@@ -11,7 +11,7 @@ import javax.imageio.ImageIO
11
11
import wechaty .padplus .PuppetPadplus
12
12
import wechaty .padplus .grpc .PadPlusServerOuterClass .{ApiType , ResponseType , StreamResponse }
13
13
import wechaty .padplus .schemas .GrpcSchemas .GrpcQrCodeLogin
14
- import wechaty .padplus .schemas .ModelContact .{GetContactSelfInfoGrpcResponse , GrpcContactPayload , PadplusContactPayload }
14
+ import wechaty .padplus .schemas .ModelContact .{GrpcContactPayload , PadplusContactPayload }
15
15
import wechaty .padplus .schemas .ModelRoom .GrpcRoomPayload
16
16
import wechaty .padplus .schemas .ModelUser .ScanData
17
17
import wechaty .padplus .schemas .PadplusEnums .QrcodeStatus
@@ -61,9 +61,6 @@ trait ContactRawSupport extends LazyLogging{
61
61
asyncRequestNothing(ApiType .GET_CONTACT ,Some (json.toString)).flatMap(_=> promise.future)
62
62
}
63
63
}
64
- def getContactSelfInfo (): Future [GetContactSelfInfoGrpcResponse ]= {
65
- asyncRequest[GetContactSelfInfoGrpcResponse ](ApiType .GET_CONTACT_SELF_INFO )
66
- }
67
64
68
65
protected def loginPartialFunction (response : StreamResponse ): PartialFunction [ResponseType , Unit ] = {
69
66
case ResponseType .QRCODE_SCAN =>
@@ -82,9 +79,9 @@ trait ContactRawSupport extends LazyLogging{
82
79
// 二维码的参数设置
83
80
val hints = new util.HashMap [DecodeHintType , String ]();
84
81
hints.put(DecodeHintType .CHARACTER_SET , " utf-8" ); // 设置二维码的编码
85
- // 得到解析结果,
86
- val result = multiFormatReader.decode(binaryBitmap, hints);
87
- val payload = new EventScanPayload
82
+ // 得到解析结果,
83
+ val result = multiFormatReader.decode(binaryBitmap, hints);
84
+ val payload = new EventScanPayload
88
85
payload.qrcode = result.getText
89
86
logger.debug(" Scan QR Code to login: %s\n https://wechaty.github.io/qrcode/%s\n " .format(payload.status, payload.qrcode))
90
87
emit(PuppetEventName .SCAN , payload)
@@ -104,9 +101,9 @@ trait ContactRawSupport extends LazyLogging{
104
101
eventLoginPayload.contactId = padplusContactPayload.userName
105
102
emit(PuppetEventName .LOGIN , eventLoginPayload)
106
103
107
- Future {
108
- getContact(padplusContactPayload.userName )
109
- }
104
+ getContact(padplusContactPayload.userName).foreach(payload => {
105
+ this .savePadplusContactPayload(payload )
106
+ })
110
107
case ResponseType .AUTO_LOGIN =>
111
108
logger.debug(" response data:{}" , response.getData)
112
109
val autoLoginData = objectMapper.readTree(response.getData)
@@ -126,14 +123,10 @@ trait ContactRawSupport extends LazyLogging{
126
123
selfId = Some (rawContactPayload.userName)
127
124
}
128
125
129
- // contactSelfInfo { padplusContact =>
130
- // selfId = Some(padplusContact.userName)
131
- // logger.debug("contactSelf:{}", padplusContact)
132
- // savePadplusContactPayload(padplusContact)
133
- // val eventLoginPayload = new EventLoginPayload
134
- // eventLoginPayload.contactId = padplusContact.userName
135
- // emit(PuppetEventName.LOGIN, eventLoginPayload)
136
- // }
126
+ contactSelfInfo().foreach(payload=> {
127
+ savePadplusContactPayload(payload)
128
+ })
129
+
137
130
} else {
138
131
deleteUin()
139
132
asyncRequest(ApiType .GET_QRCODE )
@@ -183,18 +176,8 @@ trait ContactRawSupport extends LazyLogging{
183
176
val scanData = objectMapper.readValue(scanRawData, classOf [ScanData ])
184
177
QrcodeStatus (scanData.status.intValue()) match {
185
178
case QrcodeStatus .Scanned =>
186
-
187
179
case QrcodeStatus .Confirmed =>
188
- // contactSelfInfo { padplusContact =>
189
- // selfId = Some(padplusContact.userName)
190
- // logger.debug("contactSelf:{}", padplusContact)
191
- // savePadplusContactPayload(padplusContact)
192
- // val eventLoginPayload = new EventLoginPayload
193
- // eventLoginPayload.contactId = padplusContact.userName
194
- // emit(PuppetEventName.LOGIN, eventLoginPayload)
195
- // }
196
180
case QrcodeStatus .Canceled | QrcodeStatus .Expired =>
197
-
198
181
}
199
182
}
200
183
0 commit comments