@@ -38,16 +38,9 @@ type Pusher struct {
38
38
39
39
var errNoOfflinePusher = errors .New ("no offlinePusher is configured" )
40
40
41
- func NewPusher (
42
- discov discoveryregistry.SvcDiscoveryRegistry ,
43
- offlinePusher offlinepush.OfflinePusher ,
44
- database controller.PushDatabase ,
45
- groupLocalCache * localcache.GroupLocalCache ,
46
- conversationLocalCache * localcache.ConversationLocalCache ,
47
- conversationRpcClient * rpcclient.ConversationRpcClient ,
48
- groupRpcClient * rpcclient.GroupRpcClient ,
49
- msgRpcClient * rpcclient.MessageRpcClient ,
50
- ) * Pusher {
41
+ func NewPusher (discov discoveryregistry.SvcDiscoveryRegistry , offlinePusher offlinepush.OfflinePusher , database controller.PushDatabase ,
42
+ groupLocalCache * localcache.GroupLocalCache , conversationLocalCache * localcache.ConversationLocalCache ,
43
+ conversationRpcClient * rpcclient.ConversationRpcClient , groupRpcClient * rpcclient.GroupRpcClient , msgRpcClient * rpcclient.MessageRpcClient ) * Pusher {
51
44
return & Pusher {
52
45
discov : discov ,
53
46
database : database ,
@@ -94,18 +87,7 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
94
87
return err
95
88
}
96
89
isOfflinePush := utils .GetSwitchFromOptions (msg .Options , constant .IsOfflinePush )
97
- log .ZDebug (
98
- ctx ,
99
- "push_result" ,
100
- "ws push result" ,
101
- wsResults ,
102
- "sendData" ,
103
- msg ,
104
- "isOfflinePush" ,
105
- isOfflinePush ,
106
- "push_to_userID" ,
107
- userIDs ,
108
- )
90
+ log .ZDebug (ctx , "push_result" , "ws push result" , wsResults , "sendData" , msg , "isOfflinePush" , isOfflinePush , "push_to_userID" , userIDs )
109
91
p .successCount ++
110
92
for _ , userID := range userIDs {
111
93
if isOfflinePush && userID != msg .SendID {
@@ -156,15 +138,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
156
138
}
157
139
defer func (groupID string , userIDs []string ) {
158
140
if err := p .DeleteMemberAndSetConversationSeq (ctx , groupID , userIDs ); err != nil {
159
- log .ZError (
160
- ctx ,
161
- "MemberQuitNotification DeleteMemberAndSetConversationSeq" ,
162
- err ,
163
- "groupID" ,
164
- groupID ,
165
- "userIDs" ,
166
- userIDs ,
167
- )
141
+ log .ZError (ctx , "MemberQuitNotification DeleteMemberAndSetConversationSeq" , err , "groupID" , groupID , "userIDs" , userIDs )
168
142
}
169
143
}(groupID , []string {tips .QuitUser .UserID })
170
144
pushToUserIDs = append (pushToUserIDs , tips .QuitUser .UserID )
@@ -173,21 +147,10 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
173
147
if p .UnmarshalNotificationElem (msg .Content , & tips ) != nil {
174
148
return err
175
149
}
176
- kickedUsers := utils .Slice (
177
- tips .KickedUserList ,
178
- func (e * sdkws.GroupMemberFullInfo ) string { return e .UserID },
179
- )
150
+ kickedUsers := utils .Slice (tips .KickedUserList , func (e * sdkws.GroupMemberFullInfo ) string { return e .UserID })
180
151
defer func (groupID string , userIDs []string ) {
181
152
if err := p .DeleteMemberAndSetConversationSeq (ctx , groupID , userIDs ); err != nil {
182
- log .ZError (
183
- ctx ,
184
- "MemberKickedNotification DeleteMemberAndSetConversationSeq" ,
185
- err ,
186
- "groupID" ,
187
- groupID ,
188
- "userIDs" ,
189
- userIDs ,
190
- )
153
+ log .ZError (ctx , "MemberKickedNotification DeleteMemberAndSetConversationSeq" , err , "groupID" , groupID , "userIDs" , userIDs )
191
154
}
192
155
}(groupID , kickedUsers )
193
156
pushToUserIDs = append (pushToUserIDs , kickedUsers ... )
@@ -197,16 +160,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
197
160
if p .UnmarshalNotificationElem (msg .Content , & tips ) != nil {
198
161
return err
199
162
}
200
- log .ZInfo (
201
- ctx ,
202
- "GroupDismissedNotificationInfo****" ,
203
- "groupID" ,
204
- groupID ,
205
- "num" ,
206
- len (pushToUserIDs ),
207
- "list" ,
208
- pushToUserIDs ,
209
- )
163
+ log .ZInfo (ctx , "GroupDismissedNotificationInfo****" , "groupID" , groupID , "num" , len (pushToUserIDs ), "list" , pushToUserIDs )
210
164
if len (config .Config .Manager .UserID ) > 0 {
211
165
ctx = mcontext .WithOpUserIDContext (ctx , config .Config .Manager .UserID [0 ])
212
166
}
@@ -270,35 +224,17 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
270
224
log .ZError (ctx , "offlinePushMsg failed" , err , "groupID" , groupID , "msg" , msg )
271
225
return err
272
226
}
273
- _ , err := p .GetConnsAndOnlinePush (
274
- ctx ,
275
- msg ,
276
- utils .IntersectString (needOfflinePushUserIDs , WebAndPcBackgroundUserIDs ),
277
- )
227
+ _ , err := p .GetConnsAndOnlinePush (ctx , msg , utils .IntersectString (needOfflinePushUserIDs , WebAndPcBackgroundUserIDs ))
278
228
if err != nil {
279
- log .ZError (
280
- ctx ,
281
- "offlinePushMsg failed" ,
282
- err ,
283
- "groupID" ,
284
- groupID ,
285
- "msg" ,
286
- msg ,
287
- "userIDs" ,
288
- utils .IntersectString (needOfflinePushUserIDs , WebAndPcBackgroundUserIDs ),
289
- )
229
+ log .ZError (ctx , "offlinePushMsg failed" , err , "groupID" , groupID , "msg" , msg , "userIDs" , utils .IntersectString (needOfflinePushUserIDs , WebAndPcBackgroundUserIDs ))
290
230
return err
291
231
}
292
232
}
293
233
}
294
234
return nil
295
235
}
296
236
297
- func (p * Pusher ) GetConnsAndOnlinePush (
298
- ctx context.Context ,
299
- msg * sdkws.MsgData ,
300
- pushToUserIDs []string ,
301
- ) (wsResults []* msggateway.SingleMsgToUserResults , err error ) {
237
+ func (p * Pusher ) GetConnsAndOnlinePush (ctx context.Context , msg * sdkws.MsgData , pushToUserIDs []string ) (wsResults []* msggateway.SingleMsgToUserResults , err error ) {
302
238
conns , err := p .discov .GetConns (ctx , config .Config .RpcRegisterName .OpenImMessageGatewayName )
303
239
log .ZDebug (ctx , "get gateway conn" , "conn length" , len (conns ))
304
240
if err != nil {
@@ -307,10 +243,7 @@ func (p *Pusher) GetConnsAndOnlinePush(
307
243
//Online push message
308
244
for _ , v := range conns {
309
245
msgClient := msggateway .NewMsgGatewayClient (v )
310
- reply , err := msgClient .SuperGroupOnlineBatchPushOneMsg (
311
- ctx ,
312
- & msggateway.OnlineBatchPushOneMsgReq {MsgData : msg , PushToUserIDs : pushToUserIDs },
313
- )
246
+ reply , err := msgClient .SuperGroupOnlineBatchPushOneMsg (ctx , & msggateway.OnlineBatchPushOneMsgReq {MsgData : msg , PushToUserIDs : pushToUserIDs })
314
247
if err != nil {
315
248
continue
316
249
}
@@ -323,12 +256,7 @@ func (p *Pusher) GetConnsAndOnlinePush(
323
256
return wsResults , nil
324
257
}
325
258
326
- func (p * Pusher ) offlinePushMsg (
327
- ctx context.Context ,
328
- conversationID string ,
329
- msg * sdkws.MsgData ,
330
- offlinePushUserIDs []string ,
331
- ) error {
259
+ func (p * Pusher ) offlinePushMsg (ctx context.Context , conversationID string , msg * sdkws.MsgData , offlinePushUserIDs []string ) error {
332
260
title , content , opts , err := p .getOfflinePushInfos (conversationID , msg )
333
261
if err != nil {
334
262
return err
@@ -362,10 +290,7 @@ func (p *Pusher) GetOfflinePushOpts(msg *sdkws.MsgData) (opts *offlinepush.Opts,
362
290
return opts , nil
363
291
}
364
292
365
- func (p * Pusher ) getOfflinePushInfos (
366
- conversationID string ,
367
- msg * sdkws.MsgData ,
368
- ) (title , content string , opts * offlinepush.Opts , err error ) {
293
+ func (p * Pusher ) getOfflinePushInfos (conversationID string , msg * sdkws.MsgData ) (title , content string , opts * offlinepush.Opts , err error ) {
369
294
if p .offlinePusher == nil {
370
295
err = errNoOfflinePusher
371
296
return
0 commit comments