forked from openimsdk/openim-sdk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t_group_sdk.go
519 lines (420 loc) · 15.8 KB
/
t_group_sdk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
package test
import (
"github.com/erbaner/be-core/open_im_sdk"
"github.com/erbaner/be-core/pkg/constant"
"github.com/erbaner/be-core/pkg/sdk_params_callback"
"github.com/erbaner/be-core/pkg/server_api_params"
// "encoding/json"
"fmt"
"github.com/erbaner/be-core/pkg/log"
"github.com/erbaner/be-core/pkg/utils"
//"github.com/erbaner/be-core/internal/open_im_sdk"
//"github.com/erbaner/be-core/pkg/utils"
// "github.com/erbaner/be-core/internal/common"
)
type XBase struct {
}
func (XBase) OnError(errCode int32, errMsg string) {
fmt.Println("get groupmenberinfo OnError", errCode, errMsg)
}
func (XBase) OnSuccess(data string) {
fmt.Println("get groupmenberinfo OnSuccess, ", data)
}
func (XBase) OnProgress(progress int) {
fmt.Println("OnProgress, ", progress)
}
type testGroupListener struct {
}
func (testGroupListener) OnJoinedGroupAdded(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnJoinedGroupDeleted(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupMemberAdded(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupMemberDeleted(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupApplicationAdded(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupApplicationDeleted(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupInfoChanged(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupMemberInfoChanged(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupApplicationAccepted(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
func (testGroupListener) OnGroupApplicationRejected(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)
}
type testOrganizationListener struct {
}
func (testOrganizationListener) OnOrganizationUpdated() {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), "on listener callback ")
}
type testWorkMomentsListener struct {
}
func (testWorkMomentsListener) OnRecvNewNotification() {
log.NewInfo(utils.OperationIDGenerator(), utils.GetSelfFuncName(), "on listener callback ")
}
type testCreateGroup struct {
OperationID string
}
func (t testCreateGroup) OnSuccess(data string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), data)
}
func (t testCreateGroup) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), errCode, errMsg)
}
func SetTestGroupID(groupID, memberID string) {
MemberUserID = memberID
TestgroupID = groupID
}
var MemberUserID = "2101502031"
var me = "3984071717"
var TestgroupID = "3109164461"
func DoTestCreateGroup() {
var test testCreateGroup
test.OperationID = utils.OperationIDGenerator()
var groupInfo sdk_params_callback.CreateGroupBaseInfoParam
groupInfo.GroupName = "聊聊大群测试"
groupInfo.GroupType = 1
var memberlist []server_api_params.GroupAddMemberInfo
memberlist = append(memberlist, server_api_params.GroupAddMemberInfo{UserID: MemberUserID, RoleLevel: 1})
memberlist = append(memberlist, server_api_params.GroupAddMemberInfo{UserID: me, RoleLevel: 2})
g1 := utils.StructToJsonString(groupInfo)
g2 := utils.StructToJsonString(memberlist)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ", g1, g2)
open_im_sdk.CreateGroup(test, test.OperationID, g1, g2)
}
type testSetGroupInfo struct {
OperationID string
}
func (t testSetGroupInfo) OnSuccess(data string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), data)
}
func (t testSetGroupInfo) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), errCode, errMsg)
}
func DoSetGroupInfo() {
var test testSetGroupInfo
test.OperationID = utils.OperationIDGenerator()
var input sdk_params_callback.SetGroupInfoParam
input.GroupName = "new group name 11111111"
input.Notification = "new notification 11111"
var n int32
n = 1
input.NeedVerification = &n
setInfo := utils.StructToJsonString(input)
open_im_sdk.SetGroupInfo(test, test.OperationID, TestgroupID, setInfo)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ", setInfo)
}
func DoSetGroupVerification() {
var test testSetGroupInfo
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetGroupVerification(test, test.OperationID, TestgroupID, 1)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ", TestgroupID, 2)
}
func DoSetGroupLookMemberInfo() {
var test testSetGroupInfo
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetGroupLookMemberInfo(test, test.OperationID, TestgroupID, 0)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ", TestgroupID, 1)
}
func DoSetGroupApplyMemberFriend() {
var test testSetGroupInfo
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetGroupApplyMemberFriend(test, test.OperationID, TestgroupID, 1)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ", TestgroupID, 1)
}
type testGetGroupsInfo struct {
OperationID string
}
func (t testGetGroupsInfo) OnSuccess(data string) {
log.Info(t.OperationID, "testGetGroupsInfo,onSuccess", data)
}
func (t testGetGroupsInfo) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, "testGetGroupsInfo,onError", errCode, errMsg)
}
type testSearchGroups struct {
OperationID string
}
func (t testSearchGroups) OnSuccess(data string) {
log.Info(t.OperationID, "testSearchGroups,onSuccess", data)
}
func (t testSearchGroups) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, "testSearchGroups,onError", errCode, errMsg)
}
func DoTestGetGroupsInfo() {
var test testGetGroupsInfo
groupIDList := []string{TestgroupID}
list := utils.StructToJsonString(groupIDList)
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, "test getGroupsInfo input", list)
open_im_sdk.GetGroupsInfo(test, test.OperationID, list)
}
func DoTestSearchGroups() {
var test testGetGroupsInfo
var params sdk_params_callback.SearchGroupsParam
params.KeywordList = []string{"17"}
//params.IsSearchGroupID =true
params.IsSearchGroupName = true
open_im_sdk.SearchGroups(test, test.OperationID, utils.StructToJsonString(params))
}
type testJoinGroup struct {
OperationID string
}
func (t testJoinGroup) OnSuccess(data string) {
log.Info(t.OperationID, "testJoinGroup,onSuccess", data)
}
func (t testJoinGroup) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, "testJoinGroup,onError", errCode, errMsg)
}
func DoTestJoinGroup() {
var test testJoinGroup
test.OperationID = utils.OperationIDGenerator()
groupID := "1003105543"
reqMsg := "121212"
log.Info(test.OperationID, "test join group input", groupID, reqMsg)
open_im_sdk.JoinGroup(test, test.OperationID, groupID, reqMsg, constant.JoinBySearch)
}
type testQuitGroup struct {
OperationID string
}
func (t testQuitGroup) OnSuccess(data string) {
log.Info(t.OperationID, "testQuitGroup,onSuccess", data)
}
func (t testQuitGroup) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, "testQuitGroup,onError", errCode, errMsg)
}
func DoTestQuitGroup() {
var test testQuitGroup
test.OperationID = utils.OperationIDGenerator()
groupID := "19de93b442a1ca3b772aa0f12761939d"
log.Info(test.OperationID, "test quit group input", groupID)
open_im_sdk.QuitGroup(test, test.OperationID, groupID)
}
type testGetJoinedGroupList struct {
OperationID string
}
/*
OnError(errCode int, errMsg string)
OnSuccess(data string)
*/
func (t testGetJoinedGroupList) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, "testGetJoinedGroupList OnError", errCode, errMsg)
}
func (t testGetJoinedGroupList) OnSuccess(data string) {
log.Info(t.OperationID, "testGetJoinedGroupList OnSuccess, output", data)
}
func DoTestGetJoinedGroupList() {
var test testGetJoinedGroupList
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetJoinedGroupList(test, test.OperationID)
}
type testGetGroupMemberList struct {
OperationID string
}
func (t testGetGroupMemberList) OnSuccess(data string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), "testGetGroupMemberList: ", data)
}
func (t testGetGroupMemberList) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, utils.GetSelfFuncName(), "testGetGroupMemberList", errCode, errMsg)
}
func DotestGetGroupMemberList() {
var test testGetGroupMemberList
test.OperationID = utils.OperationIDGenerator()
var groupId = TestgroupID
open_im_sdk.GetGroupMemberList(test, test.OperationID, groupId, 4, 0, 100)
}
func DotestCos() {
//var callback baseCallback
//p := ws.NewPostApi(token, userForSDK.ImConfig().ApiAddr)
//var storage common.ObjectStorage = common.NewCOS(p)
//test(storage, callback)
}
//func DotestMinio() {
// var callback baseCallback
// token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiIxMzkwMDAwMDAwMCIsIlBsYXRmb3JtIjoiSU9TIiwiZXhwIjoxNjQ1NzgyNDY0LCJuYmYiOjE2NDUxNzc2NjQsImlhdCI6MTY0NTE3NzY2NH0.T-SDoLxdlwRGOMZPIKriPtAlOGWCLodsGi1dWxN8kto"
// p := ws.NewPostApi(token, "https://storage.rentsoft.cn")
// minio := common.NewMinio(p)
// var storage common.ObjectStorage = minio
// log.NewInfo("", *minio)
// test(storage, callback)
//}
//
//func test(storage common.ObjectStorage, callback baseCallback) {
// dir, newName, err := storage.UploadFile("./main/main.go", func(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err)
// dir, newName, err = storage.UploadImage("C:\\Users\\Administrator\\Desktop\\1.jpg", func(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err, err)
// dir, newName, err = storage.UploadSound("./main/main.go", func(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err, err)
// snapshotURL, snapshotUUID, videoURL, videoUUID, err := storage.UploadVideo("./main/main.go", "C:\\Users\\Administrator\\Desktop\\1.jpg", func(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo(snapshotURL, snapshotUUID, videoURL, videoUUID, err)
//}
type testGetGroupMembersInfo struct {
}
func (testGetGroupMembersInfo) OnError(errCode int32, errMsg string) {
fmt.Println("testGetGroupMembersInfo OnError", errCode, errMsg)
}
func (testGetGroupMembersInfo) OnSuccess(data string) {
fmt.Println("testGetGroupMembersInfo OnSuccess, output", data)
}
//
//func DotestGetGroupMembersInfo() {
// var test testGetGroupMembersInfo
// var memlist []string
// memlist = append(memlist, "307edc814bb0d04a")
// //memlist = append(memlist, "ded01dfe543700402608e19d4e2f839e")
// jlist, _ := json.Marshal(memlist)
// fmt.Println("GetGroupMembersInfo input : ", string(jlist))
// sdk_interface.GetGroupMembersInfo("7ff61d8f9d4a8a0d6d70a14e2683aad5", string(jlist), test)
// //GetGroupMemberList("05dc84b52829e82242a710ecf999c72c", 0, 0, test)
//}
//
type baseCallback struct {
OperationID string
callName string
}
func (t baseCallback) OnSuccess(data string) {
log.Info(t.OperationID, t.callName, utils.GetSelfFuncName(), data)
}
func (t baseCallback) OnError(errCode int32, errMsg string) {
log.Info(t.OperationID, t.callName, utils.GetSelfFuncName(), errCode, errMsg)
}
type testKickGroupMember struct {
baseCallback
}
type testGetGroupMemberListByJoinTimeFilter struct {
baseCallback
}
func DotestGetGroupMemberListByJoinTimeFilter() {
var test testGetGroupMemberListByJoinTimeFilter
test.OperationID = utils.OperationIDGenerator()
var memlist []string
jlist := utils.StructToJsonString(memlist)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input ", jlist)
open_im_sdk.GetGroupMemberListByJoinTimeFilter(test, test.OperationID, "3750066757", 1, 40, 0, 0, jlist)
}
func DotestKickGroupMember() {
var test testKickGroupMember
test.OperationID = utils.OperationIDGenerator()
var memlist []string
memlist = append(memlist, MemberUserID)
jlist := utils.StructToJsonString(memlist)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input ", jlist)
open_im_sdk.KickGroupMember(test, test.OperationID, TestgroupID, "kkk", jlist)
}
type testInviteUserToGroup struct {
baseCallback
}
func DotestInviteUserToGroup() {
var test testInviteUserToGroup
test.OperationID = utils.OperationIDGenerator()
var memlist []string
memlist = append(memlist, MemberUserID)
jlist := utils.StructToJsonString(memlist)
log.Info(test.OperationID, utils.GetSelfFuncName(), "input ", jlist)
open_im_sdk.InviteUserToGroup(test, test.OperationID, TestgroupID, "come", string(jlist))
}
type testGetGroupApplicationList struct {
baseCallback
}
func DotestGetRecvGroupApplicationList() string {
var test testGetGroupApplicationList
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ")
open_im_sdk.GetRecvGroupApplicationList(test, test.OperationID)
return ""
}
// func DoGroupApplicationList() {
// var test testGroupX
// fmt.Println("test DoGetGroupApplicationList....")
// sdk_interface.GetGroupApplicationList(test)
// }
type testTransferGroupOwner struct {
baseCallback
}
func DotestTransferGroupOwner() {
var test testTransferGroupOwner
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.TransferGroupOwner(test, test.OperationID, TestgroupID, MemberUserID)
}
type testProcessGroupApplication struct {
baseCallback
}
func DoTestAcceptGroupApplication(uid string) {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ")
open_im_sdk.AcceptGroupApplication(test, test.OperationID, TestgroupID, MemberUserID, "ok")
}
func DoTestGetUserReqGroupApplicationList() {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ")
open_im_sdk.GetSendGroupApplicationList(test, test.OperationID)
}
// 提示
func DoTestGetRecvGroupApplicationList() {
var test testProcessGroupApplication
log.Info(test.OperationID, utils.GetSelfFuncName(), "input:")
open_im_sdk.GetRecvGroupApplicationList(test, test.OperationID)
}
func DotestRefuseGroupApplication(uid string) {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ")
open_im_sdk.RefuseGroupApplication(test, test.OperationID, TestgroupID, MemberUserID, "no")
}
type testSetGroupMemberNickname struct {
baseCallback
}
func DotestSetGroupMemberNickname(myUserID string) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
log.Info(test.OperationID, utils.GetSelfFuncName(), "input: ")
open_im_sdk.SetGroupMemberNickname(test, test.OperationID, TestgroupID, myUserID, "")
}
func DoTestSetGroupMemberRoleLevel(groupID, userID string, roleLevel int) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
fmt.Println(test.OperationID, utils.GetSelfFuncName(), "inputx: ")
open_im_sdk.SetGroupMemberRoleLevel(test, test.OperationID, groupID, userID, roleLevel)
}
func DoTestSetGroupMemberInfo(groupID, userID string, ex string) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
param := sdk_params_callback.SetGroupMemberInfoParam{GroupID: groupID, UserID: userID}
if ex != "" {
param.Ex = &ex
}
g1 := utils.StructToJsonString(param)
fmt.Println(test.OperationID, utils.GetSelfFuncName(), "inputx: ", g1)
open_im_sdk.SetGroupMemberInfo(test, test.OperationID, g1)
}