Compare commits

..

1249 Commits

Author SHA1 Message Date
wangchuxiao 0c7cb274b4 Merge branch 'tuoyun' 2022-04-08 18:37:35 +08:00
wangchuxiao a08c499c95 getui 2022-04-08 18:35:53 +08:00
wangchuxiao a879bbce59 getui 2022-04-08 18:29:54 +08:00
wangchuxiao f11f8b3e0e getui 2022-04-08 18:27:20 +08:00
wangchuxiao 7842545627 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-08 18:01:11 +08:00
Gordon 2a0f8f5ce3 note 2022-04-08 17:55:44 +08:00
wangchuxiao 4ae3ad7abd getui 2022-04-08 17:48:16 +08:00
wangchuxiao a16025ca95 getui 2022-04-08 17:41:39 +08:00
wangchuxiao fdefe09187 getui 2022-04-08 17:32:58 +08:00
wangchuxiao 06370a763c getui 2022-04-08 17:20:55 +08:00
wangchuxiao 691e2580e5 getui 2022-04-08 17:17:26 +08:00
wangchuxiao f40369d061 getui 2022-04-08 17:12:11 +08:00
wangchuxiao 046c523880 getui 2022-04-08 17:00:28 +08:00
wangchuxiao b3b7ae26cf getui 2022-04-08 16:40:39 +08:00
wangchuxiao 49424b8b56 getui 2022-04-08 16:23:53 +08:00
wenxu12345 68ff4a52dc Merge remote-tracking branch 'origin/main' 2022-04-08 16:21:12 +08:00
wenxu12345 07c932e9e6 v2.0.7 2022-04-08 16:20:41 +08:00
wangchuxiao cbe3abeab0 getui 2022-04-08 16:15:22 +08:00
wangchuxiao 3d5e3ce6cf Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
# Conflicts:
#	internal/rpc/msg/tag_send_msg.go
2022-04-08 15:43:55 +08:00
wangchuxiao 4efdabc1ff getui 2022-04-08 15:40:07 +08:00
Gordon 8ca495ec50 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-06 16:47:32 +08:00
Gordon 69aba02c9a send tag modify 2022-04-06 16:47:22 +08:00
wenxu12345 42225dd35e log 2022-04-06 15:54:59 +08:00
wenxu12345 ad4c9fcc83 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-06 15:33:30 +08:00
wenxu12345 ef4d0c3c42 log 2022-04-06 15:33:16 +08:00
Gordon 59cc45eaab replace log 2022-04-06 14:41:36 +08:00
Gordon f64c40e91f tag msg 2022-04-06 14:31:25 +08:00
Gordon 46d7d30089 shell update 2022-04-06 12:01:29 +08:00
Gordon 48f15bb71c shell update 2022-04-06 11:59:30 +08:00
Gordon ac70b1d11b Merge branch 'tuoyun' 2022-04-06 11:56:22 +08:00
Gordon d720082644 shell update 2022-04-06 11:47:01 +08:00
Gordon 1f45b642e9 build modify 2022-04-05 20:11:57 +08:00
Gordon 83228d8aa6 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-05 20:10:35 +08:00
Gordon 34f1e50f90 build modify 2022-04-05 20:10:05 +08:00
wenxu12345 b0c518a0d6 log 2022-04-05 20:06:15 +08:00
wenxu12345 aa673a3a5c log 2022-04-05 20:06:08 +08:00
wenxu12345 40d58f6bc2 log 2022-04-05 19:49:49 +08:00
wenxu12345 7604b24ffc log 2022-04-05 19:48:31 +08:00
wenxu12345 a47c0c91a3 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-05 19:31:52 +08:00
wenxu12345 0232f52281 log 2022-04-05 19:31:35 +08:00
Gordon 08eba71c8a remove timer 2022-04-05 17:50:26 +08:00
Gordon 577a9249d1 test 2022-04-05 17:31:32 +08:00
Gordon ea6461bd0a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-05 17:20:32 +08:00
Gordon f58c94146a test 2022-04-05 17:20:22 +08:00
wenxu12345 6efe13d142 log 2022-04-05 16:41:37 +08:00
wenxu12345 0a8fdc6cc8 set gin log 2022-04-05 16:24:34 +08:00
wenxu12345 b91b298174 Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	cmd/Open-IM-SDK-Core
2022-04-05 15:08:25 +08:00
wenxu12345 f87038622b set gin log 2022-04-05 15:07:34 +08:00
Gordon 8b077848bb Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-05 14:56:39 +08:00
Gordon 2945e6f8bf test 2022-04-05 14:56:29 +08:00
wenxu12345 0f760dc388 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-05 14:48:03 +08:00
wenxu12345 5a9b5db99b Check environment before deployment 2022-04-05 14:47:47 +08:00
wangchuxiao 6ba51fb338 tag and set private tips 2022-04-05 14:27:13 +08:00
wangchuxiao 146aa497f9 tag and set private tips 2022-04-05 12:09:55 +08:00
wangchuxiao e7bc82d152 tag and set private tips 2022-04-05 12:03:54 +08:00
wangchuxiao 26f8172b1a tag and set private tips 2022-04-05 11:55:40 +08:00
wangchuxiao 634584400a tag and set private tips 2022-04-05 11:50:26 +08:00
wangchuxiao 7d6be79ba8 tag and set private tips 2022-04-05 10:33:50 +08:00
wangchuxiao cef208f6ef Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-05 10:27:43 +08:00
wangchuxiao f4921d1317 tag and set private tips 2022-04-05 10:27:34 +08:00
Gordon 7f1a74b576 panic fix 2022-04-01 20:40:58 +08:00
wangchuxiao 3dc11777c6 minio cfg 2022-04-01 19:23:22 +08:00
wangchuxiao b536165910 Merge branch 'tuoyun' 2022-04-01 19:19:10 +08:00
wenxu12345 7c7aa9e7a7 v2.0.6 2022-04-01 18:45:10 +08:00
wangchuxiao 2b03b57b5c tag and set private tips 2022-04-01 15:59:49 +08:00
wangchuxiao 77c6120014 null to empty slice 2022-04-01 15:32:24 +08:00
wangchuxiao b82ff7b88d tips info 2022-04-01 14:49:48 +08:00
wangchuxiao a16a75230c tag and set private tips 2022-04-01 14:43:31 +08:00
wangchuxiao 0e27b302bc tag and set private tips 2022-03-31 19:49:04 +08:00
wangchuxiao c369ab9b1c Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-31 19:45:57 +08:00
wangchuxiao bb267ccae7 tag and set private tips 2022-03-31 19:17:37 +08:00
Gordon efe24658a4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-31 18:38:05 +08:00
Gordon 5cdf9e7551 OA tag fields modify 2022-03-31 18:36:15 +08:00
wangchuxiao 4390302384 tag and set private tips 2022-03-31 16:50:46 +08:00
wangchuxiao dab00e7fb2 tag and set private tips 2022-03-31 15:01:49 +08:00
wangchuxiao 929c5e7a5b Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-31 14:50:17 +08:00
wangchuxiao d600042110 tag and set private tips 2022-03-31 14:50:02 +08:00
Gordon 0a58e7433e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-31 11:43:25 +08:00
Gordon 5639c985df OA tag fields modify 2022-03-31 11:43:14 +08:00
wenxu12345 9fbfbfb23b Merge log files 2022-03-31 11:28:51 +08:00
wenxu12345 ecd2f0e2bf Merge log files 2022-03-31 11:15:06 +08:00
Gordon 60418276bd oa notification add 2022-03-30 20:04:12 +08:00
Gordon 170392f0bc oa notification add 2022-03-30 18:23:05 +08:00
Gordon 6744745152 token add operationID 2022-03-30 15:52:04 +08:00
skiffer-git 009ae6a235 mute group 2022-03-29 18:54:55 +08:00
skiffer-git bf5f72c00b mute group 2022-03-29 18:36:24 +08:00
skiffer-git 84aca5b9e1 mute group 2022-03-29 18:29:19 +08:00
skiffer-git 6164266870 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 18:24:22 +08:00
skiffer-git cc9df9c586 mute group 2022-03-29 18:24:10 +08:00
wangchuxiao 29a268d476 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-29 17:33:13 +08:00
wangchuxiao 18d7aab703 tag 2022-03-29 17:33:06 +08:00
skiffer-git 373e6b6c8e mute group 2022-03-29 17:29:05 +08:00
skiffer-git 71fab4f6be Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 17:24:55 +08:00
skiffer-git de55c14a16 mute group 2022-03-29 17:24:46 +08:00
Gordon e8517e954d group add 2022-03-29 17:20:37 +08:00
Gordon 78281fc82c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 17:16:02 +08:00
Gordon bc260fffde group add 2022-03-29 17:15:51 +08:00
skiffer-git db00a08bdc Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 17:03:17 +08:00
skiffer-git 85cf7f26ce mute group 2022-03-29 17:03:06 +08:00
Gordon acca147ff2 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 16:56:43 +08:00
Gordon d53da0e422 group add 2022-03-29 16:56:33 +08:00
skiffer-git 11eaaab72d Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 16:32:43 +08:00
skiffer-git 475e64fc5b mute group 2022-03-29 16:32:25 +08:00
wangchuxiao 1bd8154ac4 tag 2022-03-29 16:15:37 +08:00
wangchuxiao d2fa0e7852 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-29 16:10:43 +08:00
wangchuxiao f2b324abc2 tag 2022-03-29 16:10:36 +08:00
skiffer-git d2225dd841 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 16:05:16 +08:00
skiffer-git 8d26aa86b9 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 16:05:08 +08:00
wangchuxiao 7e937d7d29 tag 2022-03-29 16:04:54 +08:00
skiffer-git fe4b534b78 mute group 2022-03-29 16:04:15 +08:00
wangchuxiao d0a65c7c68 tag 2022-03-29 15:58:42 +08:00
wangchuxiao 416f87f4bb tag 2022-03-29 15:50:20 +08:00
wangchuxiao 7eeb67be28 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-29 15:35:18 +08:00
wangchuxiao 7ed6ee5075 tag 2022-03-29 15:35:03 +08:00
wenxu12345 d3c8215e15 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 13:31:19 +08:00
wenxu12345 30bc6c274e mute group 2022-03-29 13:30:54 +08:00
skiffer-git ecb1068f0b mute group 2022-03-29 12:40:08 +08:00
wenxu12345 f6eef21b45 mute group 2022-03-29 11:55:48 +08:00
skiffer-git 1aeff25316 mute group 2022-03-29 11:48:17 +08:00
skiffer-git 6de569537f Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-29 11:36:11 +08:00
skiffer-git 764bc3fead mute group 2022-03-29 11:35:53 +08:00
Gordon a89d617532 group add 2022-03-29 11:27:19 +08:00
Gordon fef33795d0 group add 2022-03-29 11:16:03 +08:00
Gordon d2c04b761d ali cloud oss 2022-03-29 11:01:54 +08:00
Gordon c5828aba91 Merge branch 'tuoyun'
# Conflicts:
#	cmd/open_im_api/main.go
#	config/config.yaml
#	go.sum
#	pkg/common/config/config.go
#	pkg/common/db/model.go
2022-03-29 10:58:01 +08:00
skiffer-git 1286f9dcb6 mute group 2022-03-29 09:34:45 +08:00
skiffer-git 391e525fc5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-28 19:27:23 +08:00
skiffer-git afc32b1cfa mute group 2022-03-28 19:27:05 +08:00
wangchuxiao 0797181967 tag 2022-03-28 19:18:30 +08:00
wangchuxiao 14c5e631ff tag 2022-03-28 19:15:59 +08:00
wangchuxiao 5cdb039c33 tag 2022-03-28 19:12:31 +08:00
wangchuxiao a11c4fcb58 tag 2022-03-28 19:05:58 +08:00
wangchuxiao c67a937d40 tag 2022-03-28 18:53:57 +08:00
wangchuxiao 03fa7137b9 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-28 18:52:02 +08:00
wangchuxiao e95400988e tag 2022-03-28 18:51:48 +08:00
Gordon 942c9c6a63 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-28 18:30:21 +08:00
Gordon 6c45665fde add tag message conversation update 2022-03-28 18:30:12 +08:00
wangchuxiao d92ac8f588 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-28 18:13:08 +08:00
wangchuxiao 169665da32 tag 2022-03-28 18:13:01 +08:00
Gordon c4d80b4844 auto migrate test 2022-03-28 17:52:40 +08:00
Gordon 7827749453 tag notification 2022-03-28 17:37:30 +08:00
wangchuxiao 5e78697a69 tag 2022-03-28 17:22:18 +08:00
wangchuxiao a0e6a78496 tag 2022-03-28 17:18:03 +08:00
wangchuxiao af99a93536 tag 2022-03-28 17:12:36 +08:00
wangchuxiao e9ea117985 tag 2022-03-28 17:10:45 +08:00
wangchuxiao b9ddb0140f tag 2022-03-28 17:02:03 +08:00
wangchuxiao dae70371d1 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-28 16:59:39 +08:00
wangchuxiao 228cbb4082 tag 2022-03-28 16:59:15 +08:00
Gordon 679c913f3a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-28 16:57:24 +08:00
Gordon 03fb7947c3 add oa notification 2022-03-28 16:57:08 +08:00
wangchuxiao c39f5a27b2 tag 2022-03-28 16:49:19 +08:00
wangchuxiao dbdb516f3c tag 2022-03-28 16:42:18 +08:00
wangchuxiao c1a97b7356 tag 2022-03-28 16:20:20 +08:00
wangchuxiao a6d8f7ea24 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-28 16:03:16 +08:00
wangchuxiao 574c7600e0 tag 2022-03-28 16:02:31 +08:00
Gordon d1c0205d77 add oa notification 2022-03-28 15:55:55 +08:00
wangchuxiao 13c29d2c1e tag 2022-03-28 15:04:42 +08:00
wangchuxiao dc1a0f050e tag 2022-03-28 14:54:46 +08:00
wangchuxiao e252a00d55 tag 2022-03-28 14:11:47 +08:00
Gordon 5bedbb7c7d script modify 2022-03-28 12:56:59 +08:00
wangchuxiao e510418152 Merge branch 'office_tag' into tuoyun 2022-03-28 12:17:48 +08:00
wangchuxiao 8197ae6aa7 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-28 12:17:32 +08:00
wangchuxiao 9d619d520d tag 2022-03-28 12:17:07 +08:00
wangchuxiao 46605479e9 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into office_tag 2022-03-25 18:48:30 +08:00
wangchuxiao 6d20eddd43 mongo 2022-03-25 18:46:27 +08:00
skiffer-git c1ee2a0adb Update docker-compose.yaml 2022-03-25 12:48:11 +08:00
skiffer-git 9d29d49ada group dismissed 2022-03-24 15:33:30 +08:00
wangchuxiao e7b95892ff minio upload api 2022-03-23 17:40:51 +08:00
wangchuxiao 4bf5c77374 mongo 2022-03-23 17:18:40 +08:00
wangchuxiao df4a75f4b0 mongo 2022-03-23 17:15:46 +08:00
wangchuxiao 4bdb4cbbb5 mongo 2022-03-23 16:13:18 +08:00
wangchuxiao 4cdcdee8e4 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-23 15:44:59 +08:00
wangchuxiao e6c36411cb mongo 2022-03-23 15:44:34 +08:00
skiffer-git a4788a95af Update issue templates 2022-03-23 11:33:35 +08:00
Gordon b5de638c0b ws remove log 2022-03-23 11:32:58 +08:00
skiffer-git c1a210313e Update issue templates 2022-03-23 11:28:08 +08:00
skiffer-git ab0ed67f81 Update issue templates 2022-03-23 11:26:25 +08:00
skiffer-git 5d54d5b7d6 Update issue templates 2022-03-23 11:25:59 +08:00
Gordon 1d09ffa529 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-22 18:13:48 +08:00
Gordon eef9d15aaa ws remove log 2022-03-22 18:13:34 +08:00
wangchuxiao 8034ddc413 mongo 2022-03-22 14:30:07 +08:00
wangchuxiao e75adb165a mongo 2022-03-21 19:36:10 +08:00
wangchuxiao 09ce0d5285 mongo 2022-03-21 19:19:33 +08:00
wangchuxiao cc1ad41e94 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-21 16:57:14 +08:00
wangchuxiao 8a38646bc5 mongo 2022-03-21 16:56:52 +08:00
Gordon a2b65f52f6 fix group create bug 2022-03-21 15:45:26 +08:00
jaonzyx c16d8da784 管理员创建群组bug fix (#168) 2022-03-21 15:43:43 +08:00
goubo a55582a018 方便测试导入数据 (#148) 2022-03-21 15:25:41 +08:00
Gordon ea6d472002 pr modify and update 2022-03-21 14:59:00 +08:00
Gordon 3dc4290f2a pr modify and update 2022-03-21 14:57:35 +08:00
hxnets 6c43f75f9f 新增阿里云OSS文件上传参数获取接口 (#115)
* configure update

* mongo:4.0

* open-im-server -> open_im_server

* sleep 15

* 0.0.0.0

* sleep 10 15

* Update config.yaml

* config

* Update docker-compose.yaml

* Update config.yaml

* Create ISSUE_TEMPLATE.md

* Update ISSUE_TEMPLATE.md

* Create ISSUE_TEMPLATE

* add issue template

* add issue template

* add issue template

* add issue template

* Update README.md

* script

* script

* script

* config

* script

* config update

* script update

* image: openim/open_im_server:v1.0.6

* script

* script

* script

* version update

* sender message sync

* version update

* 阿里云oss sts上传参数

* 阿里云oss sts上传参数

Co-authored-by: wenxu12345 <44203734@qq.com>
Co-authored-by: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Co-authored-by: Gordon <1432970085@qq.com>
Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2022-03-21 14:43:41 +08:00
Sunny e0c6972bed Update config.yaml (#167)
Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2022-03-21 11:19:10 +08:00
马守越 1ab3e04cba 新增mongo.dbUrl配置 (#174)
* 当dbUri值不为空则直接使用该值

* 新增支持ali oss

Co-authored-by: mashouyue's m1max <mashouyue@toowow.cn>
2022-03-21 11:13:17 +08:00
Arthur 1b8f664c8a fix: json tag value of UserIDResult.UserID (#178)
Signed-off-by: arthur <yang_yapo@126.com>
2022-03-21 11:03:46 +08:00
Gordon 25adfe5b28 check shell update 2022-03-18 20:06:52 +08:00
Gordon 7637b2bec2 check shell update 2022-03-18 19:08:31 +08:00
Gordon 6b3d984ca6 log update 2022-03-18 19:02:46 +08:00
Gordon da5bfe32af log update 2022-03-18 18:18:10 +08:00
wenxu12345 cfab49a7dd friendVerify 2022-03-18 17:44:50 +08:00
Gordon f93d22ae22 log update 2022-03-18 17:35:09 +08:00
wenxu12345 91b9e50fd0 2.0.4 2022-03-18 17:21:04 +08:00
wenxu12345 1b457b0be6 fix bug : etcd Put failed etcdserver: requested lease not found 2022-03-18 11:10:06 +08:00
wangchuxiao d77894c8fe rtc add 2022-03-17 20:55:47 +08:00
wangchuxiao 366f7621fa rtc add 2022-03-17 19:00:05 +08:00
wangchuxiao 984bc37e29 middleware 2022-03-17 16:43:10 +08:00
wangchuxiao 604de144b9 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-17 16:31:55 +08:00
Gordon 5dddaeb6e5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-17 15:47:20 +08:00
Gordon 7790686a84 ws add token platform verify 2022-03-17 15:46:32 +08:00
wenxu12345 60950f056b fix bug : etcd Put failed etcdserver: requested lease not found 2022-03-17 14:56:18 +08:00
wangchuxiao ef07634e09 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-17 14:13:24 +08:00
wangchuxiao f70a20f740 rtc add 2022-03-17 14:12:49 +08:00
wenxu12345 c1cda2d536 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-17 13:49:49 +08:00
wenxu12345 2b03e7aea8 add log 2022-03-17 13:49:21 +08:00
wangchuxiao 58cea3e947 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-17 12:49:00 +08:00
wangchuxiao f02fb7ba15 rtc add 2022-03-17 12:48:54 +08:00
wangchuxiao fbafcd0cbc rtc add 2022-03-17 12:48:24 +08:00
Gordon bf09c88e6e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-17 12:08:47 +08:00
Gordon cb8f7e0ddb mongo single node 2022-03-17 12:08:39 +08:00
wenxu12345 f63aa33082 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-17 11:57:33 +08:00
wenxu12345 7bdf6717e1 add log 2022-03-17 11:57:21 +08:00
Gordon 2fc2801ad4 mongo single node 2022-03-17 11:55:35 +08:00
Gordon 2bb6061a44 pb modify 2022-03-17 10:41:34 +08:00
wangchuxiao a0e3488af0 rtc proto modify 2022-03-17 10:33:20 +08:00
wangchuxiao 8fef1f975a rtc add 2022-03-16 20:37:37 +08:00
wangchuxiao 17fad47ca1 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-16 18:02:33 +08:00
wangchuxiao b0aa168c9a rtc add 2022-03-16 18:02:26 +08:00
Gordon 367888968b log add 2022-03-16 16:09:39 +08:00
wenxu12345 11c65e6b90 signaling add participant 2022-03-16 15:45:34 +08:00
wenxu12345 e9699ed8cc Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-16 15:31:27 +08:00
wenxu12345 812362338e signaling add participant 2022-03-16 15:31:15 +08:00
Gordon b7ff0cf2a2 meta data add 2022-03-16 15:21:18 +08:00
wangchuxiao fa21ae6161 rtc add 2022-03-16 14:59:15 +08:00
wenxu12345 fb815c0be0 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-16 14:13:45 +08:00
wenxu12345 27c6a187a2 signaling 2022-03-16 14:13:30 +08:00
Gordon 852d3b9f48 add friend and blacklist judge 2022-03-16 11:25:44 +08:00
Gordon 10884b8175 add friend and blacklist judge 2022-03-16 11:18:59 +08:00
wenxu12345 5f37414fee delete msg from server 2022-03-16 10:44:58 +08:00
wenxu12345 e95644ada2 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-15 19:08:57 +08:00
wenxu12345 ab4aee93c1 delete msg from server 2022-03-15 19:08:40 +08:00
Gordon 5df94a03fe Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-15 19:03:35 +08:00
Gordon ab9f3a1635 add friend and blacklist judge 2022-03-15 19:03:22 +08:00
wenxu12345 110c43b97a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-15 18:14:11 +08:00
wenxu12345 e0a86a8016 delete msg from server 2022-03-15 18:13:58 +08:00
Gordon 9e7f3b83c4 config explanation 2022-03-15 17:25:31 +08:00
Gordon 011960b159 send msg add protect 2022-03-15 14:16:14 +08:00
Gordon d23a3cedef pb modify 2022-03-15 11:16:00 +08:00
Gordon b782b539a5 pb modify 2022-03-15 11:15:20 +08:00
wenxu12345 2930e49d61 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-15 10:57:16 +08:00
Gordon 45777e6047 pb modify 2022-03-15 10:53:56 +08:00
wenxu12345 204b27ca5d pb platformID 2022-03-15 10:51:25 +08:00
Gordon dde8f427af pb modify 2022-03-15 10:41:19 +08:00
Gordon 1db0966675 pb modify 2022-03-15 10:17:24 +08:00
wenxu12345 b4c16002ff signaling 2022-03-15 10:16:13 +08:00
Gordon ca23c76426 pb modify 2022-03-15 10:11:14 +08:00
Gordon 0c50815944 server modify 2022-03-15 10:03:39 +08:00
wenxu12345 185f3c05fb signaling 2022-03-15 10:02:52 +08:00
Gordon bde88ecc79 server modify 2022-03-15 10:00:45 +08:00
Gordon 38e5b1f853 server modify 2022-03-15 09:50:37 +08:00
wenxu12345 83fffe717e signaling 2022-03-15 09:47:17 +08:00
Gordon 8757faf965 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-14 20:57:59 +08:00
Gordon 9b61fb1f85 ws modify 2022-03-14 20:57:40 +08:00
wangchuxiao 16a6465453 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-14 20:02:58 +08:00
wangchuxiao 1d3f05c22b rtc 2022-03-14 20:02:42 +08:00
Gordon 470bdb6efb ws modify 2022-03-14 19:46:01 +08:00
wenxu12345 fa53530055 signaling 2022-03-14 19:44:23 +08:00
Gordon 02d0b4c99b ws.proto 2022-03-14 19:41:00 +08:00
Gordon ca9ac35eb5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-14 18:40:14 +08:00
Gordon cb68f83451 signal update 2022-03-14 18:39:59 +08:00
wangchuxiao 972675d4da Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-14 18:33:16 +08:00
wangchuxiao 347b1dd31c livekit 2022-03-14 18:33:00 +08:00
Gordon d34e729e32 signal update 2022-03-14 18:22:48 +08:00
Gordon 4954dcead8 grpc version 2022-03-14 18:19:03 +08:00
Gordon a2f3677784 grpc version 2022-03-14 18:01:50 +08:00
Gordon fb22b8bba5 grpc version 2022-03-14 18:00:12 +08:00
Gordon c0ca3569fd grpc version 2022-03-14 17:58:32 +08:00
Gordon bae5042eea grpc version 2022-03-14 17:56:20 +08:00
Gordon a5f831e81e grpc version 2022-03-14 17:41:05 +08:00
Gordon 6cb6c60eba etcd version 2022-03-14 17:39:36 +08:00
Gordon d4098180b6 etcd version 2022-03-14 17:38:15 +08:00
Gordon 9bec4b2713 etcd version 2022-03-14 17:36:48 +08:00
Gordon 82b899f883 etcd version 2022-03-14 17:34:54 +08:00
Gordon 69daec4f86 remove timer 2022-03-14 17:19:50 +08:00
Gordon e5d348140c add Signal message 2022-03-14 17:17:40 +08:00
Gordon 8ba136e0a3 add Signal message 2022-03-14 17:15:55 +08:00
Gordon 63f48a3c4c add Signal message 2022-03-14 17:13:57 +08:00
Gordon e9d10bc012 add Signal message 2022-03-14 17:13:13 +08:00
Gordon 96be2e6262 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-14 17:12:36 +08:00
Gordon 91fa230016 add Signal message 2022-03-14 17:12:26 +08:00
wangchuxiao d4b33a1342 cfg 2022-03-14 17:00:03 +08:00
wangchuxiao 8d08bc7fd1 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-14 16:56:09 +08:00
Gordon 7c08249e08 add Signal message 2022-03-14 16:51:16 +08:00
Gordon 4f5fff96e0 add Signal message 2022-03-14 16:49:04 +08:00
Gordon cf6379283b add Signal message 2022-03-14 16:47:18 +08:00
Gordon 9659638f0c add Signal message 2022-03-14 16:33:59 +08:00
Gordon 433fef9992 add Signal message 2022-03-14 16:05:16 +08:00
Gordon d60039454a add Signal message 2022-03-14 16:04:49 +08:00
wangchuxiao d90b31c5df Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-14 15:18:47 +08:00
Gordon 965dac5ff9 constant 2022-03-14 15:14:14 +08:00
wenxu12345 564f77bcdc signaling 2022-03-14 15:04:34 +08:00
Gordon 6136ac4116 ws proto modify 2022-03-14 14:59:23 +08:00
Gordon bba84b4d11 ws proto modify 2022-03-14 14:28:35 +08:00
wenxu12345 b52317f56b signaling 2022-03-14 10:58:41 +08:00
wenxu12345 98f2806be6 signaling 2022-03-14 10:38:35 +08:00
wenxu12345 ebf7a1d40d v2.0.3 image 2022-03-14 10:23:44 +08:00
Gordon 0ce164079e ws modify 2022-03-14 10:00:28 +08:00
wangchuxiao 3693d2e93d conversation table 2022-03-13 10:07:31 +08:00
Judgelight d3a38963ae Merge pull request #173 from OpenIMSDK/tuoyun
Tuoyun
2022-03-11 18:44:48 +08:00
wenxu12345 9ab9ae0408 signal 2022-03-11 18:12:34 +08:00
wenxu12345 0abb4a82b1 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-11 18:11:47 +08:00
wenxu12345 94a579e7d3 signal 2022-03-11 18:11:22 +08:00
Gordon 9d132d7f92 int32 modify 2022-03-11 18:10:58 +08:00
Gordon 0315abc0df utils modify 2022-03-11 18:09:28 +08:00
Gordon 24e04f1303 utils modify 2022-03-11 18:06:46 +08:00
wangchuxiao 51c2f845d8 opt 2022-03-11 17:37:01 +08:00
Gordon edc81534c4 ws modify 2022-03-11 17:29:20 +08:00
wenxu12345 b10ba999cd join time 2022-03-10 12:27:16 +08:00
wenxu12345 12d10ce8b5 fix bug: group member jointime 2022-03-10 12:01:28 +08:00
wenxu12345 c4554cb4e9 1.statistics log
2. Handle exception : etcd keepalive failed
2022-03-09 11:25:51 +08:00
wenxu12345 0e575a9366 keepalive ttl * 3
add user.ex
2022-03-08 18:48:36 +08:00
Gordon 13efbf5f98 log level 2022-03-07 11:50:35 +08:00
Gordon c8be20e9f2 tag update 2022-03-04 19:31:03 +08:00
Gordon 15aabb3859 log 2022-03-04 19:19:06 +08:00
Gordon b2a9867297 Merge branch 'tuoyun' 2022-03-04 19:10:32 +08:00
Gordon e734b000de log 2022-03-04 19:01:32 +08:00
wangchuxiao 127e5af6f3 cfg 2022-03-04 18:44:38 +08:00
wangchuxiao 319f46406c cfg 2022-03-04 18:37:55 +08:00
wangchuxiao ddf79d06d0 callback 2022-03-04 18:26:07 +08:00
wangchuxiao fafad9217d cb 2022-03-04 18:23:58 +08:00
Gordon 08022497e6 log 2022-03-04 18:21:14 +08:00
Gordon 29f849c184 log 2022-03-04 18:20:57 +08:00
wangchuxiao 1572d9df89 cb 2022-03-04 18:17:44 +08:00
wangchuxiao 4c297164a5 cb 2022-03-04 18:03:22 +08:00
Gordon a7c8eda290 log 2022-03-04 17:29:15 +08:00
Gordon 1bcd2d4531 log 2022-03-04 17:26:50 +08:00
Gordon eb1e596cde log 2022-03-04 17:26:08 +08:00
Gordon 9bbcf0c5d7 log 2022-03-04 17:16:21 +08:00
Gordon 341ec6e9a0 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-03-04 17:13:33 +08:00
Gordon 7e9234e712 log 2022-03-04 17:13:23 +08:00
wangchuxiao fec33c0b96 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-04 16:53:27 +08:00
Gordon af2917adb9 log 2022-03-04 16:38:53 +08:00
wangchuxiao 2e1459e29c Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-04 16:38:03 +08:00
wangchuxiao 95f6035aa8 add cb 2022-03-04 16:37:49 +08:00
Gordon d6e7cfb044 shell update 2022-03-04 16:24:28 +08:00
Gordon 8dc04667b0 test recover 2022-03-04 16:11:04 +08:00
wangchuxiao c108115c83 add callback 2022-03-04 15:20:59 +08:00
wangchuxiao bcae7720e1 add callback 2022-03-04 14:27:54 +08:00
wangchuxiao 399d0b94d5 msg callback 2022-03-03 19:47:30 +08:00
wangchuxiao a5712e1216 msg callback 2022-03-03 19:44:34 +08:00
wangchuxiao 3805db1263 msg callback 2022-03-03 19:39:49 +08:00
wangchuxiao 88b8a5323a msg callback 2022-03-03 19:23:16 +08:00
wangchuxiao 02510528d1 msg callback 2022-03-03 19:09:59 +08:00
wangchuxiao 7deffeffd8 msg callback 2022-03-03 19:06:00 +08:00
wangchuxiao 4d4520226d msg callback 2022-03-03 18:49:36 +08:00
wangchuxiao 9f80e0a0e6 alter callback fg 2022-03-03 17:54:31 +08:00
wangchuxiao 2ed3fd3cba alter callback fg 2022-03-03 17:53:37 +08:00
wangchuxiao 3698f1dab8 alter callback fg 2022-03-03 16:50:06 +08:00
wangchuxiao fb4c02ca9b alter callback fg 2022-03-03 16:47:03 +08:00
wangchuxiao 9cec4b0c8e alter callback fg 2022-03-03 16:41:17 +08:00
wangchuxiao 6cef26f893 alter callback fg 2022-03-03 16:23:59 +08:00
wangchuxiao e2b5b7016c add debug log 2022-03-03 16:08:46 +08:00
wangchuxiao 2d55e2edd5 alter cfg 2022-03-03 15:59:31 +08:00
wangchuxiao 85dbf4f98f alter port 2022-03-03 15:52:19 +08:00
wangchuxiao d13a6b0c36 add callback 2022-03-03 14:42:50 +08:00
wangchuxiao 48f03f306a Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-03 14:18:35 +08:00
wangchuxiao f1c11ac114 add callback 2022-03-03 14:18:28 +08:00
Gordon 97ec9602f7 callback note 2022-03-03 12:11:38 +08:00
Gordon 53cdf884ef Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	config/config.yaml
2022-03-03 10:56:37 +08:00
Gordon d8a729c961 config update 2022-03-03 10:53:44 +08:00
FG 25f24801d6 log 2022-03-02 22:52:39 +08:00
skiffer-git e6b302abf9 log 2022-03-02 21:02:21 +08:00
skiffer-git c0c08fe373 adjust log 2022-03-02 20:59:54 +08:00
wangchuxiao 60e29cc894 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-03-02 19:07:28 +08:00
wangchuxiao dcfd802757 callback add 2022-03-02 19:07:17 +08:00
skiffer-git 84a01569d6 limit mongo memory 2022-03-02 09:45:12 +08:00
Gordon 72ed38156a test code 2022-03-01 17:48:53 +08:00
Gordon 0e9e02de0b statistics code 2022-03-01 15:53:33 +08:00
skiffer-git 58163cefa0 set max open file num 2022-03-01 15:32:47 +08:00
skiffer-git c4ec54f6e4 Statistics 2022-03-01 15:22:02 +08:00
skiffer-git de7dae4455 statistics 2022-03-01 15:17:43 +08:00
skiffer-git 6362500741 Statistics 2022-03-01 15:14:56 +08:00
skiffer-git 9b3d1f5734 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-28 19:10:44 +08:00
skiffer-git 123aad2707 statistics log 2022-02-28 19:10:32 +08:00
wangchuxiao 0bed7ee669 merge code 2022-02-28 17:57:03 +08:00
wangchuxiao 7d8d314962 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-28 17:52:25 +08:00
wangchuxiao f01a6e82dc fix minio bug 2022-02-28 17:52:13 +08:00
wangchuxiao 67d7ee2751 fix bug 2022-02-28 17:47:53 +08:00
skiffer-git 04f8a7247d replace find with take 2022-02-28 17:28:00 +08:00
skiffer-git 7b6ef76d54 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-28 17:24:21 +08:00
skiffer-git ed65ad842f Replace find with take 2022-02-28 17:20:40 +08:00
Gordon a33fe330f7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-28 17:03:41 +08:00
Gordon b30da3eea4 database judge modify 2022-02-28 17:03:29 +08:00
skiffer-git 05fbbfcf39 grpc-etcd log 2022-02-28 15:28:13 +08:00
wenxu12345 09aec06790 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-25 20:01:11 +08:00
wenxu12345 00a52475de statistics 2022-02-25 20:01:02 +08:00
Gordon 6c03211ac4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-25 19:56:15 +08:00
Gordon ca18958669 test config 2022-02-25 19:56:00 +08:00
wenxu12345 e1f58f07fe 2.0.1 2022-02-25 19:55:58 +08:00
wenxu12345 9d28736849 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-25 19:50:40 +08:00
wenxu12345 739096a9c0 statistics performance 2022-02-25 19:50:18 +08:00
Gordon 2775d9b78a test 2022-02-25 19:49:38 +08:00
Gordon 4f01b0b2ad remove mysql for test 2022-02-25 19:39:42 +08:00
wenxu12345 2427671093 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-25 19:29:54 +08:00
wenxu12345 8c9d1b7dec statistics 2022-02-25 19:29:39 +08:00
Gordon 55c8399084 remove mysql for test 2022-02-25 19:19:23 +08:00
Gordon a1067492b7 server msg id update 2022-02-25 18:35:04 +08:00
Gordon 961beb3e85 Merge remote-tracking branch 'origin/main' 2022-02-25 16:00:15 +08:00
Gordon 23e86f1067 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-25 15:59:42 +08:00
Gordon a1333dcace config update 2022-02-25 15:59:33 +08:00
wenxu12345 82690b5f2f Merge branch 'tuoyun' 2022-02-25 15:36:45 +08:00
wenxu12345 70b97aa856 version: "3" 2022-02-25 15:36:29 +08:00
wenxu12345 05210e2a8b Merge branch 'tuoyun' 2022-02-25 15:31:44 +08:00
wenxu12345 751c278052 version: "2" 2022-02-25 15:31:18 +08:00
wenxu12345 9a1620d51f Merge branch 'tuoyun' 2022-02-25 15:28:19 +08:00
wenxu12345 157cd9a035 2.0.1 2022-02-25 15:27:37 +08:00
wenxu12345 010736839a 2.0.1 2022-02-25 15:26:55 +08:00
Gordon 2c26efb5a9 log remove 2022-02-25 15:02:02 +08:00
Gordon fe9e2aa287 config update 2022-02-25 11:49:52 +08:00
Gordon 2585014ace Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	config/config.yaml
2022-02-24 18:14:25 +08:00
Gordon 0410003ceb api update 2022-02-24 18:08:53 +08:00
wangchuxiao e1a0c2fc48 fix bug 2022-02-24 14:47:21 +08:00
wangchuxiao b0a8c0a35a Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-23 19:55:49 +08:00
wenxu12345 0fca91ca37 config description 2022-02-23 18:22:44 +08:00
wangchuxiao 65ba2d2e27 Merge branch 'main' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-23 17:19:30 +08:00
wangchuxiao 188ca8fc58 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-23 15:46:21 +08:00
wangchuxiao 3b80b74730 test mongo driver 2022-02-23 15:46:02 +08:00
Gordon d9f5f960a5 test 2022-02-23 15:33:22 +08:00
Gordon e31da8bbd0 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-23 15:27:31 +08:00
Gordon 1e602975f3 test 2022-02-23 15:27:23 +08:00
wangchuxiao 541ccda754 test mongo driver 2022-02-23 14:30:21 +08:00
wangchuxiao 1b68363b80 test mongo driver 2022-02-23 12:30:47 +08:00
wangchuxiao fc11b3c463 test mongo driver 2022-02-23 12:30:18 +08:00
wangchuxiao f9f36cd1d6 test mongo driver 2022-02-23 12:27:01 +08:00
wangchuxiao 566c05bcef mongodriver test 2022-02-23 12:00:02 +08:00
wenxu12345 effb21bc6c dbMysqlDatabaseName: openIM_v2 2022-02-23 10:35:16 +08:00
wenxu12345 4c92ee4a8a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-23 10:31:26 +08:00
wenxu12345 8f5b5ab0f9 openIM_v2 2022-02-23 10:31:11 +08:00
wangchuxiao 5dacbfc17e Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-23 10:18:57 +08:00
wangchuxiao 5defc18a64 alter cfg codettl 2022-02-23 10:18:43 +08:00
Gordon d2ba299f42 shell update 2022-02-23 10:10:28 +08:00
Gordon e78e5d6f32 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-23 09:49:11 +08:00
Gordon ebbdcbe5a5 shell update 2022-02-23 09:49:02 +08:00
wangchuxiao 1d0ca5f11e Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-22 19:05:33 +08:00
wangchuxiao d22935703d forget pwd 2022-02-22 19:05:12 +08:00
Gordon d66a567b8f shell update 2022-02-22 19:02:39 +08:00
wenxu12345 34695f2aa3 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-22 18:02:11 +08:00
wenxu12345 dcacd88f11 UserNotificationBegin = 1301 2022-02-22 18:02:00 +08:00
wangchuxiao 2bbf794501 alter cfg 2022-02-22 17:19:56 +08:00
wangchuxiao e3937c5ef2 alter yaml 2022-02-22 17:14:29 +08:00
Gordon a93775bb64 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-22 16:02:46 +08:00
Gordon eddcac2343 send msg time modify 2022-02-22 16:01:32 +08:00
wenxu12345 95c125a5af Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-22 14:23:16 +08:00
wenxu12345 927380741c v2.0.0 2022-02-22 14:23:05 +08:00
Gordon 861dfc43a8 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-22 14:13:14 +08:00
Gordon a1cbf8724f log 2022-02-22 14:13:04 +08:00
wangchuxiao cae88e7946 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-22 12:27:46 +08:00
wangchuxiao 952ad0e162 fix deploy 2022-02-22 12:27:39 +08:00
Gordon b751156b5c redis ttl 2022-02-21 21:19:06 +08:00
wangchuxiao aad27f40cf verrify 2022-02-21 21:07:50 +08:00
wangchuxiao 55d7c6e672 add log 2022-02-21 21:02:37 +08:00
wenxu12345 75590eb765 VerificationCodeForRegisterSuffix 2022-02-21 20:09:26 +08:00
wangchuxiao dfdb952e2b fix reset password api 2022-02-21 19:12:51 +08:00
wangchuxiao c09ebc146b Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-21 18:50:25 +08:00
wangchuxiao 139ef08af3 fix bug 2022-02-21 18:50:11 +08:00
Gordon 2d13a5fd35 msg judge 2022-02-21 18:18:53 +08:00
wangchuxiao a3fb32dfc6 fix bug and add reset pwd api 2022-02-21 16:41:56 +08:00
wangchuxiao 079efe5de6 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-21 16:25:36 +08:00
wangchuxiao 4d28ccebad add reset pwd 2022-02-21 16:24:25 +08:00
wenxu12345 2171acc909 replace mongo driver 2022-02-21 15:23:04 +08:00
wenxu12345 1e05811c13 replace mongo driver 2022-02-21 15:22:40 +08:00
wenxu12345 ec023ec13e replace mongo driver 2022-02-21 15:22:12 +08:00
wenxu12345 996570cc57 replace mongo driver 2022-02-21 15:21:45 +08:00
wenxu12345 7cf712daff replace mongo driver 2022-02-21 15:20:39 +08:00
wenxu12345 9a35af9fb2 replace mongo driver 2022-02-21 15:17:55 +08:00
wenxu12345 ede3b07963 replace mongo driver 2022-02-21 15:14:24 +08:00
wenxu12345 53a4b90d96 replace mongo driver 2022-02-21 15:12:48 +08:00
wenxu12345 bf948789ea replace mongo driver 2022-02-21 15:07:50 +08:00
wenxu12345 db116f39fd Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-21 15:03:49 +08:00
wenxu12345 c962a19eb7 replace mongo driver 2022-02-21 15:03:29 +08:00
wenxu12345 571c83314a Refactoring code 2022-02-21 15:01:06 +08:00
Gordon d906d49930 model modify 2022-02-21 14:11:51 +08:00
Gordon 344bafff45 push modify 2022-02-21 12:20:05 +08:00
wenxu12345 4858390346 Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	config/config.yaml
2022-02-21 11:06:34 +08:00
wenxu12345 f16f0e3069 Refactoring code 2022-02-21 11:06:06 +08:00
Gordon 3ee12221a4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-21 10:10:22 +08:00
Gordon 8915848a52 login modify 2022-02-21 10:10:11 +08:00
wangchuxiao a2cd7c8007 add minio 2022-02-19 18:48:15 +08:00
wangchuxiao 6e9b9341d4 mini cr 2022-02-18 17:06:27 +08:00
Gordon e90d8a87ee config 2022-02-18 15:16:33 +08:00
Gordon 45c43888e7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-18 12:56:53 +08:00
Gordon 68e7dfb1cc conversation add 2022-02-18 12:56:43 +08:00
wangchuxiao f086f33097 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-17 19:41:03 +08:00
wangchuxiao 737ce2c2e7 fix bug 2022-02-17 19:35:17 +08:00
Gordon 3c7c7cde3c close console log 2022-02-17 16:28:59 +08:00
Gordon 3913d9e48e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-17 16:18:47 +08:00
Gordon 84d4645efa close console log 2022-02-17 16:18:37 +08:00
wangchuxiao 8a7442648c Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-17 14:37:54 +08:00
wangchuxiao f1616461f7 add log 2022-02-17 14:36:34 +08:00
Gordon ed2a5af5ed Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	internal/api/third/tencent_cloud_storage_credential.go
2022-02-17 11:14:27 +08:00
Gordon 3b73a4c69a send msg modify 2022-02-17 11:13:51 +08:00
wenxu12345 17954dfdc9 Refactoring code 2022-02-16 19:41:44 +08:00
wenxu12345 3aadf61fde Refactoring code 2022-02-16 18:58:02 +08:00
wenxu12345 5e65e394a6 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-16 18:30:36 +08:00
wenxu12345 8c357ec213 Refactoring code 2022-02-16 18:30:24 +08:00
wangchuxiao a599a334a3 alter cfg 2022-02-16 14:11:47 +08:00
wangchuxiao 36d39669e4 alter deploy 2022-02-16 12:23:08 +08:00
wangchuxiao 028171a91a yaml cfg alter 2022-02-16 11:13:13 +08:00
wangchuxiao 2647e1cdac alter yaml cfg 2022-02-16 11:06:35 +08:00
wangchuxiao 994cebea82 makefile 2022-02-15 18:57:41 +08:00
wangchuxiao a533a3e0ef makefile 2022-02-15 18:43:03 +08:00
wangchuxiao caa915b31d Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-15 18:29:46 +08:00
wangchuxiao 2996d8537d add makefile 2022-02-15 18:29:38 +08:00
wangchuxiao 65be1263b9 make file 2022-02-15 18:28:54 +08:00
wenxu12345 d81ae835aa Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-15 14:34:20 +08:00
wenxu12345 c405cedc41 Refactoring code 2022-02-15 14:34:03 +08:00
Gordon 2a7f366cbf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-15 14:32:40 +08:00
Gordon ea580e4c64 send message 2022-02-15 14:31:55 +08:00
wangchuxiao 445100f32d Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-15 14:11:30 +08:00
wangchuxiao 648a852ba7 conversation opt 2022-02-15 14:11:20 +08:00
Gordon 9f136fb150 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-15 13:16:41 +08:00
Gordon 6d5b38fc8a send message 2022-02-15 13:16:31 +08:00
skiffer-git 2e7fd5fe93 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-14 17:50:38 +08:00
root 626895166a Merge branch 'tuoyun' of https://github.com/OpenIMSDK/Open-IM-Server into tuoyun 2022-02-14 17:01:26 +08:00
skiffer-git 1ca8d2b2db log 2022-02-14 16:59:52 +08:00
Gordon aa57f25b2c tes log 2022-02-14 16:59:26 +08:00
root a321676b99 Merge branch 'tuoyun' of https://github.com/OpenIMSDK/Open-IM-Server into tuoyun 2022-02-14 16:29:30 +08:00
Gordon 5b49b105f6 config file 2022-02-14 16:29:15 +08:00
Gordon d610b19f4e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-14 16:28:40 +08:00
root b9241288c4 config file 2022-02-14 16:23:05 +08:00
Gordon a7470dc284 update 2022-02-14 16:13:27 +08:00
Gordon 154624a767 update 2022-02-14 16:04:35 +08:00
skiffer-git 6f1a5eb79c log 2022-02-14 16:03:55 +08:00
Judgelight a8334a22f8 Merge pull request #131 from OpenIMSDK/cms-dev
Cms dev
2022-02-14 15:18:05 +08:00
wangchuxiao 8cdea2bfeb cms dev 2022-02-14 15:16:59 +08:00
wangchuxiao c413eda330 merge code 2022-02-14 10:57:23 +08:00
wangchuxiao 22bfb6be4b merge code 2022-02-14 10:46:32 +08:00
Gordon 6bfbf37749 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-14 09:44:18 +08:00
wangchuxiao 7797e47561 add 2022-02-14 00:02:15 +08:00
wangchuxiao 52579c5fab add 2022-02-12 17:13:31 +08:00
wenxu12345 a5ed6d897c Refactor code 2022-02-11 20:32:51 +08:00
wenxu12345 439605bafc Refactor code 2022-02-11 20:31:57 +08:00
wenxu12345 9f6fd3ee6a Refactor code 2022-02-11 19:58:42 +08:00
Gordon 1539c0b2f2 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-11 19:56:01 +08:00
wenxu12345 109e8b53a1 Refactor code 2022-02-11 19:49:21 +08:00
Gordon 216697d4b5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-11 19:46:04 +08:00
wenxu12345 77bb88ed59 Refactor code 2022-02-11 19:41:32 +08:00
wenxu12345 7e52477908 Refactor code 2022-02-11 19:35:51 +08:00
wenxu12345 45816fa84f Refactor code 2022-02-11 19:34:18 +08:00
wenxu12345 18babef78b Refactor code 2022-02-11 19:06:48 +08:00
Gordon df8970f59b demo modify 2022-02-11 19:06:29 +08:00
wenxu12345 3103c33dda Refactor code 2022-02-11 18:57:37 +08:00
wenxu12345 a9fa7ee26a Refactor code 2022-02-11 18:52:21 +08:00
wenxu12345 e605560e5c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-11 18:49:27 +08:00
wenxu12345 af330d7f8a Refactor code 2022-02-11 18:49:17 +08:00
Gordon 563d466374 demo modify 2022-02-11 17:51:36 +08:00
Gordon fd59cc6226 demo modify 2022-02-11 17:44:02 +08:00
Gordon 6a8a0f2249 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-11 16:45:28 +08:00
Gordon 8c43b0953b demo modify 2022-02-11 16:36:02 +08:00
Gordon a885d7f003 demo modify 2022-02-11 16:25:28 +08:00
wenxu12345 63af591938 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-10 18:54:32 +08:00
wenxu12345 bf6efc3530 Refactor code 2022-02-10 18:32:02 +08:00
Gordon 609ec24c6a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-10 17:13:54 +08:00
Gordon c99cbec3df db 2022-02-10 17:13:19 +08:00
Gordon 6eb44cb9d8 db 2022-02-10 16:52:18 +08:00
wenxu12345 f67f2a31ee Refactor code 2022-02-10 16:44:58 +08:00
wenxu12345 3d5b8287ce Refactor code 2022-02-10 16:15:57 +08:00
wenxu12345 548a27fe48 Refactor code 2022-02-10 16:14:18 +08:00
wenxu12345 7970a0b3b4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-10 12:28:17 +08:00
wenxu12345 2c67845dd6 Refactor code 2022-02-10 12:28:06 +08:00
Gordon e02ca2f7e3 db 2022-02-10 12:01:00 +08:00
Gordon 84a2197027 db 2022-02-10 11:57:03 +08:00
Gordon 41dd808c9a db 2022-02-10 11:47:44 +08:00
Gordon 6a7a76dce3 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-10 11:45:52 +08:00
Gordon b7a8f6c2a1 db 2022-02-10 11:41:34 +08:00
Gordon f574017b66 db 2022-02-10 11:40:16 +08:00
wenxu12345 b35d5ded77 Refactor code 2022-02-10 09:35:24 +08:00
wenxu12345 a3f712306e Refactor code 2022-02-10 09:31:50 +08:00
wenxu12345 e455b3ff00 Refactor code 2022-02-10 09:17:48 +08:00
wenxu12345 17dd73834f Refactor code 2022-02-09 20:25:25 +08:00
wenxu12345 189020298e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-09 19:38:57 +08:00
wangchuxiao 375b400b1e Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-02-09 19:21:08 +08:00
wangchuxiao 192ac0e013 api 2022-02-09 19:20:46 +08:00
wangchuxiao b80c8013c0 add user req group reqlist api 2022-02-09 19:19:22 +08:00
wenxu12345 0606428cd9 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-09 18:35:58 +08:00
wenxu12345 8cd7b85711 Refactor code 2022-02-09 18:35:46 +08:00
Gordon e91f2b89df Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-09 17:47:25 +08:00
Gordon 93706c94af mysql coding 2022-02-09 17:40:59 +08:00
wangchuxiao 6de61cb214 cms dev 2022-02-09 16:22:58 +08:00
wenxu12345 a21e7adeb5 Refactor code 2022-02-09 15:30:57 +08:00
wenxu12345 11aecf43ba Refactor code 2022-02-09 15:07:31 +08:00
wenxu12345 ee3490a520 Refactor code 2022-02-09 15:03:24 +08:00
wenxu12345 178c1afdea Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-09 13:25:23 +08:00
wenxu12345 3a2cd0276a Refactor code 2022-02-09 13:21:46 +08:00
Gordon a81e5aa6e4 log 2022-02-09 13:05:17 +08:00
Gordon 927cde3777 log 2022-02-09 12:59:20 +08:00
Gordon bed2bfb6db push msg specify receiver 2022-02-09 12:50:36 +08:00
wenxu12345 72f87b449b Refactor code 2022-02-09 12:12:19 +08:00
wenxu12345 02b95b16f9 Refactor code 2022-02-09 09:50:03 +08:00
wenxu12345 3e16519793 Refactor code 2022-02-09 09:44:45 +08:00
wenxu12345 a4b6cb3232 Refactor code 2022-02-09 09:31:17 +08:00
wenxu12345 8883701297 Refactor code 2022-02-09 09:26:58 +08:00
wenxu12345 225c0a9b03 Refactor code 2022-02-09 09:13:07 +08:00
wangchuxiao 43a9bba96f msg cms 2022-02-09 00:45:23 +08:00
wenxu12345 2c670b3b21 Refactor code 2022-02-08 20:25:39 +08:00
wangchuxiao 02aad295f9 group 2022-02-08 20:24:59 +08:00
wenxu12345 163da78bc6 Refactor code 2022-02-08 20:22:07 +08:00
wenxu12345 a549f86624 Refactor code 2022-02-08 19:33:37 +08:00
wenxu12345 27262436d1 Refactor code 2022-02-08 19:28:46 +08:00
wenxu12345 fa2b691dc1 Refactor code 2022-02-08 19:22:15 +08:00
wenxu12345 03a010406f Refactor code 2022-02-08 19:18:07 +08:00
wenxu12345 1e5245efd0 Refactor code 2022-02-08 19:10:06 +08:00
wenxu12345 abd8369dd9 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-08 18:44:38 +08:00
wenxu12345 d0dbffebe1 Refactor code 2022-02-08 18:40:15 +08:00
wenxu12345 c202cee81f Refactor code 2022-02-08 18:34:23 +08:00
Gordon 95153a6609 push msg specify receiver 2022-02-08 18:06:35 +08:00
Gordon e157bc195b push msg specify receiver 2022-02-08 17:34:53 +08:00
Gordon ac09da9efc push msg specify receiver 2022-02-08 17:12:47 +08:00
Gordon dc1ad8fb2d push msg specify receiver 2022-02-08 17:12:02 +08:00
Gordon ba5d178ba0 push msg specify receiver 2022-02-08 16:49:45 +08:00
Gordon 9ceebacfb1 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-08 15:52:26 +08:00
Gordon 2a872eb995 notification 2022-02-08 15:30:48 +08:00
wenxu12345 9077b56df1 Refactor code 2022-02-08 15:19:31 +08:00
wenxu12345 3380cab2c3 Refactor code 2022-02-08 14:50:47 +08:00
wenxu12345 1355fa0636 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-08 14:45:34 +08:00
wenxu12345 70fb869852 Refactor code 2022-02-08 14:45:21 +08:00
Gordon 73da15586b Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-08 14:10:41 +08:00
Gordon b3024a6f7c test 2022-02-08 14:06:49 +08:00
wenxu12345 4c42f5a2f5 Refactor code 2022-02-08 12:22:37 +08:00
wenxu12345 14cf30cd98 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-02-08 11:54:52 +08:00
wangchuxiao e94dbe4965 cms dev 2022-02-07 19:42:09 +08:00
wangchuxiao a7f9faf868 statistics 2022-02-07 08:44:21 +08:00
skiffer-git 6cbdc958cd notification 2022-01-28 11:18:31 +08:00
wangchuxiao fb396d9cf0 add 2022-01-27 18:31:31 +08:00
skiffer-git fca092d392 Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	config/config.yaml
#	internal/rpc/chat/send_msg.go
#	internal/rpc/group/create_group.go
#	pkg/common/config/config.go
#	pkg/proto/sdk_ws/ws.pb.go
#	pkg/proto/sdk_ws/ws.proto
2022-01-27 11:51:34 +08:00
wangchuxiao 0ed393b1a5 group 2022-01-27 01:08:02 +08:00
wangchuxiao b992faa468 group rpc 2022-01-26 18:43:01 +08:00
wangchuxiao 3f911ab437 Merge branch 'cms-dev' of https://github.com/OpenIMSDK/Open-IM-Server into cms-dev 2022-01-26 09:53:54 +08:00
wangchuxiao 84586b675a group 2022-01-26 09:53:49 +08:00
wangchuxiao f952f715c8 group pb 2022-01-26 00:37:58 +08:00
wangchuxiao 79d097c903 group pb 2022-01-26 00:37:28 +08:00
wangchuxiao cdc2428aca cms 2022-01-25 19:18:04 +08:00
wangchuxiao 82c8ace8df cms dev 2022-01-24 18:22:47 +08:00
Gordon 8525dcb376 fix time convert 2022-01-24 16:44:14 +08:00
wangchuxiao 1607853393 cms 2022-01-24 01:40:49 +08:00
skiffer-git 27d402104e Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	cmd/Open-IM-SDK-Core
#	pkg/common/config/config.go
2022-01-22 09:55:54 +08:00
wangchuxiao d58bcd136a pb api 2022-01-21 18:39:57 +08:00
Gordon 1944b24fba push message modify 2022-01-21 09:39:09 +08:00
Gordon 8e10533681 msg test 2022-01-20 19:23:20 +08:00
Gordon 5a9f3f1f5e msg test 2022-01-20 19:20:56 +08:00
Gordon 64f2fb9e73 msg test 2022-01-20 18:38:20 +08:00
Gordon cbed698a1c msg test 2022-01-20 18:36:30 +08:00
Gordon cd7efee49c msg test 2022-01-20 18:28:45 +08:00
Gordon f7ab90724e msg test 2022-01-20 18:04:24 +08:00
Gordon aa7b891150 chat log model update 2022-01-20 17:29:38 +08:00
Gordon 911100923f chat log model update 2022-01-20 17:18:41 +08:00
Gordon 3c64d84980 protocol modify 2022-01-20 11:55:08 +08:00
Gordon e4f87b53b4 protocol modify 2022-01-20 11:53:57 +08:00
Gordon ff779fcc7c protocol modify 2022-01-20 11:42:43 +08:00
Gordon e7c7784fec protocol modify 2022-01-20 11:37:14 +08:00
Gordon 184f0900fb protocol modify 2022-01-20 11:36:43 +08:00
wenxu12345 9ca83b7349 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-20 10:02:41 +08:00
Gordon 8b3df83e7e ws proto 2022-01-20 10:00:02 +08:00
Gordon da24249850 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-19 18:18:57 +08:00
Gordon 04e509fc49 update user 2022-01-19 18:14:53 +08:00
wenxu12345 99a8eaea91 Refactor code 2022-01-19 18:02:57 +08:00
wenxu12345 4c3474a9f7 Refactor code 2022-01-19 17:29:25 +08:00
wenxu12345 14ccbf335d Refactor code 2022-01-19 17:17:51 +08:00
wenxu12345 14841a44ad Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-19 16:11:18 +08:00
Gordon d2b411ecbb nil modify 2022-01-19 14:50:36 +08:00
Gordon 544e60eb6d nil modify 2022-01-19 14:45:23 +08:00
wenxu12345 db80d8f56f Refactor code 2022-01-19 14:12:29 +08:00
wenxu12345 ae09d73257 Refactor code 2022-01-19 14:10:15 +08:00
Gordon ca0f095d6b db charset set utf-8 2022-01-19 14:00:25 +08:00
Gordon 1a0f626a80 model length add 2022-01-19 12:31:28 +08:00
Gordon c23426425e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-19 12:02:55 +08:00
Gordon de52439276 model length add 2022-01-19 11:49:01 +08:00
Gordon 757b296fd0 model length add 2022-01-19 11:47:40 +08:00
wenxu12345 83e842d121 Refactor code 2022-01-19 09:33:31 +08:00
wenxu12345 7f00a3075f Refactor code 2022-01-19 09:32:46 +08:00
wenxu12345 1c362e4871 Refactor code 2022-01-18 21:42:27 +08:00
wenxu12345 0dc5c9dbac Refactor code 2022-01-18 21:17:35 +08:00
wenxu12345 28d9304ec6 Refactor code 2022-01-18 20:27:46 +08:00
wenxu12345 d132e53c06 Refactor code 2022-01-18 20:04:58 +08:00
wenxu12345 e28a8db3b4 Refactor code 2022-01-18 19:46:17 +08:00
Gordon b6380a17ce ws send msg modify 2022-01-18 18:39:27 +08:00
wenxu12345 f4ceef485b Refactor code 2022-01-18 15:58:57 +08:00
wenxu12345 f3507569b5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-18 15:30:37 +08:00
wenxu12345 da5e60a009 Refactor code 2022-01-18 15:26:06 +08:00
Gordon 896a69086b ws send msg modify 2022-01-18 15:09:47 +08:00
Gordon b375877a6d ws send msg modify 2022-01-18 14:06:42 +08:00
Gordon 0ed5f8081a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-18 12:22:06 +08:00
Gordon 7416fa3a4c ws send msg modify 2022-01-18 11:54:48 +08:00
wenxu12345 b90bb10a3f Refactor code 2022-01-18 10:43:30 +08:00
wenxu12345 69643c37c1 Refactor code 2022-01-18 10:41:12 +08:00
wenxu12345 bf208485f8 Refactor code 2022-01-18 09:40:08 +08:00
wenxu12345 d12d571c2b Refactor code 2022-01-18 09:25:41 +08:00
wenxu12345 a456936853 Refactor code 2022-01-17 18:25:35 +08:00
wenxu12345 655f7ff7d0 Refactor code 2022-01-17 18:00:25 +08:00
wenxu12345 5d8e972ac7 Refactor code 2022-01-17 14:10:45 +08:00
wenxu12345 31a6797fc3 Refactor code 2022-01-17 14:07:21 +08:00
wenxu12345 b9b0e9cf43 Refactor code 2022-01-17 14:06:37 +08:00
wenxu12345 7f4eb5624b Refactor code 2022-01-17 14:05:09 +08:00
wenxu12345 766a05236a Refactor code 2022-01-17 10:11:26 +08:00
wenxu12345 92a6c7b89e Refactor code 2022-01-16 18:58:07 +08:00
wenxu12345 a583a31220 Refactor code 2022-01-16 16:31:28 +08:00
wenxu12345 87f14be30c Refactor code 2022-01-16 12:25:41 +08:00
wenxu12345 7e13cc84c8 Refactor code 2022-01-15 18:36:40 +08:00
wenxu12345 a2440a2e80 Refactor code 2022-01-15 15:30:48 +08:00
wenxu12345 17b96dd7c1 Refactor code 2022-01-15 15:25:12 +08:00
wenxu12345 b2c2c1247b Refactor code 2022-01-15 11:14:29 +08:00
wenxu12345 e4b6b18712 Refactor code 2022-01-14 18:33:06 +08:00
wenxu12345 4601633605 Refactor code 2022-01-14 18:29:09 +08:00
wenxu12345 839123408b Refactor code 2022-01-14 18:16:50 +08:00
wenxu12345 2a3cf5f002 Refactor code 2022-01-14 16:48:42 +08:00
wenxu12345 4d172ec4f5 Refactor code 2022-01-14 16:11:23 +08:00
wenxu12345 6f411e96ed Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-14 13:53:43 +08:00
wenxu12345 7f7664eb4f Refactor code 2022-01-14 13:52:09 +08:00
wenxu12345 3d994cc2cf Refactor code 2022-01-14 13:44:46 +08:00
Gordon 6bc69d5a75 proto json tag modify 2022-01-14 09:59:25 +08:00
Gordon 0db2c271a0 proto json tag modify 2022-01-14 09:51:43 +08:00
Gordon 02b09c58a1 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-01-14 09:47:46 +08:00
Gordon b0a8ad1ac1 tidy 2022-01-13 18:33:11 +08:00
wenxu12345 3e6302e44a Refactor code 2022-01-13 11:20:21 +08:00
wenxu12345 1f493c427a Refactor code 2022-01-13 11:16:55 +08:00
wenxu12345 89eb39ca3e Refactor code 2022-01-13 11:10:29 +08:00
wenxu12345 b495761283 Refactor code 2022-01-06 20:34:00 +08:00
wenxu12345 29e92015d5 Refactor code 2022-01-06 20:33:09 +08:00
wenxu12345 c71f2f7fae Refactor code 2022-01-06 20:21:13 +08:00
wenxu12345 548c92dc0d Refactor code 2022-01-06 20:17:22 +08:00
wenxu12345 59a5f675f6 Refactor code 2022-01-06 20:16:14 +08:00
wenxu12345 d80a669515 Refactor code 2022-01-06 20:07:40 +08:00
wenxu12345 bc0c5d4fcb Refactor code 2022-01-06 19:59:13 +08:00
wenxu12345 1a69fdf1e0 Refactor code 2022-01-06 18:30:58 +08:00
wenxu12345 df6643f1c5 Refactor code 2022-01-06 18:26:50 +08:00
wenxu12345 03fc008dfc Refactor code 2022-01-06 18:23:29 +08:00
wenxu12345 fa330c766f Refactor code 2022-01-06 18:22:09 +08:00
wenxu12345 cb80742eaa Refactor code 2022-01-06 18:16:36 +08:00
wenxu12345 0ae46455af Refactor code 2022-01-06 18:16:08 +08:00
wenxu12345 d6133c325a Refactor code 2022-01-06 18:14:54 +08:00
wenxu12345 edfb89a8d9 Refactor code 2022-01-06 18:09:48 +08:00
wenxu12345 aafbee2a28 Refactor code 2022-01-06 18:08:54 +08:00
wenxu12345 5c9dc62015 Refactor code 2022-01-06 18:04:30 +08:00
wenxu12345 5fef41e132 Refactor code 2022-01-06 18:00:15 +08:00
wenxu12345 a677d4da5f Refactor code 2022-01-06 17:55:37 +08:00
wenxu12345 136e0cde06 Refactor code 2022-01-06 15:24:57 +08:00
wenxu12345 06af2b6aa3 Refactor code 2022-01-06 15:19:24 +08:00
wenxu12345 29e2a00109 Refactor code 2022-01-06 15:18:23 +08:00
wenxu12345 d5b5929e9b Refactor code 2022-01-06 14:17:25 +08:00
wenxu12345 fea89ad451 Refactor code 2022-01-04 13:38:38 +08:00
wenxu12345 3d6f1e42d2 Refactor code 2022-01-04 13:19:14 +08:00
wenxu12345 1ad80e1870 Refactor code 2022-01-04 13:01:57 +08:00
wenxu12345 ea0b8df5d4 Refactor code 2022-01-04 13:01:07 +08:00
wenxu12345 0e39aac5cd Refactor code 2022-01-04 12:58:11 +08:00
wenxu12345 7e88621aa1 Refactor code 2022-01-04 12:56:10 +08:00
wenxu12345 9b76407193 Refactor code 2021-12-31 11:18:32 +08:00
wenxu12345 b6bd2687d2 Refactor code 2021-12-31 11:11:41 +08:00
wenxu12345 82c0f8a863 Refactor code 2021-12-31 11:08:16 +08:00
wenxu12345 9782802bd8 Refactor code 2021-12-31 11:01:48 +08:00
wenxu12345 87659b56a4 Refactor code 2021-12-31 10:57:45 +08:00
wenxu12345 cd62d7f0d9 Refactor code 2021-12-31 10:49:37 +08:00
wenxu12345 1290bc8cc9 Refactor code 2021-12-31 10:45:11 +08:00
wenxu12345 fe285ecd6b Refactor code 2021-12-31 10:41:06 +08:00
wenxu12345 da7d187612 Refactor code 2021-12-31 10:40:32 +08:00
wenxu12345 9b2fde6ea2 Refactor code 2021-12-31 09:43:22 +08:00
wenxu12345 da1a563a3c Refactor code 2021-12-31 09:40:08 +08:00
wenxu12345 9bee5c79c8 Refactor code 2021-12-31 09:25:11 +08:00
wenxu12345 aab6ad96eb Refactor code 2021-12-31 09:04:04 +08:00
wenxu12345 c8d803b559 Refactor code 2021-12-31 08:49:05 +08:00
wenxu12345 ab5faec68c Refactor code 2021-12-30 21:29:10 +08:00
wenxu12345 dcba4fef48 Refactor code 2021-12-30 21:28:38 +08:00
wenxu12345 a654073c71 Refactor code 2021-12-30 21:09:37 +08:00
wenxu12345 eb417c7e22 Refactor code 2021-12-30 21:03:52 +08:00
wenxu12345 0fce4c6177 Refactor code 2021-12-30 20:51:33 +08:00
wenxu12345 e964ff0b70 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 20:42:19 +08:00
wenxu12345 a5765fc25a Refactor code 2021-12-30 20:39:49 +08:00
wenxu12345 18600bcd11 Refactor code 2021-12-30 20:09:45 +08:00
Gordon 7a3bb59d3e add null value handle 2021-12-30 19:12:50 +08:00
Gordon 29e1535c64 Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	cmd/open_im_api/main.go
2021-12-30 18:38:37 +08:00
wenxu12345 7b41ce1f24 Refactor code 2021-12-30 18:33:01 +08:00
wenxu12345 1e6a170c3c Refactor code 2021-12-30 18:31:13 +08:00
wenxu12345 887028a1b4 Refactor code 2021-12-30 18:30:03 +08:00
wenxu12345 816ceab057 Refactor code 2021-12-30 18:28:37 +08:00
wenxu12345 324152e363 Refactor code 2021-12-30 18:22:56 +08:00
wenxu12345 1b11cd571e Refactor code 2021-12-30 18:19:54 +08:00
Gordon 627419aa5f add null value handle 2021-12-30 17:56:12 +08:00
Gordon aa99e710d1 Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	cmd/open_im_api/main.go
#	internal/api/group/group.go
2021-12-30 17:55:32 +08:00
wenxu12345 f3a9857747 Refactor code 2021-12-30 17:54:11 +08:00
Gordon fdf1c0448b add null value handle 2021-12-30 17:48:20 +08:00
wenxu12345 a09b39dd69 Refactor code 2021-12-30 17:48:19 +08:00
Gordon e4989d8b9f add null value handle 2021-12-30 17:46:29 +08:00
wenxu12345 b135de80c0 Refactor code 2021-12-30 17:46:11 +08:00
wenxu12345 79a39b39d9 Refactor code 2021-12-30 17:44:06 +08:00
wenxu12345 0c02afa54e Refactor code 2021-12-30 17:34:54 +08:00
wenxu12345 1e9ef321f0 Refactor code 2021-12-30 17:27:11 +08:00
Gordon 7301bc30b1 add null value handle 2021-12-30 16:53:06 +08:00
wenxu12345 ccecd8f4f0 Refactor code 2021-12-30 16:30:13 +08:00
wenxu12345 93e669d7d3 Refactor code 2021-12-30 16:27:57 +08:00
wenxu12345 a0f28c07f2 Refactor code 2021-12-30 16:24:37 +08:00
wenxu12345 bd14e5019f Refactor code 2021-12-30 16:19:06 +08:00
wenxu12345 6d0f454e6a Refactor code 2021-12-30 14:17:29 +08:00
wenxu12345 a031311ab5 Refactor code 2021-12-30 14:03:55 +08:00
wenxu12345 492915567b Refactor code 2021-12-30 13:53:05 +08:00
wenxu12345 8b1a7def38 Refactor code 2021-12-30 13:49:39 +08:00
wenxu12345 2f62339f0c Refactor code 2021-12-30 13:39:36 +08:00
wenxu12345 288f25c827 Refactor code 2021-12-30 13:29:32 +08:00
wenxu12345 1392a8ecf1 Refactor code 2021-12-30 13:26:07 +08:00
wenxu12345 1eee8f439b Refactor code 2021-12-30 12:30:30 +08:00
wenxu12345 0db7aca1cd Refactor code 2021-12-30 12:29:27 +08:00
wenxu12345 89d69a8fb6 Refactor code 2021-12-30 12:27:26 +08:00
wenxu12345 7574d06718 Refactor code 2021-12-30 12:07:13 +08:00
wenxu12345 4336a1a13e Refactor code 2021-12-30 12:05:10 +08:00
wenxu12345 9409d6e05e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 11:53:59 +08:00
wenxu12345 0971445289 Refactor code 2021-12-30 11:53:50 +08:00
Gordon 32fe763c0c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 11:50:31 +08:00
Gordon 6790d2be44 err log 2021-12-30 11:50:20 +08:00
wenxu12345 f579c6b56d Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 11:47:14 +08:00
wenxu12345 81aaa95170 Refactor code 2021-12-30 11:42:10 +08:00
Gordon e0c91f7fda Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 11:40:30 +08:00
Gordon bd0596dd86 err log 2021-12-30 11:35:48 +08:00
wenxu12345 cc5125d51d Refactor code 2021-12-30 11:28:24 +08:00
wenxu12345 e90be1bb88 Refactor code 2021-12-30 11:13:19 +08:00
wenxu12345 b32567681f Refactor code 2021-12-30 11:07:12 +08:00
wenxu12345 9f5897e06c Refactor code 2021-12-30 11:04:53 +08:00
wenxu12345 e8ffcb0630 Refactor code 2021-12-30 10:59:25 +08:00
wenxu12345 88aaa38676 Refactor code 2021-12-30 10:56:17 +08:00
wenxu12345 6692867db5 Refactor code 2021-12-30 10:49:09 +08:00
wenxu12345 42c898d5aa Refactor code 2021-12-30 10:36:37 +08:00
wenxu12345 2936f886a9 Refactor code 2021-12-30 10:35:09 +08:00
Gordon f582967711 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 10:35:06 +08:00
Gordon 68985e9eda log add 2021-12-30 10:30:47 +08:00
wenxu12345 7c3e429f22 Refactor code 2021-12-30 10:20:16 +08:00
wenxu12345 cb79b1aea5 Refactor code 2021-12-30 10:18:49 +08:00
wenxu12345 b687eb09b4 Refactor code 2021-12-30 10:14:30 +08:00
wenxu12345 83874ad466 Refactor code 2021-12-30 09:46:53 +08:00
wenxu12345 c0172b0a49 Refactor code 2021-12-30 09:39:37 +08:00
wenxu12345 f59208b9cf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 09:38:17 +08:00
wenxu12345 6d9ee74360 Refactor code 2021-12-30 09:38:07 +08:00
wenxu12345 5ae6e98572 Refactor code 2021-12-30 09:34:19 +08:00
wenxu12345 3f639e2ffe Refactor code 2021-12-30 09:33:51 +08:00
Gordon 43a690c8cf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-30 09:30:59 +08:00
wenxu12345 2725a1cd8d Refactor code 2021-12-30 09:30:46 +08:00
wenxu12345 ac3159193f Refactor code 2021-12-30 09:26:40 +08:00
wenxu12345 f2c0a3994a Refactor code 2021-12-30 09:23:18 +08:00
wenxu12345 d7dbe986f1 Refactor code 2021-12-30 09:17:49 +08:00
wenxu12345 f93090596a Refactor code 2021-12-30 09:11:38 +08:00
wenxu12345 8b7e62e819 Refactor code 2021-12-30 09:10:31 +08:00
wenxu12345 28ef79f371 Refactor code 2021-12-29 22:06:27 +08:00
wenxu12345 e39312828c Refactor code 2021-12-29 22:00:18 +08:00
Gordon 3bbf9d2e0f nil return modify 2021-12-29 21:55:07 +08:00
wenxu12345 be4ba6cc69 Refactor code 2021-12-29 21:50:11 +08:00
wenxu12345 51126ca941 Refactor code 2021-12-29 21:47:56 +08:00
wenxu12345 faae2d7a1e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 21:36:54 +08:00
wenxu12345 ca92bc899b Refactor code 2021-12-29 21:26:56 +08:00
Gordon ace5fd61bd nil return modify 2021-12-29 19:37:52 +08:00
Gordon 31fabb4624 nil return modify 2021-12-29 19:35:04 +08:00
Gordon b4935fef76 nil return modify 2021-12-29 19:33:54 +08:00
Gordon d1fba4c125 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 19:25:37 +08:00
Gordon de8ac68466 nil return modify 2021-12-29 19:17:43 +08:00
Gordon 0392eab129 nil return modify 2021-12-29 19:12:33 +08:00
wenxu12345 479ce592fa Refactor code 2021-12-29 18:36:56 +08:00
wenxu12345 9eaa180c10 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 18:32:26 +08:00
wenxu12345 4b38f0bc6b Refactor code 2021-12-29 18:26:49 +08:00
Gordon 40ed7258d4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 18:23:14 +08:00
wenxu12345 b0c05fd80d Refactor code 2021-12-29 18:12:23 +08:00
wenxu12345 1537330b61 Refactor code 2021-12-29 18:10:19 +08:00
Gordon abd91260ab nil return modify 2021-12-29 18:09:55 +08:00
wenxu12345 5dcb321a6f Refactor code 2021-12-29 18:04:24 +08:00
wenxu12345 38cc72a3f9 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 17:55:51 +08:00
Gordon 6f03c470ae nil return modify 2021-12-29 17:53:08 +08:00
wenxu12345 4cb02bd3a5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 17:52:11 +08:00
wenxu12345 9f55418bfb Refactor code 2021-12-29 17:52:01 +08:00
Gordon 8faf1140fb nil return modify 2021-12-29 17:51:06 +08:00
wenxu12345 6e14375b86 Refactor code 2021-12-29 17:46:27 +08:00
wenxu12345 7138d7ac59 Refactor code 2021-12-29 17:43:49 +08:00
wenxu12345 a02b810412 Refactor code 2021-12-29 17:42:22 +08:00
Gordon bd5480b264 nil return modify 2021-12-29 17:39:04 +08:00
Gordon 7c04bcae26 nil return modify 2021-12-29 17:34:44 +08:00
Gordon efa61dcb39 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 17:31:30 +08:00
wenxu12345 6c137d9098 Refactor code 2021-12-29 17:26:06 +08:00
wenxu12345 3ca92c7a03 Refactor code 2021-12-29 17:13:45 +08:00
wenxu12345 bb2d5e570a Refactor code 2021-12-29 17:06:40 +08:00
Gordon 1ce2a86f37 nil return modify 2021-12-29 17:05:52 +08:00
wenxu12345 c6ee7c5082 Refactor code 2021-12-29 16:55:45 +08:00
wenxu12345 a52d674a14 Refactor code 2021-12-29 16:52:12 +08:00
wenxu12345 69b1ee2ec7 Refactor code 2021-12-29 16:46:33 +08:00
wenxu12345 95a771c2fb Refactor code 2021-12-29 16:44:24 +08:00
wenxu12345 cf59f57ab8 Refactor code 2021-12-29 16:39:52 +08:00
wenxu12345 8cd38693dd Refactor code 2021-12-29 16:31:33 +08:00
wenxu12345 ef67aa9e48 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 16:18:17 +08:00
wenxu12345 4623b5d5db Refactor code 2021-12-29 16:17:55 +08:00
Gordon 65456d331b nil return modify 2021-12-29 16:04:08 +08:00
Gordon 20f51092ad nil return modify 2021-12-29 15:53:56 +08:00
Gordon 0b0173f155 nil return modify 2021-12-29 15:52:19 +08:00
wenxu12345 4e4bab2bf0 Refactor code 2021-12-29 15:50:50 +08:00
Gordon 679c907b78 nil return modify 2021-12-29 15:19:49 +08:00
Gordon cd6bb1b98f Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 15:08:57 +08:00
wenxu12345 667ceb2115 Refactor code 2021-12-29 15:08:27 +08:00
Gordon 03f491ab5a nil return modify 2021-12-29 15:07:36 +08:00
wenxu12345 fb7c4114c1 Refactor code 2021-12-29 14:57:36 +08:00
wenxu12345 669ea69357 Refactor code 2021-12-29 14:39:54 +08:00
wenxu12345 5b32e0db6f Refactor code 2021-12-29 14:36:13 +08:00
wenxu12345 20aa2bdc6e Refactor code 2021-12-29 14:25:39 +08:00
wenxu12345 c7b7847a82 Refactor code 2021-12-29 14:14:08 +08:00
wenxu12345 d99f3e1522 Refactor code 2021-12-29 14:08:46 +08:00
wenxu12345 903b53033d Refactor code 2021-12-29 14:06:25 +08:00
wenxu12345 f2fa08ea82 Refactor code 2021-12-29 13:56:50 +08:00
wenxu12345 c049cde8cf Refactor code 2021-12-29 13:49:39 +08:00
wenxu12345 d58dc29550 Refactor code 2021-12-29 13:45:22 +08:00
wenxu12345 e75e36e999 Refactor code 2021-12-29 13:40:26 +08:00
wenxu12345 7903dc7c2e Refactor code 2021-12-29 13:34:13 +08:00
wenxu12345 a8e13d86e2 Refactor code 2021-12-29 13:30:50 +08:00
wenxu12345 8e173d8273 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 12:32:45 +08:00
wenxu12345 7b67dc03f7 Refactor code 2021-12-29 12:29:39 +08:00
Gordon c4fca3b23d nil return modify 2021-12-29 12:22:10 +08:00
wenxu12345 c42e70686d Refactor code 2021-12-29 12:13:00 +08:00
wenxu12345 df861b59c1 Refactor code 2021-12-29 12:06:26 +08:00
wenxu12345 447ccdf042 Refactor code 2021-12-29 12:02:55 +08:00
wenxu12345 db37d0197a Refactor code 2021-12-29 11:57:28 +08:00
wenxu12345 e6f21d166a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 11:52:58 +08:00
wenxu12345 2e0923a26a Refactor code 2021-12-29 11:52:51 +08:00
Gordon bd1af2223d Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 11:40:06 +08:00
wenxu12345 ec395acae0 Refactor code 2021-12-29 11:37:52 +08:00
wenxu12345 5ff69b86db Refactor code 2021-12-29 11:36:45 +08:00
Gordon ce6cd8070f conversation update 2021-12-29 11:32:20 +08:00
wenxu12345 ddf985b445 Refactor code 2021-12-29 11:31:53 +08:00
Gordon 6a37072b9a conversation update 2021-12-29 11:31:51 +08:00
wenxu12345 d2ea06ef4a Refactor code 2021-12-29 11:29:51 +08:00
wenxu12345 943f58f2c0 Refactor code 2021-12-29 11:19:55 +08:00
wenxu12345 0891e2d432 Refactor code 2021-12-29 11:16:23 +08:00
wenxu12345 740dd0e0a6 Refactor code 2021-12-29 11:15:20 +08:00
wenxu12345 2fcd21ae94 Refactor code 2021-12-29 11:02:55 +08:00
wenxu12345 c312f079fb Refactor code 2021-12-29 11:01:57 +08:00
wenxu12345 a480dfe59e Refactor code 2021-12-29 11:01:14 +08:00
wenxu12345 453eddc089 Refactor code 2021-12-29 10:57:48 +08:00
wenxu12345 51cb558317 Refactor code 2021-12-29 10:55:28 +08:00
wenxu12345 f0c5b1e544 Refactor code 2021-12-29 10:52:52 +08:00
wenxu12345 348ce56776 Refactor code 2021-12-29 10:41:05 +08:00
wenxu12345 d8ab13e249 Refactor code 2021-12-29 10:39:47 +08:00
wenxu12345 376f61e213 Refactor code 2021-12-29 10:32:26 +08:00
wenxu12345 b30cb5254e Refactor code 2021-12-29 10:18:10 +08:00
wenxu12345 3737e889ea Refactor code 2021-12-29 09:36:48 +08:00
wenxu12345 ec144da8ce Refactor code 2021-12-29 09:32:35 +08:00
wenxu12345 e61b37b6bf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-29 09:08:33 +08:00
wenxu12345 47a3c3c253 tidy code 2021-12-28 21:17:41 +08:00
Gordon 23c5f4040e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 21:03:31 +08:00
wenxu12345 39ceb20332 tidy code 2021-12-28 21:03:03 +08:00
Gordon e80c5c89e0 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 20:44:58 +08:00
Gordon 8cfc5925da management modify 2021-12-28 20:44:19 +08:00
wenxu12345 da73347231 tidy code 2021-12-28 20:28:01 +08:00
wenxu12345 e26c3d9462 tidy code 2021-12-28 20:21:09 +08:00
wenxu12345 f4c3c86dd1 tidy code 2021-12-28 20:03:20 +08:00
wenxu12345 5c509ee85a tidy code 2021-12-28 19:28:33 +08:00
wenxu12345 12ebf232d5 tidy code 2021-12-28 18:37:16 +08:00
wenxu12345 05ee76b0a9 tidy code 2021-12-28 18:33:36 +08:00
wenxu12345 12df670681 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 18:23:03 +08:00
wenxu12345 6d589a1204 tidy code 2021-12-28 18:18:35 +08:00
Gordon 1e50556f64 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 18:09:07 +08:00
Gordon 7ee703f077 token modify 2021-12-28 18:05:25 +08:00
wenxu12345 141936e609 tidy code 2021-12-28 18:03:51 +08:00
wenxu12345 188a90f97d tidy code 2021-12-28 18:01:40 +08:00
wenxu12345 ec95f0a7af tidy code 2021-12-28 17:49:52 +08:00
wenxu12345 848510d4ca tidy code 2021-12-28 17:48:21 +08:00
wenxu12345 16e276d08e tidy code 2021-12-28 17:45:57 +08:00
wenxu12345 62d0a7e6ff tidy code 2021-12-28 17:15:51 +08:00
wenxu12345 eeee9a54d7 tidy code 2021-12-28 17:13:31 +08:00
Gordon 3ec1d1a965 token modify 2021-12-28 17:12:07 +08:00
wenxu12345 2b60430c55 tidy code 2021-12-28 17:03:37 +08:00
wenxu12345 dbd3ed49ed tidy code 2021-12-28 16:59:17 +08:00
wenxu12345 eb640157f2 tidy code 2021-12-28 16:58:01 +08:00
wenxu12345 166ec71a28 tidy code 2021-12-28 16:50:05 +08:00
wenxu12345 8e4f3b4f06 tidy code 2021-12-28 16:48:20 +08:00
wenxu12345 f43e1a1018 tidy code 2021-12-28 16:36:02 +08:00
wenxu12345 508ccf4f9c tidy code 2021-12-28 16:31:38 +08:00
wenxu12345 6f92fa0069 tidy code 2021-12-28 16:30:00 +08:00
wenxu12345 2293253d52 tidy code 2021-12-28 16:26:59 +08:00
wenxu12345 1cb7b6a67e tidy code 2021-12-28 16:24:45 +08:00
wenxu12345 817a5e4b64 tidy code 2021-12-28 16:23:14 +08:00
wenxu12345 8286c10406 tidy code 2021-12-28 16:06:06 +08:00
wenxu12345 12c2d18325 tidy code 2021-12-28 16:03:47 +08:00
wenxu12345 28cfc2a9c1 tidy code 2021-12-28 16:01:57 +08:00
wenxu12345 1e3cad4b20 tidy code 2021-12-28 15:47:20 +08:00
wenxu12345 b6944c4308 tidy code 2021-12-28 15:33:47 +08:00
wenxu12345 38542f9888 tidy code 2021-12-28 14:23:14 +08:00
wenxu12345 4223b2d0f0 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 14:10:49 +08:00
wenxu12345 c0db257e9b tidy code 2021-12-28 14:07:06 +08:00
wenxu12345 6b1f4e1686 tidy code 2021-12-28 11:57:12 +08:00
Gordon 6e8080b87d Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-28 11:30:47 +08:00
Gordon 292a8620e0 remove invalid token 2021-12-28 10:59:01 +08:00
wenxu12345 f0f1c54244 tidy code 2021-12-27 21:08:42 +08:00
wenxu12345 30024c9814 tidy code 2021-12-27 18:22:32 +08:00
wenxu12345 3446442eca Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-27 16:57:36 +08:00
wenxu12345 e439ef4ddd tidy code 2021-12-27 16:48:05 +08:00
Gordon 774e348f95 send msg file modify 2021-12-27 11:49:01 +08:00
wenxu12345 3d4e0a0479 tidy code 2021-12-26 18:47:11 +08:00
wenxu12345 30b9ca7f37 notification 2021-12-24 16:02:21 +08:00
wenxu12345 04e064e86e notification 2021-12-24 15:39:26 +08:00
wenxu12345 6a88d64a90 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-24 15:02:58 +08:00
wenxu12345 e64bc40ca9 notification 2021-12-24 15:02:47 +08:00
Gordon 33ae9dae0a send msg file modify 2021-12-23 19:50:04 +08:00
Gordon ba249d294e send msg file modify 2021-12-23 19:37:41 +08:00
wenxu12345 d40e1e47fd notification 2021-12-23 18:29:39 +08:00
Gordon 1be993801f send msg file modify 2021-12-23 17:48:06 +08:00
Gordon b76aa03d3a Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	pkg/proto/sdk_ws/ws.pb.go
2021-12-23 17:39:31 +08:00
Gordon 743715fa73 send msg file modify 2021-12-23 17:35:07 +08:00
Gordon 5f09d6a26f send msg file modify 2021-12-23 17:34:32 +08:00
wenxu12345 27fd4f444b notification 2021-12-23 17:22:49 +08:00
Gordon 2d56dacd0e send msg file modify 2021-12-23 17:22:26 +08:00
Gordon 333453df79 send msg file modify 2021-12-23 17:19:57 +08:00
Gordon cfddc75ccb config file modify 2021-12-23 14:28:44 +08:00
Gordon 3a01ee9973 config file modify 2021-12-23 10:04:21 +08:00
wenxu12345 1efe753a04 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-22 15:25:00 +08:00
wenxu12345 a8e80a44e6 notification 2021-12-22 15:24:49 +08:00
Gordon cf94122406 proto file 2021-12-22 11:20:10 +08:00
wenxu12345 a5518eb492 OpUserID 2021-12-22 11:14:57 +08:00
Gordon 6bdfc570a8 proto file 2021-12-22 11:14:03 +08:00
Gordon 26640b3b07 proto file 2021-12-22 11:13:51 +08:00
Gordon 777805fc1a proto file 2021-12-22 11:10:13 +08:00
Gordon 57e08e282c proto file 2021-12-22 10:50:03 +08:00
Gordon fb5ea3be84 proto file 2021-12-22 10:47:07 +08:00
Gordon 05c15a104f Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts:
#	pkg/proto/sdk_ws/ws.proto
2021-12-22 10:10:51 +08:00
Gordon 5f18723e2c proto file 2021-12-22 09:37:19 +08:00
Gordon 7db98e55c5 proto file 2021-12-22 09:31:33 +08:00
wenxu12345 75e1e2e678 notification 2021-12-21 21:40:50 +08:00
wenxu12345 2876e77a08 UserInfo FriendInfo GroupInfo 2021-12-20 17:27:05 +08:00
wenxu12345 3ba881f641 pb: open_im_sdk.OfflinePushInfo 2021-12-20 16:29:24 +08:00
skiffer-git 264451d923 notification 2021-12-19 21:03:05 +08:00
Gordon e63b3ab0e3 add management interface 2021-12-17 16:43:41 +08:00
Gordon 8987005e60 add management interface 2021-12-17 16:23:44 +08:00
Gordon d6614decd1 rpc restore 2021-12-17 15:55:43 +08:00
Gordon 42726cf2b6 add check user is registered 2021-12-17 15:10:24 +08:00
Gordon ff1ac3387b add check user is registered 2021-12-17 15:07:17 +08:00
Gordon f933abe48e add check user is registered 2021-12-17 14:28:43 +08:00
Gordon be94674507 pb file 2021-12-17 12:52:12 +08:00
Gordon c8b1e5bafc pb file 2021-12-17 12:15:33 +08:00
Gordon 7403619cbc err handle 2021-12-17 11:14:43 +08:00
itltf512116 7a6df3abd3 Tuoyun 新增单容器单进程的部署方式 (#103)
* feat 新增deploy:单容器单进程模型部署

* feat 新增openim内部各组件的host名称配置;
fix 独立容器部署镜像文档;

* feat 新增注释说明
2021-12-17 10:49:01 +08:00
skiffer-git b84dbbc3b8 notification 2021-12-14 15:11:35 +08:00
skiffer-git 7adde6a0a9 notification 2021-12-14 14:53:27 +08:00
Gordon a328080ba4 sync message 2021-12-10 18:07:09 +08:00
Gordon 525889e366 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-10 17:58:59 +08:00
Gordon 88d181f9fe sync message 2021-12-10 17:51:19 +08:00
Gordon 2dc773ebe6 sync message 2021-12-10 17:50:29 +08:00
wenxu12345 043ce653a9 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-10 17:30:25 +08:00
wenxu12345 8b4da90497 pb 2021-12-10 17:30:11 +08:00
Gordon 59fffc6fbe server version update 2021-12-10 17:18:20 +08:00
Gordon 8b81d60dce Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-10 17:06:29 +08:00
Gordon 0ed9aa5372 sender message sync 2021-12-10 17:00:24 +08:00
wenxu12345 2ace964573 pb: open_im_sdk.OfflinePushInfo 2021-12-10 11:07:44 +08:00
wenxu12345 a8201aaa58 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-10 11:06:32 +08:00
Gordon 776fa2f4f6 pb change 2021-12-10 11:04:05 +08:00
Gordon eabef540cf pb change 2021-12-10 10:51:20 +08:00
Gordon d6ec8f4930 pb change 2021-12-10 10:49:49 +08:00
Gordon aaf834a33b pb change 2021-12-10 10:35:21 +08:00
Gordon 043f9bde59 msg add notification 2021-12-09 21:22:54 +08:00
Gordon 170310e23c push add ios push 2021-12-09 18:15:40 +08:00
Gordon 31a558cfea push add ios push 2021-12-09 18:10:39 +08:00
Gordon adc4fec19b push add ios push 2021-12-09 17:54:58 +08:00
Gordon 74beec2b85 push add ios push 2021-12-09 17:52:05 +08:00
Gordon d7cd8ba780 push add ios push 2021-12-09 17:42:02 +08:00
Gordon a69ebf4299 push add ios push 2021-12-09 17:41:06 +08:00
Gordon 8085c62774 push add ios push 2021-12-09 17:14:24 +08:00
Gordon 3e51e781a6 push add ios push 2021-12-09 16:05:20 +08:00
Gordon fa028fdafd push add ios push 2021-12-09 15:43:36 +08:00
Gordon d2ce4192cc rpc protocol update 2021-12-08 18:30:23 +08:00
Gordon 822f689c48 rpc protocol update 2021-12-08 18:17:57 +08:00
Gordon c6ade8d9bc rpc protocol update 2021-12-08 18:15:14 +08:00
Gordon 0e99fb27b5 rpc protocol update 2021-12-08 18:09:34 +08:00
Gordon 058a191e61 rpc protocol update 2021-12-08 18:08:48 +08:00
Gordon ebd867a6d5 conversation update 2021-12-08 17:44:16 +08:00
Gordon 687933a63e conversation update 2021-12-08 17:23:26 +08:00
wenxu12345 1f40c87dd9 demo log 2021-12-08 14:56:09 +08:00
wenxu12345 93ffbe2a79 demo log 2021-12-08 14:49:47 +08:00
Gordon a090e602b3 conversation update 2021-12-08 12:30:17 +08:00
Gordon c9a48081fd conversation update 2021-12-08 12:24:55 +08:00
Gordon 5b026e13f6 conversation update 2021-12-08 10:42:04 +08:00
Gordon f1aab5ad3b Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-07 21:22:00 +08:00
wenxu12345 d7028f22e2 fix bug 2021-12-07 16:15:21 +08:00
Gordon 570c0cb9a1 remove log 2021-12-07 16:13:11 +08:00
wenxu12345 053792e89d ReceiveMessageOpt debug log 2021-12-07 16:12:55 +08:00
wenxu12345 31212d4f4b ReceiveMessageOpt debug log 2021-12-07 16:10:49 +08:00
wenxu12345 19489afefc ReceiveMessageOpt debug log 2021-12-07 16:07:56 +08:00
wenxu12345 5dd494d9a2 ReceiveMessageOpt debug log 2021-12-07 16:01:48 +08:00
wenxu12345 2adbf9f686 ReceiveMessageOpt debug log 2021-12-07 15:56:33 +08:00
wenxu12345 9dbad9ce53 ReceiveMessageOpt 2021-12-07 15:44:12 +08:00
wenxu12345 52498bf05e ReceiveMessageOpt 2021-12-07 14:39:56 +08:00
wenxu12345 e4e5608c8c ReceiveMessageOpt 2021-12-07 14:34:41 +08:00
wenxu12345 d629874468 ReceiveMessageOpt 2021-12-07 14:28:07 +08:00
Gordon 7da98935b9 redis add func 2021-12-07 11:46:24 +08:00
Gordon d50a0abd2a send message by message receive opt 2021-12-07 10:22:49 +08:00
Gordon 33b9685985 send message by message receive opt 2021-12-06 20:03:59 +08:00
Gordon cd14f3e649 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-06 16:16:56 +08:00
Gordon 70eaa7d968 redis add message receive opt 2021-12-06 16:06:19 +08:00
wenxu12345 f1b51f9c97 fix bug: QuitGroup Find ->Scan 2021-12-03 11:50:30 +08:00
wenxu12345 65398fb147 callback config 2021-12-02 21:35:01 +08:00
wenxu12345 a8575b4fc7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-02 20:47:49 +08:00
wenxu12345 67ede12fd8 online state 2021-12-02 20:42:17 +08:00
Gordon e6b5819099 redis prefix modify 2021-12-02 14:10:47 +08:00
wenxu12345 5cd1af5b48 script 2021-12-02 11:47:30 +08:00
wenxu12345 6d1c70b8d3 get online state by secret 2021-12-02 11:27:06 +08:00
wenxu12345 cda28cb2ee Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-01 20:05:56 +08:00
wenxu12345 aac7a0f5af script 2021-12-01 20:03:06 +08:00
Gordon 0501cbcf4c demo merge into project 2021-12-01 14:52:55 +08:00
Gordon f08941c0bd demo merge into project 2021-12-01 14:39:29 +08:00
Gordon c1ed2f14c8 demo merge into project 2021-12-01 14:28:47 +08:00
Gordon 3ae5c9dca1 demo merge into project 2021-12-01 13:35:28 +08:00
Gordon ace6ef0029 demo merge into project 2021-12-01 13:14:17 +08:00
Gordon 140724d665 demo merge into project 2021-12-01 12:44:39 +08:00
Gordon c476c255b8 demo merge into project 2021-12-01 12:44:34 +08:00
Gordon cf069970bd demo merge into project 2021-12-01 12:35:21 +08:00
Gordon a8341ec86d demo merge into project 2021-12-01 12:31:51 +08:00
Gordon 23b965a20a demo merge into project 2021-12-01 12:30:27 +08:00
Gordon 2104ba787a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-01 12:16:18 +08:00
Gordon 15660663f6 demo merge into project 2021-12-01 12:16:02 +08:00
wenxu12345 4d3e79281d script 2021-12-01 11:57:43 +08:00
wenxu12345 21ff7a36b8 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-12-01 10:41:34 +08:00
wenxu12345 42e2957bee script 2021-12-01 10:37:56 +08:00
Gordon bd62da8e1a test modify 2021-11-30 21:17:20 +08:00
Gordon df592d99dd test modify 2021-11-30 21:12:03 +08:00
Gordon 39f5e13463 test modify 2021-11-30 21:08:52 +08:00
Gordon 58785e9470 test modify 2021-11-30 21:06:10 +08:00
Gordon 3495d75a6f test modify 2021-11-30 21:05:24 +08:00
Gordon bee12423b0 test modify 2021-11-30 20:50:38 +08:00
Gordon a705e595ee test modify 2021-11-30 20:43:58 +08:00
Gordon 45f29c4c6f test modify 2021-11-30 20:38:23 +08:00
Gordon 5f90851458 test modify 2021-11-30 20:33:34 +08:00
Gordon 01515f919d test modify 2021-11-30 20:15:34 +08:00
Gordon a2292b1177 test modify 2021-11-30 19:58:57 +08:00
Gordon b2f5f56fa0 test modify 2021-11-30 19:54:27 +08:00
Gordon 2be1e1a70d test modify 2021-11-30 19:52:14 +08:00
Gordon b416cd380a test modify 2021-11-30 19:37:14 +08:00
Gordon f18f54afc6 test modify 2021-11-30 19:35:55 +08:00
Gordon b02830c891 token modify 2021-11-30 15:37:51 +08:00
Gordon aff733bbd9 constan 2021-11-29 18:24:39 +08:00
Gordon 4a66911a61 get all node online user status 2021-11-29 17:22:23 +08:00
Gordon c9b3a017a4 get all node online user status 2021-11-29 16:43:22 +08:00
root 6712d65de4 pbfile 2021-11-29 16:31:13 +08:00
Gordon c2a45cdbeb get all node online user status 2021-11-29 16:26:57 +08:00
Gordon 0f20e58a46 not token 2021-11-29 15:03:19 +08:00
root 2f37767899 pb file 2021-11-29 14:10:42 +08:00
Gordon f4c7272305 pb file 2021-11-29 14:09:10 +08:00
root 8a8e33763c pbfile 2021-11-29 12:01:53 +08:00
Gordon d55eda0bb3 pb file 2021-11-29 12:00:52 +08:00
root 6c7483733f pbfile 2021-11-29 11:44:51 +08:00
Gordon c7590c120d pb file 2021-11-29 11:25:57 +08:00
Gordon b3dec3653a pb file 2021-11-29 11:22:49 +08:00
Gordon 7cb42c49de pb file 2021-11-29 11:19:24 +08:00
Gordon 32dffb0375 Merge branch 'main' into tuoyun 2021-11-26 20:25:41 +08:00
Gordon c3d13c73ce Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-11-26 14:37:28 +08:00
Gordon 0ea48af892 panic output detail info 2021-11-26 14:34:00 +08:00
Gordon 72b09864ce panic output detail info 2021-11-26 14:20:50 +08:00
wenxu12345 d8e5fe367b config 2021-11-25 21:06:07 +08:00
wenxu12345 b1244c0a1b config 2021-11-25 20:32:24 +08:00
Gordon 7a3b56955c multi terminal kick eachOther 2021-11-25 16:37:36 +08:00
Gordon 5dcb7f2a80 multi terminal kick eachOther 2021-11-25 16:09:26 +08:00
Gordon 64e71440e2 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2021-11-25 16:09:12 +08:00
Gordon e7e3b6dd15 multi terminal kick eachOther 2021-11-25 14:12:52 +08:00
wenxu12345 06551575b1 0.0.0.0 2021-11-25 13:57:11 +08:00
wenxu12345 912ec51315 sleep 10 15 2021-11-24 10:19:12 +08:00
wenxu12345 1363c98cd8 0.0.0.0 2021-11-24 09:39:10 +08:00
wenxu12345 b9e49e37ea sleep 15 2021-11-23 15:30:28 +08:00
wenxu12345 4bb64e301e open-im-server -> open_im_server 2021-11-23 10:54:40 +08:00
wenxu12345 1c9c911373 configure update 2021-11-23 09:57:58 +08:00
wenxu12345 75a638f728 configure update 2021-11-23 09:57:09 +08:00
Gordon 09fd45346e add management interface and callback args optimization 2021-11-16 16:04:34 +08:00
Gordon 3329068bcc picture 2021-11-15 16:30:16 +08:00
Gordon aae6874928 null pointer fix 2021-11-15 16:10:56 +08:00
Gordon 6dacf23312 log change 2021-11-15 11:46:02 +08:00
Gordon bcc0cd33f1 log change 2021-11-15 11:44:04 +08:00
Gordon 0daa840eaa log change 2021-11-15 11:31:38 +08:00
Gordon ea5e69e26d log change 2021-11-15 10:22:20 +08:00
Gordon 26f0234e3d config modify 2021-11-15 10:18:59 +08:00
Gordon 95ac2c62e8 config modify 2021-11-12 18:54:51 +08:00
Gordon f65e4aad63 push modify 2021-11-12 18:51:39 +08:00
Gordon d7f82196dc push modify 2021-11-12 18:15:28 +08:00
Gordon e88f41323f push modify 2021-11-12 17:59:37 +08:00
Gordon 8f483b498b push modify 2021-11-12 17:25:17 +08:00
Gordon 85a75be30e notification modify 2021-11-12 16:09:21 +08:00
Gordon 4b13874d44 new server version 2021-11-11 20:14:59 +08:00
Gordon ace77e6fd0 new server version 2021-11-11 20:13:45 +08:00
Gordon 46deb5a099 merge newest branch 2021-11-11 19:04:35 +08:00
Gordon 6158ea436d merge newest branch 2021-11-11 18:47:21 +08:00
Gordon 7accffd7cd shell update 2021-11-11 10:15:28 +08:00
Gordon f337b8d7cc sub moudule 2021-11-11 09:48:26 +08:00
Gordon aeaab0a8d9 make file 2021-11-10 20:20:15 +08:00
Gordon d81b95d5a6 make file 2021-11-10 20:05:40 +08:00
Gordon 34e8961601 shell update 2021-11-10 19:11:49 +08:00
Gordon b729cac998 add timer update redis minSeq 2021-11-10 18:13:04 +08:00
Gordon a08aeee0c2 main modify 2021-11-10 16:03:07 +08:00
Gordon 90a466ef01 merge all branch and change project structure 2021-11-10 15:31:18 +08:00
Gordon ad14e259ba Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	config/config.yaml
2021-11-10 15:30:10 +08:00
Gordon 8a92326241 merge all branch and change project structure 2021-11-10 15:24:59 +08:00
tzw 3e45d489b8 修正配置中的token过期时间单位 (#52)
Co-authored-by: tanzhongwu <tanzhongwu@mail.wjhudong.com>
2021-11-10 14:40:16 +08:00
binyan.li 04ad424efa fix :mysql index field is too long, resulting in table creation failure (#40) 2021-11-05 17:37:12 +08:00
Xan 7f2270844e feat:uid generator & rm incompatible gopkg (#34) 2021-11-05 16:37:17 +08:00
Gordon c97e39fc09 user change 2021-11-04 21:01:25 +08:00
Gordon 515d7bb318 config change 2021-11-04 18:07:39 +08:00
Gordon cdf928d64e push content modify 2021-11-04 17:27:12 +08:00
Gordon 2440575093 push content modify 2021-11-04 16:52:48 +08:00
Gordon 817d2b11a5 push modify 2021-11-04 10:19:33 +08:00
Gordon 4b4dce80cf push modify 2021-11-03 21:16:46 +08:00
Gordon 52e15fc9d4 push modify 2021-11-03 20:03:43 +08:00
Gordon 7dbaa1b8c1 compose commit 2021-11-03 17:54:31 +08:00
Gordon 4215d65aa7 compose commit 2021-11-03 17:51:53 +08:00
Gordon 62a6195a4f push log add 2021-11-03 16:10:24 +08:00
Gordon 51622e77d4 push log add 2021-11-03 15:59:08 +08:00
Gordon 2e14e0f767 jpush secret 2021-11-03 14:13:41 +08:00
Gordon b219f8542b push fix 2021-11-03 09:37:26 +08:00
Gordon 6d67bb9d65 docker-compose modify 2021-11-02 18:00:43 +08:00
Gordon af37abb394 docker-compose modify 2021-11-02 17:37:51 +08:00
Gordon dfd028625d fix secret check and management 2021-11-02 16:12:55 +08:00
Gordon a87c16de0d push fix 2021-11-02 12:00:24 +08:00
muistar e77a156f29 fix offline push bug (#33)
Co-authored-by: xin.he <xin.he@rokid.com>
2021-11-02 10:18:47 +08:00
Gordon 082de2b6b7 group message fix bug 2021-11-01 17:16:47 +08:00
Gordon 7f19f2f046 fix import friend panic 2021-11-01 16:14:39 +08:00
Gordon 0cc641d1f8 script 2021-10-29 21:00:59 +08:00
Yaxian 51cef0bc53 feat: test utils (#26) 2021-10-29 20:51:15 +08:00
Gordon d6168cbad9 Add files via upload
update script
2021-10-29 20:48:43 +08:00
skiffer-git 76f2ea01bf update config (#31)
* Update README.md

* Add files via upload

update config

* Add files via upload

update script

* update config

Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2021-10-29 15:08:43 +08:00
skiffer-git 37a8ddbae6 Update README.md (#30)
* Update README.md

* Add files via upload

update config

* Add files via upload

update script
2021-10-29 15:02:52 +08:00
Gordon 71873f7f0e docker-compose.yaml change 2021-10-29 14:14:27 +08:00
Gordon e124a26c52 docker-compose.yaml change 2021-10-29 12:00:10 +08:00
Gordon 09b501f7df msg split num change 2021-10-29 10:41:02 +08:00
Gordon a86980657c remove note 2021-10-29 09:53:39 +08:00
antcorp 7c3aa7ee0b fix: Startup error (#11)
* fix: Startup error

Fixed a path error that prompted that the configuration file could not be found at startup

* Update config.go

Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2021-10-25 16:42:56 +08:00
Away 65157ede23 Update jwt token version (#27)
* add sdk svr to docker script

* panic handle

* fix build from dockerfile on docker-compose

* Update deploy.Dockerfile

* log and scripts optimization

* ci: ignore files created by docker-compose (#19)

* feat: optimise get server ip (#20)

* feat: optimise get server ip

* feat: test ServerIP

* fix issue#15 (#18)

Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* Modify bug for getting lastest seq

* Reduce the MongoDB version to adapt to a few machine (#22)

* Feature/optimise jwt token (#24)

* Pr branch (#25)

* fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"]

* del accountAddr

* Create codeql-analysis.yml

* del unuse filed

* fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"]

Co-authored-by: Gordon <1432970085@qq.com>
Co-authored-by: Yaxian <yaxian.gu@gmail.com>
Co-authored-by: Zzr <bhg889@163.com>
Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
Co-authored-by: brennanli <brennanli@tencent.com>
2021-10-25 11:08:10 +08:00
Zzr 8913ca161f Fix #21 (#23)
* fix issue#15

* fix #21

Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2021-10-23 14:18:55 +08:00
senyu 3d7fd2c192 del unuse filed 2021-10-23 10:51:57 +08:00
Away b2cc597755 Create codeql-analysis.yml 2021-10-23 09:21:05 +08:00
Away d6ba0a803d Pr branch (#25)
* fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"]

* del accountAddr
2021-10-22 21:20:31 +08:00
Yaxian 0e6432f95a Feature/optimise jwt token (#24) 2021-10-22 18:49:44 +08:00
Away 0dfaa49c97 Reduce the MongoDB version to adapt to a few machine (#22) 2021-10-22 10:14:32 +08:00
skiffer-git efeba3432c Merge pull request #12 from njulk/main
Modify bug for getting lastest seq
2021-10-21 17:11:37 +08:00
skiffer-git f16cd5b8db Merge pull request #9 from xmcy0011/dev
change project layout
2021-10-21 17:10:47 +08:00
Zzr 72b23ca235 fix issue#15 (#18)
Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
2021-10-21 12:10:38 +08:00
brennanli 1871b616ba Modify bug for getting lastest seq 2021-10-17 13:25:10 +08:00
xmcy0011 f21623e1b8 fixed submodule path 2021-10-11 22:52:06 +08:00
xmcy0011 a2e204667f Merge branch 'main' into v0926_project_layout
# Conflicts:
#	cmd/open_im_api/main.go
#	internal/rpc/auth/rpcAuth.go
#	internal/rpc/chat/rpcChat.go
#	src/common/log/logrus.go
2021-10-11 22:50:24 +08:00
xmcy0011 1ec9486452 fixed build error 2021-10-11 22:42:10 +08:00
xmcy0011 2b66aafdba change Open-IM-SDK-Core to cmd/ 2021-10-11 22:19:34 +08:00
xmcy0011 3169900f80 mv src/timed_task to internal/timed_task 2021-10-11 22:13:36 +08:00
xmcy0011 737edb985b mv src/common src/utils src/grpc-etcdv3 to pkg 2021-10-11 22:12:01 +08:00
xmcy0011 bc94d4e0b3 mv src/proto to pkg/proto 2021-10-11 22:00:38 +08:00
xmcy0011 585715adbf add cmd/rpc 2021-10-11 21:51:37 +08:00
xmcy0011 1a12eb9703 add cmd/open_im_push 2021-10-11 21:43:36 +08:00
xmcy0011 b4195bd81c add cmd/open_im_msg_transfer 2021-10-11 21:40:31 +08:00
xmcy0011 5fb4ea2aa3 add cmd/open_im_msg_gateway 2021-10-11 21:39:05 +08:00
xmcy0011 9367ad901d add cmd/open_im_api 2021-10-11 21:36:28 +08:00
xmcy0011 c956add8b0 add gitignore 2021-10-10 19:50:03 +08:00
Gordon 432a91cc64 Merge pull request #6 from Bloomingg/int
Update README.md
2021-09-26 19:39:55 +08:00
Bloomingg 629a322d1d Update README.md
test fork
2021-09-26 19:37:57 +08:00
384 changed files with 45523 additions and 17317 deletions
+37
View File
@@ -0,0 +1,37 @@
---
name: "\U0001F41E Bug"
about: File a bug/issue
title: "[BUG] <title>"
labels: ''
assignees: ''
---
<!--
Note: Please search to see if an issue already exists for the bug you encountered.
-->
### Environment:
<!-- linux? windows? or Mac?
Example:
- OS: Ubuntu 20.04 -->
### Physical Memory Capacity:
<!-- 8G or above is better -->
### Docker Image:
<!-- Did you pull the docker image before execute docker images -->
### Code Version:
<!-- Did you pull code from github? Make sure the code is up to date-->
### Component installation:
<!-- Has etcd, mysql, mongodb, redis or Kafka been installed on the server before Open-IM-Server deployment-->
### Log File:
<!-- view log file(logs/openIM.log) content. -->
### screenshot:
<!---->
@@ -0,0 +1,36 @@
---
name: Deployment issues
about: Deployment issues
title: ''
labels: ''
assignees: ''
---
If you are deploying OpenIM for the first time
```
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
```
screenshot here
```
cd Open-IM-Server/script ; chmod +x *.sh ; ./env_check.sh
```
screenshot here
```
cd .. ; docker-compose up -d
```
screenshot here
```
cd script ; ./docker_check_service.sh
```
screenshot here
+38
View File
@@ -0,0 +1,38 @@
---
name: 'update '
about: update docker image
title: update docker image
labels: ''
assignees: ''
---
```
cd Open-IM-Server ; docker-compose down
```
screenshot here
```
git pull
```
screenshot here
```
docker-compose pull
```
screenshot here
```
chmod +x script/*.sh ; docker-compose up -d
```
screenshot here
```
cd script ; ./docker_check_service.sh
```
screenshot here
+71
View File
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '23 2 * * 2'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
+21 -1
View File
@@ -1,2 +1,22 @@
bin
logs
.devcontainer
components
logs
logs
out-test
.github
.idea
deploy/open_im_demo
deploy/open_im_api
deploy/open_im_msg_gateway
deploy/open_im_msg_transfer
deploy/open_im_push
deploy/open_im_timer_task
deploy/open_im_rpc_user
deploy/open_im_rpc_friend
deploy/open_im_rpc_group
deploy/open_im_rpc_msg
deploy/open_im_rpc_auth
deploy/Open-IM-SDK-Core
+2 -2
View File
@@ -1,4 +1,4 @@
[submodule "src/Open-IM-SDK-Core"]
path = src/Open-IM-SDK-Core
[submodule "cmd/Open-IM-SDK-Core"]
path = cmd/Open-IM-SDK-Core
url = https://github.com/OpenIMSDK/Open-IM-SDK-Core.git
+4 -2
View File
@@ -1,4 +1,4 @@
# Open-IM-Server
# Open-IM-Server
![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png)
@@ -92,6 +92,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
4. Start docker-compose with one click(Docker automatically pulls all images)
```
cd Open-IM-Server
docker-compose up -d
```
@@ -99,6 +100,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
```
./docker_check_service.sh
./check_all.sh
```
![OpenIMServersondockerpng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-docker.png)
@@ -154,4 +156,4 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
## License
Open-IM-Server is under the Apache 2.0 license. See the [LICENSE](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE) file for details.
Open-IM-Server is under the Apache 2.0 license. See the [LICENSE](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE) file for details
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_api
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+147
View File
@@ -0,0 +1,147 @@
package main
import (
apiAuth "Open_IM/internal/api/auth"
apiChat "Open_IM/internal/api/chat"
"Open_IM/internal/api/conversation"
"Open_IM/internal/api/friend"
"Open_IM/internal/api/group"
"Open_IM/internal/api/manage"
"Open_IM/internal/api/office"
apiThird "Open_IM/internal/api/third"
"Open_IM/internal/api/user"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
"fmt"
"io"
"os"
"strconv"
"github.com/gin-gonic/gin"
//"syscall"
"Open_IM/pkg/common/constant"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default()
r.Use(utils.CorsHandler())
log.Info("load config: ", config.Config)
// user routing group, which handles user registration and login services
userRouterGroup := r.Group("/user")
{
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
}
//friend routing group
friendRouterGroup := r.Group("/friend")
{
// friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
friendRouterGroup.POST("/add_friend", friend.AddFriend) //1
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1
friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1
friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1
friendRouterGroup.POST("/add_black", friend.AddBlack) //1
friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1
friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1
friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1
friendRouterGroup.POST("/is_friend", friend.IsFriend) //1
}
//group related routing group
groupRouterGroup := r.Group("/group")
{
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
groupRouterGroup.POST("join_group", group.JoinGroup) //1
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
groupRouterGroup.POST("/mute_group", group.MuteGroup)
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
}
//certificate
authRouterGroup := r.Group("/auth")
{
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
}
//Third service
thirdGroup := r.Group("/third")
{
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
}
//Message
chatGroup := r.Group("/msg")
{
chatGroup.POST("/newest_seq", apiChat.GetSeq)
chatGroup.POST("/send_msg", apiChat.SendMsg)
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
chatGroup.POST("/del_msg", apiChat.DelMsg)
}
//Manager
managementGroup := r.Group("/manager")
{
managementGroup.POST("/delete_user", manage.DeleteUser) //1
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
managementGroup.POST("/account_check", manage.AccountCheck) //1
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
}
//Conversation
conversationGroup := r.Group("/conversation")
{ //1
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
conversationGroup.POST("/get_conversation", conversation.GetConversation)
conversationGroup.POST("/get_conversations", conversation.GetConversations)
conversationGroup.POST("/set_conversation", conversation.SetConversation)
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
}
// office
officeGroup := r.Group("/office")
{
officeGroup.POST("/get_user_tags", office.GetUserTags)
officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID)
officeGroup.POST("/create_tag", office.CreateTag)
officeGroup.POST("/delete_tag", office.DeleteTag)
officeGroup.POST("/set_tag", office.SetTag)
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
}
go apiThird.MinioInit()
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
flag.Parse()
fmt.Println("start api server, port: ", *ginPort)
err := r.Run(":" + strconv.Itoa(*ginPort))
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cms_api
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+17
View File
@@ -0,0 +1,17 @@
package main
import (
"Open_IM/internal/cms_api"
"Open_IM/pkg/utils"
"fmt"
"github.com/gin-gonic/gin"
)
func main() {
gin.SetMode(gin.ReleaseMode)
router := cms_api.NewGinRouter()
router.Use(utils.CorsHandler())
fmt.Println("start cms api server, port: ", 8000)
router.Run(":" + "8000")
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_demo
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+42
View File
@@ -0,0 +1,42 @@
package main
import (
"Open_IM/internal/demo/register"
"Open_IM/pkg/utils"
"flag"
"fmt"
"io"
"os"
"strconv"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default()
r.Use(utils.CorsHandler())
authRouterGroup := r.Group("/auth")
{
authRouterGroup.POST("/code", register.SendVerificationCode)
authRouterGroup.POST("/verify", register.Verify)
authRouterGroup.POST("/password", register.SetPassword)
authRouterGroup.POST("/login", register.Login)
authRouterGroup.POST("/reset_password", register.ResetPassword)
}
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
fmt.Println("start demo api server, port: ", *ginPort)
err := r.Run(":" + strconv.Itoa(*ginPort))
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
}
@@ -2,13 +2,11 @@
BINARY_NAME=open_im_msg_gateway
BIN_DIR=../../bin/
LAN_FILE=.go
GO_FILE:=${BINARY_NAME}${LAN_FILE}
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
+23
View File
@@ -0,0 +1,23 @@
package main
import (
"Open_IM/internal/msg_gateway/gate"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"fmt"
"sync"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
wsPort := flag.Int("ws_port", 17778, "ws listening port")
flag.Parse()
var wg sync.WaitGroup
wg.Add(1)
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort)
gate.Init(*rpcPort, *wsPort)
gate.Run()
wg.Wait()
}
@@ -2,13 +2,12 @@
BINARY_NAME=open_im_msg_transfer
BIN_DIR=../../bin/
LAN_FILE=.go
GO_FILE:=${BINARY_NAME}${LAN_FILE}
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
+19
View File
@@ -0,0 +1,19 @@
package main
import (
"Open_IM/internal/msg_transfer/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init()
fmt.Println("start msg_transfer server")
logic.Run()
wg.Wait()
}
@@ -2,13 +2,11 @@
BINARY_NAME=open_im_push
BIN_DIR=../../bin/
LAN_FILE=.go
GO_FILE:=${BINARY_NAME}${LAN_FILE}
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
+22
View File
@@ -0,0 +1,22 @@
package main
import (
"Open_IM/internal/push/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"fmt"
"sync"
)
func main() {
rpcPort := flag.Int("port", 10700, "rpc listening port")
flag.Parse()
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
fmt.Println("start push rpc server, port: ", *rpcPort)
logic.Init(*rpcPort)
logic.Run()
wg.Wait()
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_timer_task
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+63
View File
@@ -0,0 +1,63 @@
package main
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
//for {
// fmt.Println("start delete mongodb expired record")
// timeUnixBegin := time.Now().Unix()
// count, _ := db.DB.MgoUserCount()
// fmt.Println("mongodb record count: ", count)
// for i := 0; i < count; i++ {
// time.Sleep(1 * time.Millisecond)
// uid, _ := db.DB.MgoSkipUID(i)
// fmt.Println("operate uid: ", uid)
// err := db.DB.DelUserChat(uid)
// if err != nil {
// fmt.Println("operate uid failed: ", uid, err.Error())
// }
// }
//
// timeUnixEnd := time.Now().Unix()
// costTime := timeUnixEnd - timeUnixBegin
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
// continue
// } else {
// sleepTime := 0
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
// sleepTime = 24 * 3600
// } else {
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
// }
// fmt.Println("sleep: ", sleepTime)
// time.Sleep(time.Duration(sleepTime) * time.Second)
// }
//}
//for {
// uidList, err := im_mysql_model.SelectAllUserID()
// if err != nil {
// //log.NewError("999999", err.Error())
// } else {
// for _, v := range uidList {
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
// if err != nil {
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
// continue
// } else {
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
// if err != nil {
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
// }
// }
// time.Sleep(time.Duration(100) * time.Millisecond)
// }
//
// }
//
//}
}
+23
View File
@@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_admin_cms
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+15
View File
@@ -0,0 +1,15 @@
package main
import (
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 11000, "rpc listening port")
flag.Parse()
fmt.Println("start cms rpc server, port: ", *rpcPort)
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
rpcServer.Run()
}
+24
View File
@@ -0,0 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_auth
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
@@ -1,13 +1,16 @@
package main
import (
rpcAuth "Open_IM/src/rpc/auth/auth"
rpcAuth "Open_IM/internal/rpc/auth"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800")
flag.Parse()
fmt.Println("start auth rpc server, port: ", *rpcPort)
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
rpcServer.Run()
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_friend
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
@@ -1,14 +1,16 @@
package main
import (
"Open_IM/src/rpc/friend/friend"
"Open_IM/internal/rpc/friend"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10200, "get RpcFriendPort from cmd,default 12000 as port")
flag.Parse()
fmt.Println("start friend rpc server, port: ", *rpcPort)
rpcServer := friend.NewFriendServer(*rpcPort)
rpcServer.Run()
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_group
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
@@ -1,13 +1,15 @@
package main
import (
"Open_IM/src/rpc/group/group"
"Open_IM/internal/rpc/group"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10500, "get RpcGroupPort from cmd,default 16000 as port")
flag.Parse()
fmt.Println("start group rpc server, port: ", *rpcPort)
rpcServer := group.NewGroupServer(*rpcPort)
rpcServer.Run()
}
+23
View File
@@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_message_cms
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+15
View File
@@ -0,0 +1,15 @@
package main
import (
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10900, "rpc listening port")
flag.Parse()
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
rpcServer.Run()
}
@@ -2,13 +2,11 @@
BINARY_NAME=open_im_msg
BIN_DIR=../../../bin/
LAN_FILE=.go
GO_FILE:=${BINARY_NAME}${LAN_FILE}
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
+15
View File
@@ -0,0 +1,15 @@
package main
import (
rpcChat "Open_IM/internal/rpc/msg"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10300, "rpc listening port")
flag.Parse()
fmt.Println("start msg rpc server, port: ", *rpcPort)
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
rpcServer.Run()
}
+23
View File
@@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_office
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+15
View File
@@ -0,0 +1,15 @@
package main
import (
rpc "Open_IM/internal/rpc/office"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 11100, "rpc listening port")
flag.Parse()
fmt.Println("start office rpc server, port: ", *rpcPort)
rpcServer := rpc.NewOfficeServer(*rpcPort)
rpcServer.Run()
}
+23
View File
@@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_statistics
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+15
View File
@@ -0,0 +1,15 @@
package main
import (
"Open_IM/internal/rpc/statistics"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10800, "rpc listening port")
flag.Parse()
fmt.Println("start statistics rpc server, port: ", *rpcPort)
rpcServer := statistics.NewStatisticsServer(*rpcPort)
rpcServer.Run()
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_user
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
@@ -1,13 +1,15 @@
package main
import (
"Open_IM/src/rpc/user/user"
"Open_IM/internal/rpc/user"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 10100, "rpc listening port")
flag.Parse()
fmt.Println("start user rpc server, port: ", *rpcPort)
rpcServer := user.NewUserServer(*rpcPort)
rpcServer.Run()
}
+69
View File
@@ -0,0 +1,69 @@
package main
import (
"Open_IM/pkg/utils"
"context"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
type MongoMsg struct {
UID string
Msg []string
}
func main() {
//"mongodb://%s:%s@%s/%s/?maxPoolSize=%d"
uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
DBAddress := "127.0.0.1:37017"
DBDatabase := "new-test-db"
Collection := "new-test-collection"
DBMaxPoolSize := 100
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
DBAddress,DBDatabase,
DBMaxPoolSize)
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil {
panic(err)
}
filter := bson.M{"uid":"my_uid"}
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
for i:=0; i < 2; i++{
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOneAndUpdate(ctx, filter,
bson.M{"$push": bson.M{"msg": utils.Int32ToString(int32(i))}}).Err(); err != nil{
fmt.Println("FindOneAndUpdate failed ", i, )
var mmsg MongoMsg
mmsg.UID = "my_uid"
mmsg.Msg = append(mmsg.Msg, utils.Int32ToString(int32(i)))
_, err := mongoClient.Database(DBDatabase).Collection(Collection).InsertOne(ctx, &mmsg)
if err != nil {
fmt.Println("insertone failed ", err.Error(), i)
} else{
fmt.Println("insertone ok ", i)
}
}else {
fmt.Println("FindOneAndUpdate ok ", i)
}
}
var mmsg MongoMsg
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOne(ctx, filter).Decode(&mmsg); err != nil {
fmt.Println("findone failed ", err.Error())
}else{
fmt.Println("findone ok ", mmsg.UID)
for i, v:=range mmsg.Msg{
fmt.Println("find value: ", i, v)
}
}
}
+506 -47
View File
@@ -1,47 +1,48 @@
# The class cannot be named by Pascal or camel case.
# If it is not used, the corresponding structure will not be set,
# and it will not be read naturally.
serverversion: 1.0.0
serverversion: 2.0.0
#---------------Infrastructure configuration---------------------#
etcd:
etcdSchema: openIM
etcdAddr: [ 127.0.0.1:2379 ]
etcdSchema: openIM #默认即可
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
mysql:
dbMysqlAddress: [ 127.0.0.1:3306 ]
dbMysqlUserName: root
dbMysqlPassword: openIM
dbMysqlDatabaseName: openIM
dbTableName: eMsg
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
dbMysqlUserName: root #mysql用户名,建议修改
dbMysqlPassword: openIM # mysql密码,建议修改
dbMysqlDatabaseName: openIM_v2 #默认即可
dbTableName: eMsg #默认即可
dbMsgTableNum: 1
dbMaxOpenConns: 20
dbMaxIdleConns: 10
dbMaxLifeTime: 120
mongo:
dbAddress: [ 127.0.0.1:27017 ]
dbUri: ""#当dbUri值不为空则直接使用该值
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
dbDirect: false
dbTimeout: 10
dbDatabase: openIM
dbDatabase: openIM #mongo db 默认即可
dbSource: admin
dbUserName:
dbPassword:
dbUserName: #mongo用户名,建议先不设置
dbPassword: #mongo密码,建议先不设置
dbMaxPoolSize: 20
dbRetainChatRecords: 7
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
redis:
dbAddress: 127.0.0.1:6379
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
dbMaxIdle: 128
dbMaxActive: 0
dbIdleTimeout: 120
dbPassWord: openIM
dbPassWord: openIM #redis密码 建议修改
kafka:
ws2mschat:
addr: [ 127.0.0.1:9092 ]
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
topic: "ws2ms_chat"
ms2pschat:
addr: [ 127.0.0.1:9092 ]
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
topic: "ms2ps_chat"
consumergroupid:
msgToMongo: mongo
@@ -55,33 +56,81 @@ kafka:
# The service ip default is empty,
# automatically obtain the machine's valid network card ip as the service ip,
# otherwise the configuration ip is preferred
serverip:
#如果是单机模式,用0.0.0.0或者不填,默认即可
serverip: 0.0.0.0
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
endpoints:
api: openim_api
cmsapi: openim_cms_api
push: openim_push
msg_gateway: openim_msg_gateway
rpc_auth: openim_rpc_auth
rpc_friend: openim_rpc_friend
rpc_group: openim_rpc_group
rpc_msg: openim_rpc_msg
rpc_user: openim_rpc_user
rpc_statistic: openim_rpc_statistic
rpc_admin_cms: openim_rpc_admin_cms
rpc_message_cms: openim_rpc_admin_cms
rpc_office: openim_rpc_office
api:
openImApiPort: [ 10000 ]
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
cmsapi:
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
sdk:
openImSdkWsPort: [ 30000 ]
credential:
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
tencent:
appID: 1302656840
region: ap-chengdu
bucket: echat-1302656840
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
bucket: openim
location: us-east-1
endpoint: http://121.37.25.71:9000
accessKeyID: user12345
secretAccessKey: key12345
ali: # ali oss
regionID: "oss-cn-beijing"
accessKeyID: ""
accessKeySecret: ""
stsEndpoint: "sts.cn-beijing.aliyun.com"
ossEndpoint: "oss-cn-beijing.aliyuncs.com"
bucket: "bucket1"
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
stsDurationSeconds: 3600
OssRoleArn: "acs:ram::xxx:role/xxx"
rpcport:
rpcport: #rpc服务端口 默认即可
openImUserPort: [ 10100 ]
openImFriendPort: [ 10200 ]
openImOfflineMessagePort: [ 10300 ]
openImOnlineRelayPort: [ 10400 ]
openImGroupPort: [ 10500 ]
openImGroupPort: [ 10500 ]
openImAuthPort: [ 10600 ]
openImPushPort: [ 10700 ]
openImStatisticsPort: [ 10800 ]
openImMessageCmsPort: [ 10900 ]
openImAdminCmsPort: [ 11000 ]
openImOfficePort: [ 11100 ]
c2c:
callbackBeforeSendMsg:
switch: false
timeoutStrategy: 1 #1:send
callbackAfterSendMsg:
switch: false
state:
stateChange:
switch: false
rpcregistername:
rpcregistername: #rpc注册服务名,默认即可
openImUserName: User
openImFriendName: Friend
openImOfflineMessageName: OfflineMessage
@@ -89,58 +138,468 @@ rpcregistername:
openImOnlineMessageRelayName: OnlineMessageRelay
openImGroupName: Group
openImAuthName: Auth
OpenImStatisticsName: Statistics
OpenImMessageCMSName: MessageCMS
openImAdminCMSName: AdminCMS
openImOfficeName: Office
log:
storageLocation: ../logs/
rotationTime: 24
remainRotationCount: 5
remainRotationCount: 3 #日志数量
#日志级别 6表示全都打印,测试阶段建议设置为6
remainLogLevel: 6
elasticSearchSwitch: false
elasticSearchAddr: [ 127.0.0.1:9201 ]
elasticSearchUser: ""
elasticSearchPassword: ""
modulename:
modulename: #日志文件按模块命名,默认即可
longConnSvrName: msg_gateway
msgTransferName: msg_transfer
pushName: push
longconnsvr:
openImWsPort: [ 17778 ]
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
websocketMaxConnNum: 10000
websocketMaxMsgLen: 4096
websocketTimeOut: 10
## 推送只能开启一个
push:
tpns:
tpns: #腾讯推送,暂未测试 暂不要使用
ios:
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
android:
accessID: 111
secretKey: 111
jpns:
appKey: 2783339cee4de379cc798fe1
masterSecret: 66e5f309e032c68cc668c28a
enable: false
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
appKey: cf47465a368f24c659608e7e
masterSecret: 02204efe3f3832947a236ee5
pushUrl: "https://api.jpush.cn/v3/push"
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
enable: true
getui: #个推推送,暂未测试 暂不要使用
pushUrl: "https://restapi.getui.com/v2/$appId"
masterSecret: ""
appKey: ""
intent: ""
enable: false
manager:
appManagerUid: ["openIM123456","openIM654321"]
secrets: ["openIM1","openIM2"]
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
secret: tuoyun
multiloginpolicy:
onlyOneTerminalAccess: false
mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true
allTerminalAccess: false
# 多端互踢策略
# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线
multiloginpolicy: 1
#token config
tokenpolicy:
accessSecret: "open_im_server"
# Token effective time seconds as a unit
#Seven days 7*24*60*60
accessExpire: 604800
accessSecret: "open_im_server" #token生成相关,默认即可
# Token effective time day as a unit
accessExpire: 3650 #token过期时间(天) 默认即可
messageverify:
friendVerify: false
messagecallback:
callbackSwitch: false
callbackUrl: "http://www.xxx.com/msg/judge"
# c2c:
# callbackBeforeSendMsg:
# switch: false
# timeoutStrategy: 1 #1:send
# callbackAfterSendMsg:
# switch: false
# state:
# stateChange:
# switch: false
#ios系统推送声音以及标记计数
iospush:
pushSound: "xxx"
badgeCount: true
callback:
# callback url 需要自行更换callback url
callbackUrl : "http://127.0.0.1:8080/callback"
# 开启关闭操作前后回调的配置
callbackbeforeSendSingleMsg:
enable: false # 回调是否启用
callbackTimeOut: 2 # 回调超时时间
callbackFailedContinue: true # 回调超时是否继续执行代码
callbackAfterSendSingleMsg:
enable: false
callbackTimeOut: 2
callbackBeforeSendGroupMsg:
enable: false
callbackTimeOut: 2
callbackFailedContinue: true
callbackAfterSendGroupMsg:
enable: false
callbackTimeOut: 2
callbackWordFilter:
enable: false
callbackTimeOut: 2
callbackFailedContinue: true
notification:
groupCreated:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: true
title: "create group title" # xx create the group
desc: "create group desc"
ext: "create group ext"
defaultTips:
tips: "create the group" # xx create the group
groupInfoSet:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupInfoSet title"
desc: "groupInfoSet desc"
ext: "groupInfoSet ext"
defaultTips:
tips: "modified the group profile" # group info changed by xx
joinGroupApplication:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: "joinGroupApplication title"
desc: "joinGroupApplication desc"
ext: "joinGroupApplication ext"
defaultTips:
tips: "apply to join the group" # group info changed by xx
memberQuit:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "memberQuit title"
desc: "memberQuit desc"
ext: "memberQuit ext"
defaultTips:
tips: "quit group chat" # group info changed by xx
groupApplicationAccepted:
conversation:
reliabilityLevel: 2
unreadCount: true
offlinePush:
switch: false
title: "groupApplicationAccepted title"
desc: "groupApplicationAccepted desc"
ext: "groupApplicationAccepted ext"
defaultTips:
tips: "was allowed to join the group" # group info changed by xx
groupApplicationRejected:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: " title"
desc: " desc"
ext: " ext"
defaultTips:
tips: "was rejected into the group" # group info changed by xx
groupOwnerTransferred:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupOwnerTransferred title"
desc: "groupOwnerTransferred desc"
ext: "groupOwnerTransferred ext"
defaultTips:
tips: "become a new group owner" # group info changed by xx
memberKicked:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "memberKicked title"
desc: "memberKicked desc"
ext: "memberKicked ext"
defaultTips:
tips: "was kicked out of the group" # group info changed by xx
memberInvited:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "memberInvited title"
desc: "memberInvited desc"
ext: "memberInvited ext"
defaultTips:
tips: "was invited into the group" # group info changed by xx
memberEnter:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "memberEnter title"
desc: "memberEnter desc"
ext: "memberEnter ext"
defaultTips:
tips: "entered the group" # group info changed by xx
groupDismissed:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupDismissed title"
desc: "groupDismissed desc"
ext: "groupDismissed ext"
defaultTips:
tips: "group dismissed"
groupMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMuted title"
desc: "groupMuted desc"
ext: "groupMuted ext"
defaultTips:
tips: "group Muted"
groupCancelMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupCancelMuted title"
desc: "groupCancelMuted desc"
ext: "groupCancelMuted ext"
defaultTips:
tips: "group Cancel Muted"
groupMemberMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMemberMuted title"
desc: "groupMemberMuted desc"
ext: "groupMemberMuted ext"
defaultTips:
tips: "group Member Muted"
groupMemberCancelMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMemberCancelMuted title"
desc: "groupMemberCancelMuted desc"
ext: "groupMemberCancelMuted ext"
defaultTips:
tips: "group Member Cancel Muted"
#############################friend#################################
friendApplicationAdded:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Somebody applies to add you as a friend"
desc: "Somebody applies to add you as a friend"
ext: "Somebody applies to add you as a friend"
defaultTips:
tips: "I applies to add you as a friend" #
friendApplicationApproved:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Someone applies to add your friend application"
desc: "Someone applies to add your friend application"
ext: "Someone applies to add your friend application"
defaultTips:
tips: "I applies to add your friend application" #
friendApplicationRejected:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Someone rejected your friend application"
desc: "Someone rejected your friend application"
ext: "Someone rejected your friend application"
defaultTips:
tips: "I rejected your friend application" #
friendAdded:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: true
title: "We have become friends"
desc: "We have become friends"
ext: "We have become friends"
defaultTips:
tips: "We have become friends" #
friendDeleted:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "deleted a friend"
desc: "deleted a friend"
ext: "deleted a friend"
defaultTips:
tips: "deleted a friend" #
friendRemarkSet:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Your friend's profile has been changed"
desc: "Your friend's profile has been changed"
ext: "Your friend's profile has been changed"
defaultTips:
tips: "Your friend's profile has been changed" #
blackAdded:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "blocked a user"
desc: "blocked a user"
ext: "blocked a user"
defaultTips:
tips: "blocked a user" #
blackDeleted:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
defaultTips:
tips: "Remove a blocked user"
#####################user#########################
userInfoUpdated:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
defaultTips:
tips: "remove a blocked user"
#####################conversation#########################
conversationOptUpdate:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "conversation opt update"
desc: "conversation opt update"
ext: "conversation opt update"
defaultTips:
tips: "conversation opt update"
conversationSetPrivate:
conversation:
reliabilityLevel: 2
unreadCount: true
offlinePush:
switch: true
title: "burn after reading"
desc: "burn after reading"
ext: "burn after reading"
defaultTips:
openTips: "burn after reading was opened"
closeTips: "burn after reading was closed"
#---------------demo configuration---------------------#
#The following configuration items are applied to openIM Demo configuration
#是否启动demo,如果自身没有账号体系,设置为true
demoswitch: true
demo:
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
openImDemoPort: [ 42233 ]
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
signName: 托云信息技术
verificationCodeTemplateCode: SMS_226810164
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
# second
codeTTL: 300
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
title: "openIM"
senderMail: "765567899@qq.com"
senderAuthorizationCode: "gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25 #需开放此端口 出口方向
rtc:
port: 11300
address: 127.0.0.1
+6
View File
@@ -0,0 +1,6 @@
# 先设为忽略所有内容
**/**
# 然后逐个排除
!open_im_*
+158
View File
@@ -0,0 +1,158 @@
GREEN_PREFIX="\033[32m"
COLOR_SUFFIX="\033[0m"
SKY_BLUE_PREFIX="\033[36m"
# 编译所有需要的组件源码
win-build-all:
go env -w GOOS=linux
make build-api && make build-msg-gateway && make build-msg-transfer && make build-push && make build-timer-task
make build-rpc-user && make build-rpc-friend && make build-rpc-group && make build-rpc-msg && make build-rpc-auth
make build-demo
go env -w GOOS=windows
# 编译 open_im_api
build-api:
echo -e ${GREEN_PREFIX} "open_im_api building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_api ../cmd/open_im_api/main.go
echo -e ${GREEN_PREFIX} "open_im_api build ok" ${COLOR_SUFFIX}
# 编译 open_im_msg_gateway
build-msg-gateway:
echo -e ${GREEN_PREFIX} "open_im_msg_gateway building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_msg_gateway ../cmd/open_im_msg_gateway/main.go
echo -e ${GREEN_PREFIX} "open_im_msg_gateway build ok" ${COLOR_SUFFIX}
# 编译 open_im_msg_transfer
build-msg-transfer:
echo -e ${GREEN_PREFIX} "open_im_msg_transfer building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_msg_transfer ../cmd/open_im_msg_transfer/main.go
echo -e ${GREEN_PREFIX} "open_im_msg_transfer build ok" ${COLOR_SUFFIX}
# 编译 open_im_push
build-push:
echo -e ${GREEN_PREFIX} "open_im_push building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_push ../cmd/open_im_push/main.go
echo -e ${GREEN_PREFIX} "open_im_push build ok" ${COLOR_SUFFIX}
# 编译 open_im_timer_task
build-timer-task:
echo -e ${GREEN_PREFIX} "open_im_timer_task building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_timer_task ../cmd/open_im_timer_task/main.go
echo -e ${GREEN_PREFIX} "open_im_timer_task build ok" ${COLOR_SUFFIX}
# 编译 build-rpc-user
build-rpc-user:
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_user building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_rpc_user ../cmd/rpc/open_im_user/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_user build ok" ${COLOR_SUFFIX}
# 编译 build-rpc-friend
build-rpc-friend:
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_friend building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_rpc_friend ../cmd/rpc/open_im_friend/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_friend build ok" ${COLOR_SUFFIX}
# 编译 build-rpc-group
build-rpc-group:
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_group building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_rpc_group ../cmd/rpc/open_im_group/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_group build ok" ${COLOR_SUFFIX}
# 编译 build-rpc-auth
build-rpc-auth:
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_auth building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_rpc_auth ../cmd/rpc/open_im_auth/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_auth build ok" ${COLOR_SUFFIX}
# 编译 build-rpc-msg
build-rpc-msg:
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_msg building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_rpc_msg ../cmd/rpc/open_im_msg/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_rpc_msg build ok" ${COLOR_SUFFIX}
# 编译 open_im_demo
build-demo:
echo -e ${SKY_BLUE_PREFIX} "open_im_demo building..." ${COLOR_SUFFIX}
go build -ldflags="-w -s" -o open_im_demo ../cmd/open_im_demo/main.go
echo -e ${SKY_BLUE_PREFIX} "open_im_demo build ok" ${COLOR_SUFFIX}
# 打包所有组件为镜像
image-all:
make image-api && make image-msg-gateway && make image-msg-transfer & make image-push && make image-timer-task
make image-rpc-user && make image-rpc-friend && make image-rpc-group && make image-rpc-msg && make image-rpc-auth
make image-demo
# 打包 open_im_api
image-api:
echo -e ${GREEN_PREFIX} "IMAGE:openim/api building..." ${COLOR_SUFFIX}
docker build -t openim/api:latest -f ./dockerfiles/Dockerfile.api .
echo -e ${GREEN_PREFIX} "IMAGE:openim/api build ok" ${COLOR_SUFFIX}
# 打包 open_im_msg_gateway
image-msg-gateway:
echo -e ${GREEN_PREFIX} "IMAGE:openim/msg_gateway building..." ${COLOR_SUFFIX}
docker build -t openim/msg_gateway:latest -f ./dockerfiles/Dockerfile.msg_gateway .
echo -e ${GREEN_PREFIX} "IMAGE:openim/msg_gateway build ok" ${COLOR_SUFFIX}
# 打包 open_im_msg_transfer
image-msg-transfer:
echo -e ${GREEN_PREFIX} "IMAGE:openim/msg_transfer building..." ${COLOR_SUFFIX}
docker build -t openim/msg_transfer:latest -f ./dockerfiles/Dockerfile.msg_transfer .
echo -e ${GREEN_PREFIX} "IMAGE:openim/msg_transfer build ok" ${COLOR_SUFFIX}
# 打包 open_im_push
image-push:
echo -e ${GREEN_PREFIX} "IMAGE:openim/push building..." ${COLOR_SUFFIX}
docker build -t openim/push:latest -f ./dockerfiles/Dockerfile.push .
echo -e ${GREEN_PREFIX} "IMAGE:openim/push build ok" ${COLOR_SUFFIX}
# 打包 open_im_timer_task
image-timer-task:
echo -e ${GREEN_PREFIX} "IMAGE:openim/timer_task building..." ${COLOR_SUFFIX}
docker build -t openim/timer_task:latest -f ./dockerfiles/Dockerfile.timer_task .
echo -e ${GREEN_PREFIX} "IMAGE:openim/timer_task build ok" ${COLOR_SUFFIX}
# 打包 build-rpc-user
image-rpc-user:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_user building..." ${COLOR_SUFFIX}
docker build -t openim/rpc_user:latest -f ./dockerfiles/Dockerfile.rpc_user .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_user build ok" ${COLOR_SUFFIX}
# 打包 build-rpc-friend
image-rpc-friend:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_friend building..." ${COLOR_SUFFIX}
docker build -t openim/rpc_friend:latest -f ./dockerfiles/Dockerfile.rpc_friend .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_friend build ok" ${COLOR_SUFFIX}
# 打包 build-rpc-group
image-rpc-group:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_group building..." ${COLOR_SUFFIX}
docker build -t openim/rpc_group:latest -f ./dockerfiles/Dockerfile.rpc_group .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_group build ok" ${COLOR_SUFFIX}
# 打包 build-rpc-auth
image-rpc-auth:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_auth building..." ${COLOR_SUFFIX}
docker build -t openim/rpc_auth:latest -f ./dockerfiles/Dockerfile.rpc_auth .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_auth build ok" ${COLOR_SUFFIX}
# 打包 build-rpc-msg
image-rpc-msg:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_msg building..." ${COLOR_SUFFIX}
docker build -t openim/rpc_msg:latest -f ./dockerfiles/Dockerfile.rpc_msg .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/rpc_msg build ok" ${COLOR_SUFFIX}
# 打包 open_im_demo
image-demo:
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/demo building..." ${COLOR_SUFFIX}
docker build -t openim/demo:latest -f ./dockerfiles/Dockerfile.demo .
echo -e ${SKY_BLUE_PREFIX} "IMAGE:openim/demo build ok" ${COLOR_SUFFIX}
.PHONY: win-build-all build-api build-msg-gateway build-msg-transfer build-push
build-timer-task build-rpc-user build-rpc-friend build-rpc-group build-rpc-msg build-demo
image-all image-api image-msg-gateway image-msg-transfer image-push
image-timer-task image-rpc-user image-rpc-friend image-rpc-group image-rpc-msg image-demo
+183
View File
@@ -0,0 +1,183 @@
# The class cannot be named by Pascal or camel case.
# If it is not used, the corresponding structure will not be set,
# and it will not be read naturally.
serverversion: 1.0.3
#---------------Infrastructure configuration---------------------#
etcd:
etcdSchema: openIM
etcdAddr: [ openim_etcd:2379 ]
mysql:
dbMysqlAddress: [ openim_mysql:3306 ] # openim_mysql 是对应的mysql服务的host
dbMysqlUserName: openIM
dbMysqlPassword: openIM
dbMysqlDatabaseName: openIM
dbTableName: eMsg
dbMsgTableNum: 1
dbMaxOpenConns: 20
dbMaxIdleConns: 10
dbMaxLifeTime: 120
mongo:
dbUri: ""#当dbUri值不为空则直接使用该值
dbAddress: [ openim_mongo:27017 ]
dbDirect: false
dbTimeout: 10
dbDatabase: openIM
dbSource: admin
dbUserName:
dbPassword:
dbMaxPoolSize: 20
dbRetainChatRecords: 7
redis:
dbAddress: openim_redis:6379
dbMaxIdle: 128
dbMaxActive: 0
dbIdleTimeout: 120
dbPassWord: openIM
kafka:
ws2mschat:
addr: [ openim_kafka:9092 ]
topic: "ws2ms_chat"
ms2pschat:
addr: [ openim_kafka:9092 ]
topic: "ms2ps_chat"
consumergroupid:
msgToMongo: mongo
msgToMySql: mysql
msgToPush: push
#---------------Internal service configuration---------------------#
# The service ip default is empty,
# automatically obtain the machine's valid network card ip as the service ip,
# otherwise the configuration ip is preferred
serverip: 0.0.0.0
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
# 新增的这一段配置节,主要是位了注册到etcd时,可以使用同一network下的容器名(host)来访问不同的容器,拆分到不同容器后原来全部使用serverip的形式不能用了
endpoints:
api: openim_api
push: openim_push
msg_gateway: openim_msg_gateway
rpc_auth: openim_rpc_auth
rpc_friend: openim_rpc_friend
rpc_group: openim_rpc_group
rpc_msg: openim_rpc_msg
rpc_user: openim_rpc_user
api:
openImApiPort: [ 10000 ]
sdk:
openImSdkWsPort: [ 30000 ]
cmsapi:
openImCmsApiPort: [ 8000 ]
credential:
tencent:
appID: 1302656840
region: ap-chengdu
bucket: echat-1302656840
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
rpcport:
openImUserPort: [ 10100 ]
openImFriendPort: [ 10200 ]
openImOfflineMessagePort: [ 10300]
openImOnlineRelayPort: [ 10400 ]
openImGroupPort: [ 10500 ]
openImAuthPort: [ 10600 ]
openImPushPort: [ 10700 ]
openImStatisticsPort: [ 10800 ]
openImMessageCmsPort: [ 10900 ]
openImAdminCmsPort: [ 11000 ]
rpcregistername:
openImUserName: User
openImFriendName: Friend
openImOfflineMessageName: OfflineMessage
openImPushName: Push
openImOnlineMessageRelayName: OnlineMessageRelay
openImGroupName: Group
openImAuthName: Auth
log:
storageLocation: ../logs/
rotationTime: 24
remainRotationCount: 5
remainLogLevel: 6
elasticSearchSwitch: false
elasticSearchAddr: [ 127.0.0.1:9201 ]
elasticSearchUser: ""
elasticSearchPassword: ""
modulename:
longConnSvrName: msg_gateway
msgTransferName: msg_transfer
pushName: push
longconnsvr:
openImWsPort: [ 17778 ]
websocketMaxConnNum: 10000
websocketMaxMsgLen: 4096
websocketTimeOut: 10
push:
tpns:
ios:
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
android:
accessID: 111
secretKey: 111
jpns:
appKey: cf47465a368f24c659608e7e
masterSecret: 02204efe3f3832947a236ee5
pushUrl: "https://api.jpush.cn/v3/push"
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
manager:
appManagerUid: ["openIM123456","openIM654321"]
secrets: ["openIM1","openIM2"]
secret: tuoyun
multiloginpolicy: 1
#token config
tokenpolicy:
accessSecret: "open_im_server"
# Token effective time day as a unit
accessExpire: 7
messagecallback:
callbackSwitch: false
callbackUrl: "http://www.xxx.com/msg/judge"
#TimeOut use second as unit
callbackTimeOut: 10
#---------------demo configuration---------------------#
#The following configuration items are applied to openIM Demo configuration
demoswitch: true
demo:
openImDemoPort: [ 42233 ]
alismsverify:
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
signName: OpenIM Corporation
verificationCodeTemplateCode: SMS_2268101641
superCode: 666666
mail:
title: "openIM"
senderMail: "1765567899@qq.com"
senderAuthorizationCode: "1gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_api $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_demo $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_msg_gateway $WORKDIR/main
# 创建用于挂载的几个目录,重命名可执行文件为 main,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_msg_transfer $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_push $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_rpc_auth $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_rpc_friend $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_rpc_group $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_rpc_msg $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_rpc_user $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.13
# 设置固定的项目路径
ENV WORKDIR /app
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_timer_task $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
chmod +x $WORKDIR/main
WORKDIR $WORKDIR
CMD ./main
+101
View File
@@ -0,0 +1,101 @@
version: "3.7"
networks:
openim:
external: true
services:
mysql:
networks:
- openim
image: mysql:5.7
# ports:
# #- 13306:3306
# - 23306:33060
container_name: openim_mysql
volumes:
- ./components/mysql/data:/var/lib/mysql
- /etc/localtime:/etc/localtime
environment:
MYSQL_ROOT_PASSWORD: openIM
restart: always
mongodb:
networks:
- openim
image: mongo:4.4.5-bionic
# ports:
# - 37017:27017
container_name: openim_mongo
volumes:
- ./components/mongodb/data/db:/data/db
- ./components/mongodb/data/logs:/data/logs
- ./components/mongodb/data/conf:/etc/mongo
environment:
TZ: Asia/Shanghai
# - MONGO_INITDB_ROOT_USERNAME=openIM
# - MONGO_INITDB_ROOT_PASSWORD=openIM
restart: always
redis:
networks:
- openim
image: redis:6.2.4-alpine
# ports:
# - 16379:6379
container_name: openim_redis
volumes:
- ./components/redis/data:/data
#redis config file
#- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
environment:
TZ: Asia/Shanghai
restart: always
sysctls:
net.core.somaxconn: 1024
command: redis-server --requirepass openIM --appendonly yes
zookeeper:
networks:
- openim
image: wurstmeister/zookeeper
# ports:
# - 2181:2181
container_name: openim_zookeeper
volumes:
- /etc/localtime:/etc/localtime
environment:
TZ: Asia/Shanghai
restart: always
kafka:
networks:
- openim
image: wurstmeister/kafka
container_name: openim_kafka
restart: always
environment:
TZ: Asia/Shanghai
KAFKA_BROKER_ID: 0
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
depends_on:
- zookeeper
etcd:
networks:
- openim
image: quay.io/coreos/etcd
# ports:
# - 2379:2379
# - 2380:2380
container_name: openim_etcd
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
environment:
ETCDCTL_API: 3
restart: always
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
+223
View File
@@ -0,0 +1,223 @@
version: "3.7"
networks:
openim:
external: true
services:
api:
networks:
- openim
image: openim/api
container_name: openim_api
ports:
- 10000:10000 # API,必须开
volumes:
- ./logs:/app/logs
# Dockerfile 里定义了配置文件的路径环境变量,CONFIG_NAME,默认指向了 /app/config/config.yaml
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
msg_gateway:
networks:
- openim
image: openim/msg_gateway
container_name: openim_msg_gateway
ports:
- 17778:17778 # 消息,必须开
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
msg_transfer:
networks:
- openim
image: openim/msg_transfer
container_name: openim_msg_transfer
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
push:
networks:
- openim
image: openim/push
container_name: openim_push
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
timer_task:
networks:
- openim
image: openim/timer_task
container_name: openim_timer_task
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
rpc_user:
networks:
- openim
image: openim/rpc_user
container_name: openim_rpc_user
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
logging:
driver: json-file
options:
max-size: "1g"
max-file: "2"
rpc_friend:
networks:
- openim
image: openim/rpc_friend
container_name: openim_rpc_friend
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
rpc_group:
networks:
- openim
image: openim/rpc_group
container_name: openim_rpc_group
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
rpc_auth:
networks:
- openim
image: openim/rpc_auth
container_name: openim_rpc_auth
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
rpc_msg:
networks:
- openim
image: openim/rpc_msg
container_name: openim_rpc_msg
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
# depends_on:
# - kafka
# # - mysql
# # - mongodb
# - redis
# - etcd
demo:
networks:
- openim
image: openim/demo
container_name: openim_demo
ports:
- 42233:42233
volumes:
- ./logs:/app/logs
- ./config/config.yaml:/app/config/config.yaml
- ./db/sdk:/app/db/sdk
restart: always
+30
View File
@@ -0,0 +1,30 @@
### 以docker-compose 形式单独部署
```sh
# 查看 ./Makefile ,先编译各个需要的源码到 ../bin
# win-* 表示在win平台编译位linux二进制,其实就是处理了 go env -w GOOS=linux
make win-build-all
# 得到各个二进制程序之后,打包为镜像
# 目前没有处理 Open-IM-SDK-Core ,需要的话可以自己单独处理这个模块
make image-all
# docker-compose.yaml 分成了两部分,一部分是openIM的镜像容器 openim.yaml,一部分是依赖的环境 env.yaml
# 两部分使用一个外部的网络来联通,所以首先创建用到的 network
docker network create openim --attachable=true -d bridge
# 处理openim组件需要的挂载目录,主要是处理config目录
mkdir ./config
cp ./config.example.yaml ./config/config.yaml # 修改 ./config/config.yaml 内容,比如各个依赖组件的 host
# 然后拉起env.yaml
docker-compose -f ./env.yaml up -d
# 等env 容器全部拉起成功之后,拉起openim.yaml
docker-compose -f ./openim.yaml up -d
# 查看容器运行,推荐使用下 portainer ,web查看容器情况,查看日志等等
docker container ps -a | grep openim
# 正常应该是查看api,demo等的容器日志,看到gin打印的路由日志才算是成功
```
+22 -35
View File
@@ -5,7 +5,8 @@ services:
mysql:
image: mysql:5.7
ports:
- 3306:3306
- 13306:3306
- 23306:33060
container_name: mysql
volumes:
- ./components/mysql/data:/var/lib/mysql
@@ -15,20 +16,30 @@ services:
restart: always
mongodb:
image: mongo
image: mongo:4.0
ports:
- 27017:27017
- 37017:27017
container_name: mongo
volumes:
- ./components/mongodb/data:/data/db
- ./components/mongodb/data/db:/data/db
- ./components/mongodb/data/logs:/data/logs
- ./components/mongodb/data/conf:/etc/mongo
environment:
TZ: Asia/Shanghai
- TZ=Asia/Shanghai
# cache
- wiredTigerCacheSizeGB=1
# environment:
# - MONGO_INITDB_ROOT_USERNAME=openIM
# - MONGO_INITDB_ROOT_PASSWORD=openIM
#TZ: Asia/Shanghai
restart: always
redis:
image: redis
ports:
- 6379:6379
- 16379:6379
container_name: redis
volumes:
- ./components/redis/data:/data
@@ -82,38 +93,14 @@ services:
restart: always
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
#fixme-----build from dockerfile---------
# open-im-server:
# image: open_im_server
# container_name: open-im-server
# volumes:
# - ./logs:/Open-IM-Server/logs
# - ./config/config.yaml:/Open-IM-Server/config/config.yaml
# restart: always
# build:
# context: .
# dockerfile: deploy.Dockerfile
# depends_on:
# - mysql
# - mongodb
# - redis
# - kafka
# - etcd
# network_mode: "host"
# logging:
# driver: json-file
# options:
# max-size: "1g"
# max-file: "2"
#fixme----build from docker hub------
open-im-server:
image: lyt1123/open_im_server
container_name: open-im-server
open_im_server:
image: openim/open_im_server:v2.0.7
container_name: open_im_server
volumes:
- ./logs:/Open-IM-Server/logs
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
- ./db/sdk:/Open-IM-Server/db/sdk
- ./script:/Open-IM-Server/script
restart: always
depends_on:
- kafka
Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 21 KiB

+35 -13
View File
@@ -5,43 +5,65 @@ go 1.15
require (
github.com/Shopify/sarama v1.19.0
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
github.com/alibabacloud-go/darabonba-openapi v0.1.11
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
github.com/alibabacloud-go/sts-20150401 v1.1.0
github.com/alibabacloud-go/tea v1.1.17
github.com/antonfisher/nested-logrus-formatter v1.3.0
github.com/coreos/go-semver v0.3.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/bwmarrin/snowflake v0.3.0
github.com/coreos/etcd v3.3.27+incompatible // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/frankban/quicktest v1.11.3 // indirect
github.com/fatih/structs v1.1.0
github.com/frankban/quicktest v1.14.0 // indirect
github.com/garyburd/redigo v1.6.2
github.com/gin-gonic/gin v1.7.0
github.com/go-playground/validator/v10 v10.4.1
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 v4.1.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.4.2
github.com/jinzhu/copier v0.3.4
github.com/jinzhu/gorm v1.9.16
github.com/jinzhu/now v1.1.3 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/strftime v1.0.4 // indirect
github.com/lib/pq v1.2.0 // indirect
//github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect
//github.com/livekit/server-sdk-go v0.9.1
github.com/mattn/go-sqlite3 v1.14.6 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/minio/minio-go/v7 v7.0.22
github.com/mitchellh/mapstructure v1.4.2
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/olivere/elastic/v7 v7.0.23
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
//go.etcd.io/etcd v3.3.27+incompatible
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
go.mongodb.org/mongo-driver v1.8.3
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect
google.golang.org/grpc v1.33.2
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/grpc v1.42.0
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
google.golang.org/protobuf v1.27.1
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
sigs.k8s.io/yaml v1.2.0 // indirect
)
replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
replace google.golang.org/grpc => google.golang.org/grpc v1.29.0
+812 -41
View File
File diff suppressed because it is too large Load Diff
+91
View File
@@ -0,0 +1,91 @@
package apiAuth
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/auth"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func UserRegister(c *gin.Context) {
params := api.UserRegisterReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if params.Secret != config.Config.Secret {
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
return
}
req := &rpc.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
utils.CopyStructFields(req.UserInfo, &params)
//copier.Copy(req.UserInfo, &params)
req.OperationID = params.OperationID
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := rpc.NewAuthClient(etcdConn)
reply, err := client.UserRegister(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "call rpc err ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
return
}
if reply.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "UserRegister failed ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
return
}
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
replyToken, err := client.UserToken(context.Background(), pbDataToken)
if err != nil {
log.NewError(req.OperationID, "UserToken failed ", err.Error(), pbDataToken)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
UserToken: api.UserTokenInfo{UserID: req.UserInfo.UserID, Token: replyToken.Token, ExpiredTime: replyToken.ExpiredTime}}
log.NewInfo(req.OperationID, "UserRegister return ", resp)
c.JSON(http.StatusOK, resp)
}
func UserToken(c *gin.Context) {
params := api.UserTokenReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if params.Secret != config.Config.Secret {
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
return
}
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
log.NewInfo(req.OperationID, "UserToken args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := rpc.NewAuthClient(etcdConn)
reply, err := client.UserToken(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "UserToken failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
log.NewInfo(req.OperationID, "UserRegister return ", resp)
c.JSON(http.StatusOK, resp)
}
+43
View File
@@ -0,0 +1,43 @@
package apiChat
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func DelMsg(c *gin.Context) {
var (
req api.DelMsgReq
resp api.DelMsgResp
reqPb pbCommon.DelMsgListReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
return
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
c.JSON(http.StatusOK, resp)
}
@@ -1,11 +1,11 @@
package apiChat
import (
"Open_IM/src/common/config"
"Open_IM/src/common/log"
"Open_IM/src/grpc-etcdv3/getcdv3"
pbMsg "Open_IM/src/proto/chat"
"Open_IM/src/utils"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbMsg "Open_IM/pkg/proto/chat"
"context"
"github.com/gin-gonic/gin"
"net/http"
@@ -19,7 +19,7 @@ type paramsUserNewestSeq struct {
MsgIncr int `json:"msgIncr" binding:"required"`
}
func UserGetSeq(c *gin.Context) {
func GetSeq(c *gin.Context) {
params := paramsUserNewestSeq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
@@ -27,8 +27,8 @@ func UserGetSeq(c *gin.Context) {
}
token := c.Request.Header.Get("token")
if !utils.VerifyToken(token, params.SendID) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
return
}
pbData := pbMsg.GetMaxAndMinSeqReq{}
@@ -42,7 +42,8 @@ func UserGetSeq(c *gin.Context) {
msgClient := pbMsg.NewChatClient(grpcConn)
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
if err != nil {
log.ErrorByKv("rpc call failed to getNewSeq", pbData.OperationID, "err", err, "pbData", pbData.String())
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserGetSeq rpc failed, " + err.Error()})
return
}
+68
View File
@@ -0,0 +1,68 @@
package apiChat
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
"Open_IM/pkg/proto/chat"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsUserPullMsg struct {
ReqIdentifier *int `json:"reqIdentifier" binding:"required"`
SendID string `json:"sendID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
Data struct {
SeqBegin *int64 `json:"seqBegin" binding:"required"`
SeqEnd *int64 `json:"seqEnd" binding:"required"`
}
}
type paramsUserPullMsgBySeqList struct {
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
SendID string `json:"sendID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
SeqList []uint32 `json:"seqList"`
}
func PullMsgBySeqList(c *gin.Context) {
params := paramsUserPullMsgBySeqList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
token := c.Request.Header.Get("token")
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
if err != nil {
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error(), token, params.SendID)
}
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
return
}
pbData := open_im_sdk.PullMessageBySeqListReq{}
pbData.UserID = params.SendID
pbData.OperationID = params.OperationID
pbData.SeqList = params.SeqList
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
if err != nil {
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
return
}
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"reqIdentifier": params.ReqIdentifier,
"data": reply.List,
})
}
+99
View File
@@ -0,0 +1,99 @@
package apiChat
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
pbChat "Open_IM/pkg/proto/chat"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"context"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsUserSendMsg struct {
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
SendID string `json:"sendID" binding:"required"`
SenderNickName string `json:"senderNickName"`
SenderFaceURL string `json:"senderFaceUrl"`
OperationID string `json:"operationID" binding:"required"`
Data struct {
SessionType int32 `json:"sessionType" binding:"required"`
MsgFrom int32 `json:"msgFrom" binding:"required"`
ContentType int32 `json:"contentType" binding:"required"`
RecvID string `json:"recvID" `
GroupID string `json:"groupID" `
ForceList []string `json:"forceList"`
Content []byte `json:"content" binding:"required"`
Options map[string]bool `json:"options" `
ClientMsgID string `json:"clientMsgID" binding:"required"`
CreateTime int64 `json:"createTime" binding:"required"`
OffLineInfo *open_im_sdk.OfflinePushInfo `json:"offlineInfo" `
}
}
func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.SendMsgReq {
pbData := pbChat.SendMsgReq{
Token: token,
OperationID: params.OperationID,
MsgData: &open_im_sdk.MsgData{
SendID: params.SendID,
RecvID: params.Data.RecvID,
GroupID: params.Data.GroupID,
ClientMsgID: params.Data.ClientMsgID,
SenderPlatformID: params.SenderPlatformID,
SenderNickname: params.SenderNickName,
SenderFaceURL: params.SenderFaceURL,
SessionType: params.Data.SessionType,
MsgFrom: params.Data.MsgFrom,
ContentType: params.Data.ContentType,
Content: params.Data.Content,
CreateTime: params.Data.CreateTime,
Options: params.Data.Options,
OfflinePushInfo: params.Data.OffLineInfo,
},
}
return &pbData
}
func SendMsg(c *gin.Context) {
params := paramsUserSendMsg{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
return
}
token := c.Request.Header.Get("token")
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
pbData := newUserSendMsgReq(token, &params)
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn)
log.Info("", "", "api SendMsg call, api call rpc...")
reply, err := client.SendMsg(context.Background(), pbData)
if err != nil {
log.NewError(params.OperationID, "SendMsg rpc failed, ", params, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
return
}
log.Info("", "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"data": gin.H{
"clientMsgID": reply.ClientMsgID,
"serverMsgID": reply.ServerMsgID,
"sendTime": reply.SendTime,
},
})
}
+218
View File
@@ -0,0 +1,218 @@
package conversation
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func SetConversation(c *gin.Context) {
var (
req api.SetConversationReq
resp api.SetConversationResp
reqPb pbUser.SetConversationReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
reqPb.Conversation = &pbUser.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetConversation(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func BatchSetConversations(c *gin.Context) {
var (
req api.BatchSetConversationsReq
resp api.BatchSetConversationsResp
reqPb pbUser.BatchSetConversationsReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.Data, respPb); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetAllConversations(c *gin.Context) {
var (
req api.GetAllConversationsReq
resp api.GetAllConversationsResp
reqPb pbUser.GetAllConversationsReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed, ", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetConversation(c *gin.Context) {
var (
req api.GetConversationReq
resp api.GetConversationResp
reqPb pbUser.GetConversationReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversation(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
if err := utils.CopyStructFields(&resp.Conversation, respPb.Conversation); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetConversations(c *gin.Context) {
var (
req api.GetConversationsReq
resp api.GetConversationsResp
reqPb pbUser.GetConversationsReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversations(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func SetRecvMsgOpt(c *gin.Context) {
var (
req api.SetRecvMsgOptReq
resp api.SetRecvMsgOptResp
reqPb pbUser.SetRecvMsgOptReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetRecvMsgOpt rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
//Deprecated
func SetReceiveMessageOpt(c *gin.Context) {
}
//Deprecated
func GetReceiveMessageOpt(c *gin.Context) {
}
//Deprecated
func GetAllConversationMessageOpt(c *gin.Context) {
}
+456
View File
@@ -0,0 +1,456 @@
package friend
import (
jsonData "Open_IM/internal/utils"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/friend"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func AddBlack(c *gin.Context) {
params := api.AddBlacklistReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.AddBlacklist(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "AddBlacklist failed ", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add blacklist rpc server failed"})
return
}
resp := api.AddBlacklistResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "AddBlacklist api return ", resp)
c.JSON(http.StatusOK, resp)
}
func ImportFriend(c *gin.Context) {
params := api.ImportFriendReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.ImportFriendReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.ImportFriend(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "ImportFriend failed "})
return
}
resp := api.ImportFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
if resp.ErrCode == 0 {
for _, v := range RpcResp.UserIDResultList {
resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result})
}
}
if len(resp.UserIDResultList) == 0 {
resp.UserIDResultList = []api.UserIDResult{}
}
log.NewInfo(req.OperationID, "ImportFriend api return ", resp)
c.JSON(http.StatusOK, resp)
}
func AddFriend(c *gin.Context) {
params := api.AddFriendReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.ReqMsg = params.ReqMsg
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.AddFriend(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "AddFriend failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AddFriend rpc server failed"})
return
}
resp := api.AddFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "AddFriend api return ", resp)
c.JSON(http.StatusOK, resp)
}
func AddFriendResponse(c *gin.Context) {
params := api.AddFriendResponseReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.AddFriendResponseReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.HandleMsg = params.HandleMsg
req.HandleResult = params.Flag
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
utils.CopyStructFields(req, &params)
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.AddFriendResponse(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "AddFriendResponse failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add_friend_response rpc server failed"})
return
}
resp := api.AddFriendResponseResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "AddFriendResponse api return ", resp)
c.JSON(http.StatusOK, resp)
}
func DeleteFriend(c *gin.Context) {
params := api.DeleteFriendReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.DeleteFriend(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "DeleteFriend failed ", err, req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete_friend rpc server failed"})
return
}
resp := api.DeleteFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "DeleteFriend api return ", resp)
c.JSON(http.StatusOK, resp)
}
func GetBlacklist(c *gin.Context) {
params := api.GetBlackListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.GetBlacklist(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "GetBlacklist failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get blacklist rpc server failed"})
return
}
resp := api.GetBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
for _, v := range RpcResp.BlackUserInfoList {
black := open_im_sdk.PublicUserInfo{}
utils.CopyStructFields(&black, v)
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
}
resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
c.JSON(http.StatusOK, resp)
}
func SetFriendRemark(c *gin.Context) {
params := api.SetFriendRemarkReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.Remark = params.Remark
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.SetFriendRemark(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "SetFriendComment failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call set friend comment rpc server failed"})
return
}
resp := api.SetFriendRemarkResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "SetFriendComment api return ", resp)
c.JSON(http.StatusOK, resp)
}
func RemoveBlack(c *gin.Context) {
params := api.RemoveBlackListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "RemoveBlacklist failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call remove blacklist rpc server failed"})
return
}
resp := api.RemoveBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist api return ", resp)
c.JSON(http.StatusOK, resp)
}
func IsFriend(c *gin.Context) {
params := api.IsFriendReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.IsFriend(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "IsFriend failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
return
}
resp := api.IsFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
resp.Response.Friend = RpcResp.Response
log.NewInfo(req.CommID.OperationID, "IsFriend api return ", resp)
c.JSON(http.StatusOK, resp)
}
//
//func GetFriendsInfo(c *gin.Context) {
// params := api.GetFriendsInfoReq{}
// if err := c.BindJSON(&params); err != nil {
// log.NewError("0", "BindJSON failed ", err.Error())
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
// return
// }
// req := &rpc.GetFriendsInfoReq{}
// utils.CopyStructFields(req.CommID, params)
// var ok bool
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
// if !ok {
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
// }
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
//
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
// client := rpc.NewFriendClient(etcdConn)
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
// if err != nil {
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
// return
// }
//
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
// utils.CopyStructFields(&resp, RpcResp)
// c.JSON(http.StatusOK, resp)
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
//}
func GetFriendList(c *gin.Context) {
params := api.GetFriendListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.GetFriendList(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "GetFriendList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend list rpc server failed"})
return
}
resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
c.JSON(http.StatusOK, resp)
//c.JSON(http.StatusOK, resp)
}
func GetFriendApplyList(c *gin.Context) {
params := api.GetFriendApplyListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "GetFriendApplyList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend apply list rpc server failed"})
return
}
resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
c.JSON(http.StatusOK, resp)
}
func GetSelfFriendApplyList(c *gin.Context) {
params := api.GetSelfApplyListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := rpc.NewFriendClient(etcdConn)
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
if err != nil {
log.NewError(req.CommID.OperationID, "GetSelfApplyList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get self apply list rpc server failed"})
return
}
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
c.JSON(http.StatusOK, resp)
}
+698
View File
@@ -0,0 +1,698 @@
package group
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
jsonData "Open_IM/internal/utils"
)
func KickGroupMember(c *gin.Context) {
params := api.KickGroupMemberReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.KickGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.KickGroupMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
var memberListResp api.KickGroupMemberResp
memberListResp.ErrMsg = RpcResp.ErrMsg
memberListResp.ErrCode = RpcResp.ErrCode
for _, v := range RpcResp.Id2ResultList {
memberListResp.UserIDResultList = append(memberListResp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
}
if len(memberListResp.UserIDResultList) == 0 {
memberListResp.UserIDResultList = []*api.UserIDResult{}
}
log.NewInfo(req.OperationID, "KickGroupMember api return ", memberListResp)
c.JSON(http.StatusOK, memberListResp)
}
func GetGroupMembersInfo(c *gin.Context) {
params := api.GetGroupMembersInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetGroupMembersInfoReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
//c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
api.SetErrCodeMsg(c, http.StatusInternalServerError)
return
}
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
memberListResp.Data = jsonData.JsonDataList(RpcResp.MemberList)
log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp)
c.JSON(http.StatusOK, memberListResp)
}
func GetGroupMemberList(c *gin.Context) {
params := api.GetGroupMemberListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetGroupMemberListReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetGroupMemberList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed, ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
log.NewInfo(req.OperationID, "GetGroupMemberList api return ", memberListResp)
c.JSON(http.StatusOK, memberListResp)
}
func GetGroupAllMemberList(c *gin.Context) {
params := api.GetGroupAllMemberReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetGroupAllMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupAllMember failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
c.JSON(http.StatusOK, memberListResp)
}
func GetJoinedGroupList(c *gin.Context) {
params := api.GetJoinedGroupListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetJoinedGroupListReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetJoinedGroupList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp)
c.JSON(http.StatusOK, GroupListResp)
}
func InviteUserToGroup(c *gin.Context) {
params := api.InviteUserToGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.InviteUserToGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.InviteUserToGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
for _, v := range RpcResp.Id2ResultList {
resp.UserIDResultList = append(resp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
}
if len(resp.UserIDResultList) == 0 {
resp.UserIDResultList = *new([]*api.UserIDResult)
}
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
c.JSON(http.StatusOK, resp)
}
func CreateGroup(c *gin.Context) {
params := api.CreateGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
//
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params)
for _, v := range params.MemberList {
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
}
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
req.OwnerUserID = params.OwnerUserID
req.OperationID = params.OperationID
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.CreateGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "CreateGroup failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
if RpcResp.ErrCode == 0 {
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
}
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
c.JSON(http.StatusOK, resp)
}
// 群主或管理员收到的
func GetRecvGroupApplicationList(c *gin.Context) {
params := api.GetGroupApplicationListReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetGroupApplicationListReq{}
utils.CopyStructFields(req, params)
//var ok bool
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
//}
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.GetGroupApplicationList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
c.JSON(http.StatusOK, resp)
}
func GetUserReqGroupApplicationList(c *gin.Context) {
var params api.GetUserReqGroupApplicationListReq
if err := c.BindJSON(&params); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetUserReqApplicationListReq{}
utils.CopyStructFields(req, params)
//ok, req.OpUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
//}
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.NewInfo(req.OperationID, RpcResp)
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupRequestList: RpcResp.GroupRequestList}
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
c.JSON(http.StatusOK, resp)
}
func GetGroupsInfo(c *gin.Context) {
params := api.GetGroupInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetGroupsInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
//process application
func ApplicationGroupResponse(c *gin.Context) {
params := api.ApplicationGroupResponseReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GroupApplicationResponseReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.GroupApplicationResponse(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GroupApplicationResponse failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.ApplicationGroupResponseResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, "ApplicationGroupResponse api return ", resp)
c.JSON(http.StatusOK, resp)
}
func JoinGroup(c *gin.Context) {
params := api.JoinGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.JoinGroupReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.JoinGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "JoinGroup failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
log.NewInfo(req.OperationID, "JoinGroup api return", RpcResp.String())
c.JSON(http.StatusOK, resp)
}
func QuitGroup(c *gin.Context) {
params := api.QuitGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.QuitGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.QuitGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "call quit group rpc server failed,err=%s", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
log.NewInfo(req.OperationID, "QuitGroup api return", RpcResp.String())
c.JSON(http.StatusOK, resp)
}
func SetGroupInfo(c *gin.Context) {
params := api.SetGroupInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params)
req.OperationID = params.OperationID
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.SetGroupInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.SetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
c.JSON(http.StatusOK, resp)
log.NewInfo(req.OperationID, "SetGroupInfo api return ", resp)
}
func TransferGroupOwner(c *gin.Context) {
params := api.TransferGroupOwnerReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.TransferGroupOwnerReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.TransferGroupOwner(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "TransferGroupOwner failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.TransferGroupOwnerResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp)
c.JSON(http.StatusOK, resp)
}
func DismissGroup(c *gin.Context) {
params := api.DismissGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.DismissGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.DismissGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.DismissGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func MuteGroupMember(c *gin.Context) {
params := api.MuteGroupMemberReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.MuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.MuteGroupMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.MuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func CancelMuteGroupMember(c *gin.Context) {
params := api.CancelMuteGroupMemberReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.CancelMuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.CancelMuteGroupMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func MuteGroup(c *gin.Context) {
params := api.MuteGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.MuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.MuteGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.MuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func CancelMuteGroup(c *gin.Context) {
params := api.CancelMuteGroupReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.CancelMuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.CancelMuteGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.CancelMuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
+296
View File
@@ -0,0 +1,296 @@
/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/9/15 15:23).
*/
package manage
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
"Open_IM/pkg/proto/sdk_ws"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"github.com/golang/protobuf/proto"
"github.com/mitchellh/mapstructure"
"net/http"
"strings"
)
var validate *validator.Validate
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
var newContent string
var err error
switch params.ContentType {
case constant.Text:
newContent = params.Content["text"].(string)
case constant.Picture:
fallthrough
case constant.Custom:
fallthrough
case constant.Voice:
fallthrough
case constant.File:
newContent = utils.StructToJsonString(params.Content)
case constant.Revoke:
newContent = params.Content["revokeMsgClientID"].(string)
default:
}
var options map[string]bool
if params.IsOnlineOnly {
options = make(map[string]bool, 5)
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
utils.SetSwitchFromOptions(options, constant.IsSenderSync, false)
}
pbData := pbChat.SendMsgReq{
OperationID: params.OperationID,
MsgData: &open_im_sdk.MsgData{
SendID: params.SendID,
RecvID: params.RecvID,
GroupID: params.GroupID,
ClientMsgID: utils.GetMsgID(params.SendID),
SenderPlatformID: params.SenderPlatformID,
SenderNickname: params.SenderNickname,
SenderFaceURL: params.SenderFaceURL,
SessionType: params.SessionType,
MsgFrom: constant.SysMsgType,
ContentType: params.ContentType,
Content: []byte(newContent),
// ForceList: params.ForceList,
CreateTime: utils.GetCurrentTimestampByMill(),
Options: options,
OfflinePushInfo: params.OfflinePushInfo,
},
}
if params.ContentType == constant.OANotification {
var tips open_im_sdk.TipsComm
tips.JsonDetail = utils.StructToJsonString(params.Content)
pbData.MsgData.Content, err = proto.Marshal(&tips)
if err != nil {
log.Error(params.OperationID, "Marshal failed ", err.Error(), tips.String())
}
}
return &pbData
}
func init() {
validate = validator.New()
}
func ManagementSendMsg(c *gin.Context) {
var data interface{}
params := ManagementSendMsgReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
return
}
switch params.ContentType {
case constant.Text:
data = TextElem{}
case constant.Picture:
data = PictureElem{}
case constant.Voice:
data = SoundElem{}
case constant.Video:
data = VideoElem{}
case constant.File:
data = FileElem{}
//case constant.AtText:
// data = AtElem{}
//case constant.Merger:
// data =
//case constant.Card:
//case constant.Location:
case constant.Custom:
data = CustomElem{}
case constant.Revoke:
data = RevokeElem{}
case constant.OANotification:
data = OANotificationElem{}
params.SessionType = constant.NotificationChatType
//case constant.HasReadReceipt:
//case constant.Typing:
//case constant.Quote:
default:
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
return
}
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
return
} else if err := validate.Struct(data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
log.ErrorByKv("data args validate err", "", "err", err.Error())
return
}
log.NewInfo("", data, params)
token := c.Request.Header.Get("token")
claims, err := token_verify.ParseToken(token, params.OperationID)
if err != nil {
log.NewError(params.OperationID, "parse token failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
return
}
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
return
}
switch params.SessionType {
case constant.SingleChatType:
if len(params.RecvID) == 0 {
log.NewError(params.OperationID, "recvID is a null string")
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
return
}
case constant.GroupChatType:
if len(params.GroupID) == 0 {
log.NewError(params.OperationID, "groupID is a null string")
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
return
}
}
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
pbData := newUserSendMsgReq(&params)
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn)
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
RpcResp, err := client.SendMsg(context.Background(), pbData)
if err != nil {
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
return
}
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
log.Info(params.OperationID, "ManagementSendMsg return", resp)
c.JSON(http.StatusOK, resp)
}
//
//type MergeElem struct {
// Title string `json:"title"`
// AbstractList []string `json:"abstractList"`
// MultiMessage []*MsgStruct `json:"multiMessage"`
//}
//
//type QuoteElem struct {
// Text string `json:"text"`
// QuoteMessage *MsgStruct `json:"quoteMessage"`
//}
type ManagementSendMsgReq struct {
OperationID string `json:"operationID" binding:"required"`
SendID string `json:"sendID" binding:"required"`
RecvID string `json:"recvID" `
GroupID string `json:"groupID" `
SenderNickname string `json:"senderNickname" `
SenderFaceURL string `json:"senderFaceURL" `
SenderPlatformID int32 `json:"senderPlatformID"`
ForceList []string `json:"forceList" `
Content map[string]interface{} `json:"content" binding:"required"`
ContentType int32 `json:"contentType" binding:"required"`
SessionType int32 `json:"sessionType" binding:"required"`
IsOnlineOnly bool `json:"isOnlineOnly"`
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
}
type PictureBaseInfo struct {
UUID string `mapstructure:"uuid"`
Type string `mapstructure:"type" `
Size int64 `mapstructure:"size" `
Width int32 `mapstructure:"width" `
Height int32 `mapstructure:"height"`
Url string `mapstructure:"url" `
}
type PictureElem struct {
SourcePath string `mapstructure:"sourcePath"`
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
}
type SoundElem struct {
UUID string `mapstructure:"uuid"`
SoundPath string `mapstructure:"soundPath"`
SourceURL string `mapstructure:"sourceUrl"`
DataSize int64 `mapstructure:"dataSize"`
Duration int64 `mapstructure:"duration"`
}
type VideoElem struct {
VideoPath string `mapstructure:"videoPath"`
VideoUUID string `mapstructure:"videoUUID"`
VideoURL string `mapstructure:"videoUrl"`
VideoType string `mapstructure:"videoType"`
VideoSize int64 `mapstructure:"videoSize"`
Duration int64 `mapstructure:"duration"`
SnapshotPath string `mapstructure:"snapshotPath"`
SnapshotUUID string `mapstructure:"snapshotUUID"`
SnapshotSize int64 `mapstructure:"snapshotSize"`
SnapshotURL string `mapstructure:"snapshotUrl"`
SnapshotWidth int32 `mapstructure:"snapshotWidth"`
SnapshotHeight int32 `mapstructure:"snapshotHeight"`
}
type FileElem struct {
FilePath string `mapstructure:"filePath"`
UUID string `mapstructure:"uuid"`
SourceURL string `mapstructure:"sourceUrl"`
FileName string `mapstructure:"fileName"`
FileSize int64 `mapstructure:"fileSize"`
}
type AtElem struct {
Text string `mapstructure:"text"`
AtUserList []string `mapstructure:"atUserList"`
IsAtSelf bool `mapstructure:"isAtSelf"`
}
type LocationElem struct {
Description string `mapstructure:"description"`
Longitude float64 `mapstructure:"longitude"`
Latitude float64 `mapstructure:"latitude"`
}
type CustomElem struct {
Data string `mapstructure:"data" validate:"required"`
Description string `mapstructure:"description"`
Extension string `mapstructure:"extension"`
}
type TextElem struct {
Text string `mapstructure:"text" validate:"required"`
}
type RevokeElem struct {
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
}
type OANotificationElem struct {
NotificationName string `mapstructure:"notificationName" validate:"required"`
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
Text string `mapstructure:"text" validate:"required"`
Url string `mapstructure:"url"`
MixType int32 `mapstructure:"mixType"`
PictureElem PictureElem `mapstructure:"pictureElem"`
SoundElem SoundElem `mapstructure:"soundElem"`
VideoElem VideoElem `mapstructure:"videoElem"`
FileElem FileElem `mapstructure:"fileElem"`
Ex string `mapstructure:"ex"`
}
+180
View File
@@ -0,0 +1,180 @@
/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/9/15 10:28).
*/
package manage
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbRelay "Open_IM/pkg/proto/relay"
rpc "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func DeleteUser(c *gin.Context) {
params := api.DeleteUsersReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.DeleteUsersReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.DeleteUsers(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
return
}
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
if len(RpcResp.FailedUserIDList) == 0 {
resp.FailedUserIDList = []string{}
}
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
c.JSON(http.StatusOK, resp)
}
func GetAllUsersUid(c *gin.Context) {
params := api.GetAllUsersUidReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.GetAllUserIDReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.GetAllUserID(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "call GetAllUsersUid users rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call GetAllUsersUid users rpc server failed"})
return
}
resp := api.GetAllUsersUidResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserIDList: RpcResp.UserIDList}
if len(RpcResp.UserIDList) == 0 {
resp.UserIDList = []string{}
}
log.NewInfo(req.OperationID, "GetAllUsersUid api return", resp)
c.JSON(http.StatusOK, resp)
}
func AccountCheck(c *gin.Context) {
params := api.AccountCheckReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.AccountCheckReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.AccountCheck(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "call AccountCheck users rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AccountCheck users rpc server failed"})
return
}
resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ResultList: RpcResp.ResultList}
if len(RpcResp.ResultList) == 0 {
resp.ResultList = []*rpc.AccountCheckResp_SingleUserStatus{}
}
log.NewInfo(req.OperationID, "AccountCheck api return", resp)
c.JSON(http.StatusOK, resp)
}
func GetUsersOnlineStatus(c *gin.Context) {
params := api.GetUsersOnlineStatusReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbRelay.GetUsersOnlineStatusReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
flag := false
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
for _, v := range grpcCons {
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
if err != nil {
log.NewError(params.OperationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
continue
} else {
if reply.ErrCode == 0 {
wsResult = append(wsResult, reply.SuccessResult...)
}
}
}
log.NewInfo(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
//Online data merge of each node
for _, v1 := range params.UserIDList {
flag = false
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
for _, v2 := range wsResult {
if v2.UserID == v1 {
flag = true
temp.UserID = v1
temp.Status = constant.OnlineStatus
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, v2.DetailPlatformStatus...)
}
}
if !flag {
temp.UserID = v1
temp.Status = constant.OfflineStatus
}
respResult = append(respResult, temp)
}
resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, SuccessResult: respResult}
if len(respResult) == 0 {
resp.SuccessResult = []*pbRelay.GetUsersOnlineStatusResp_SuccessResult{}
}
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
c.JSON(http.StatusOK, resp)
}
+280
View File
@@ -0,0 +1,280 @@
package office
import (
apistruct "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbOffice "Open_IM/pkg/proto/office"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func GetUserTags(c *gin.Context) {
var (
req apistruct.GetUserTagsReq
resp apistruct.GetUserTagsResp
reqPb pbOffice.GetUserTagsReq
respPb *pbOffice.GetUserTagsResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetUserTags(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserTags rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
if respPb.Tags != nil {
resp.Data.Tags = respPb.Tags
} else {
resp.Data.Tags = []*pbOffice.Tag{}
}
c.JSON(http.StatusOK, resp)
}
func CreateTag(c *gin.Context) {
var (
req apistruct.CreateTagReq
resp apistruct.CreateTagResp
reqPb pbOffice.CreateTagReq
respPb *pbOffice.CreateTagResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.CreateTag(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
c.JSON(http.StatusOK, resp)
}
func DeleteTag(c *gin.Context) {
var (
req apistruct.DeleteTagReq
resp apistruct.DeleteTagResp
reqPb pbOffice.DeleteTagReq
respPb *pbOffice.DeleteTagResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.DeleteTag(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
c.JSON(http.StatusOK, resp)
}
func SetTag(c *gin.Context) {
var (
req apistruct.SetTagReq
resp apistruct.SetTagResp
reqPb pbOffice.SetTagReq
respPb *pbOffice.SetTagResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.SetTag(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
c.JSON(http.StatusOK, resp)
}
func SendMsg2Tag(c *gin.Context) {
var (
req apistruct.SendMsg2TagReq
resp apistruct.SendMsg2TagResp
reqPb pbOffice.SendMsg2TagReq
respPb *pbOffice.SendMsg2TagResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.SendID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
c.JSON(http.StatusOK, resp)
}
func GetTagSendLogs(c *gin.Context) {
var (
req apistruct.GetTagSendLogsReq
resp apistruct.GetTagSendLogsResp
reqPb pbOffice.GetTagSendLogsReq
respPb *pbOffice.GetTagSendLogsResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
ShowNumber: req.ShowNumber,
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
if respPb.TagSendLogs != nil {
resp.Data.Logs = respPb.TagSendLogs
} else {
resp.Data.Logs = []*pbOffice.TagSendLog{}
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
c.JSON(http.StatusOK, resp)
}
func GetUserTagByID(c *gin.Context) {
var (
req apistruct.GetUserTagByIDReq
resp apistruct.GetUserTagByIDResp
reqPb pbOffice.GetUserTagByIDReq
respPb *pbOffice.GetUserTagByIDResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.TagID = req.TagID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTagByID failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.Tag = respPb.Tag
c.JSON(http.StatusOK, resp)
}
+95
View File
@@ -0,0 +1,95 @@
package apiThird
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"fmt"
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
sts20150401 "github.com/alibabacloud-go/sts-20150401/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/fatih/structs"
//"github.com/fatih/structs"
"github.com/gin-gonic/gin"
"net/http"
"time"
)
var stsClient *sts20150401.Client
/**
* 使用AK&SK初始化账号Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
func getStsClient() *sts20150401.Client {
if stsClient != nil {
return stsClient
}
conf := &openapi.Config{
// 您的AccessKey ID
AccessKeyId: tea.String(config.Config.Credential.Ali.AccessKeyID),
// 您的AccessKey Secret
AccessKeySecret: tea.String(config.Config.Credential.Ali.AccessKeySecret),
// Endpoint
Endpoint: tea.String(config.Config.Credential.Ali.StsEndpoint),
}
result, err := sts20150401.NewClient(conf)
if err != nil {
log.NewError("", "alists client初始化失败 ", err)
}
stsClient = result
return stsClient
}
func AliOSSCredential(c *gin.Context) {
req := api.OSSCredentialReq{}
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
DurationSeconds: tea.Int64(config.Config.Credential.Ali.StsDurationSeconds),
Policy: nil,
RoleArn: tea.String(config.Config.Credential.Ali.OssRoleArn),
RoleSessionName: tea.String(fmt.Sprintf("%s-%d", userID, time.Now().Unix())),
})
resp := api.OSSCredentialResp{}
if err != nil {
resp.ErrCode = constant.ErrTencentCredential.ErrCode
resp.ErrMsg = err.Error()
} else {
resp = api.OSSCredentialResp{
CommResp: api.CommResp{},
OssData: api.OSSCredentialRespData{
Endpoint: config.Config.Credential.Ali.OssEndpoint,
AccessKeyId: *stsResp.Body.Credentials.AccessKeyId,
AccessKeySecret: *stsResp.Body.Credentials.AccessKeySecret,
Token: *stsResp.Body.Credentials.SecurityToken,
Bucket: config.Config.Credential.Ali.Bucket,
FinalHost: config.Config.Credential.Ali.FinalHost,
},
Data: nil,
}
}
resp.Data = structs.Map(&resp.OssData)
log.NewInfo(req.OperationID, "AliOSSCredential return ", resp)
c.JSON(http.StatusOK, resp)
}
+60
View File
@@ -0,0 +1,60 @@
package apiThird
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"context"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
url2 "net/url"
)
var (
minioClient *minio.Client
)
func MinioInit() {
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
Secure: false,
})
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
return
}
opt := minio.MakeBucketOptions{
Region: config.Config.Credential.Minio.Location,
ObjectLocking: false,
}
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return
}
}
// 自动化桶public的代码
//err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
//if err != nil {
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
// return
//}
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
}
@@ -0,0 +1,132 @@
package apiThird
import (
apiStruct "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
_ "Open_IM/pkg/common/token_verify"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"github.com/minio/minio-go/v7"
_ "github.com/minio/minio-go/v7"
cr "github.com/minio/minio-go/v7/pkg/credentials"
"net/http"
)
func MinioUploadFile(c *gin.Context) {
var (
req apiStruct.MinioUploadFileReq
resp apiStruct.MinioUploadFileResp
)
defer func() {
if r := recover(); r != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), r)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file or snapShot args"})
return
}
}()
if err := c.Bind(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
switch req.FileType {
// videoType upload snapShot
case constant.VideoType:
snapShotFile, err := c.FormFile("snapShot")
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing snapshot arg: " + err.Error()})
return
}
snapShotFileObj, err := snapShotFile.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
resp.SnapshotURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + snapShotNewName
resp.SnapshotNewName = snapShotNewName
}
file, err := c.FormFile("file")
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
return
}
fileObj, err := file.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
return
}
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
return
}
resp.NewName = newName
resp.URL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + newName
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
return
}
func MinioStorageCredential(c *gin.Context) {
var (
req apiStruct.MinioStorageCredentialReq
resp apiStruct.MiniostorageCredentialResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
var stsOpts cr.STSAssumeRoleOptions
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
stsOpts.DurationSeconds = constant.MinioDurationTimes
li, err := cr.NewSTSAssumeRole(config.Config.Credential.Minio.Endpoint, stsOpts)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
v, err := li.Get()
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), "li.Get error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
resp.SessionToken = v.SessionToken
resp.SecretAccessKey = v.SecretAccessKey
resp.AccessKeyID = v.AccessKeyID
resp.BucketName = config.Config.Credential.Minio.Bucket
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
}
@@ -0,0 +1,72 @@
package apiThird
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"github.com/fatih/structs"
//"github.com/fatih/structs"
"github.com/gin-gonic/gin"
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
"net/http"
"time"
)
func TencentCloudStorageCredential(c *gin.Context) {
req := api.TencentCloudStorageCredentialReq{}
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
cli := sts.NewClient(
config.Config.Credential.Tencent.SecretID,
config.Config.Credential.Tencent.SecretKey,
nil,
)
opt := &sts.CredentialOptions{
DurationSeconds: int64(time.Hour.Seconds()),
Region: config.Config.Credential.Tencent.Region,
Policy: &sts.CredentialPolicy{
Statement: []sts.CredentialPolicyStatement{
{
Action: []string{
"name/cos:PostObject",
"name/cos:PutObject",
},
Effect: "allow",
Resource: []string{
"qcs::cos:" + config.Config.Credential.Tencent.Region + ":uid/" + config.Config.Credential.Tencent.AppID + ":" + config.Config.Credential.Tencent.Bucket + "/*",
},
},
},
},
}
res, err := cli.GetCredential(opt)
resp := api.TencentCloudStorageCredentialResp{}
if err != nil {
resp.ErrCode = constant.ErrTencentCredential.ErrCode
resp.ErrMsg = err.Error()
} else {
resp.CosData.Bucket = config.Config.Credential.Tencent.Bucket
resp.CosData.Region = config.Config.Credential.Tencent.Region
resp.CosData.CredentialResult = res
}
resp.Data = structs.Map(&resp.CosData)
log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp)
c.JSON(http.StatusOK, resp)
}
+129
View File
@@ -0,0 +1,129 @@
package user
import (
jsonData "Open_IM/internal/utils"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
rpc "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func GetUsersInfo(c *gin.Context) {
params := api.GetUsersInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.GetUserInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
var publicUserInfoList []*open_im_sdk.PublicUserInfo
for _, v := range RpcResp.UserInfoList {
publicUserInfoList = append(publicUserInfoList,
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
}
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
func UpdateUserInfo(c *gin.Context) {
params := api.UpdateSelfUserInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
utils.CopyStructFields(req.UserInfo, &params)
req.OperationID = params.OperationID
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
func GetSelfUserInfo(c *gin.Context) {
params := api.GetSelfUserInfoReq{}
if err := c.BindJSON(&params); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
req.UserIDList = append(req.UserIDList, req.OpUserID)
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.GetUserInfo(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
if len(RpcResp.UserInfoList) == 1 {
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfo: RpcResp.UserInfoList[0]}
resp.Data = jsonData.JsonDataOne(resp.UserInfo)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
} else {
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
}
+42
View File
@@ -0,0 +1,42 @@
package admin
import (
"Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbAdmin "Open_IM/pkg/proto/admin_cms"
"Open_IM/pkg/utils"
"context"
"strings"
"github.com/gin-gonic/gin"
)
// register
func AdminLogin(c *gin.Context) {
var (
req cms_api_struct.AdminLoginRequest
resp cms_api_struct.AdminLoginResponse
reqPb pbAdmin.AdminLoginReq
)
if err := c.BindJSON(&req); err != nil {
log.NewInfo("0", utils.GetSelfFuncName(), err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.Secret = req.Secret
reqPb.AdminID = req.AdminName
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName)
client := pbAdmin.NewAdminCMSClient(etcdConn)
respPb, err := client.AdminLogin(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.Token = respPb.Token
openIMHttp.RespHttp200(c, constant.OK, resp)
}
+450
View File
@@ -0,0 +1,450 @@
package group
import (
"Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"strings"
pbGroup "Open_IM/pkg/proto/group"
"github.com/gin-gonic/gin"
)
func GetGroupById(c *gin.Context) {
var (
req cms_api_struct.GetGroupByIdRequest
resp cms_api_struct.GetGroupByIdResponse
reqPb pbGroup.GetGroupByIdReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.GetGroupById(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupById failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.GroupName = respPb.CMSGroup.GroupInfo.GroupName
resp.GroupID = respPb.CMSGroup.GroupInfo.GroupID
resp.CreateTime = (utils.UnixSecondToTime(int64(respPb.CMSGroup.GroupInfo.CreateTime))).String()
resp.ProfilePhoto = respPb.CMSGroup.GroupInfo.FaceURL
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetGroups(c *gin.Context) {
var (
req cms_api_struct.GetGroupsRequest
resp cms_api_struct.GetGroupsResponse
reqPb pbGroup.GetGroupsReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.GetGroups(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
for _, v := range respPb.CMSGroups {
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
GroupName: v.GroupInfo.GroupName,
GroupID: v.GroupInfo.GroupID,
GroupMasterName: v.GroupMasterName,
GroupMasterId: v.GroupMasterId,
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
IsBanPrivateChat: false,
ProfilePhoto: v.GroupInfo.FaceURL,
})
}
resp.GroupNums = int(respPb.GroupNum)
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetGroupByName(c *gin.Context) {
var (
req cms_api_struct.GetGroupRequest
resp cms_api_struct.GetGroupResponse
reqPb pbGroup.GetGroupReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupName = req.GroupName
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.GetGroup(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroup failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
return
}
for _, v := range respPb.CMSGroups {
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
GroupName: v.GroupInfo.GroupName,
GroupID: v.GroupInfo.GroupID,
GroupMasterName: v.GroupMasterName,
GroupMasterId: v.GroupMasterId,
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
IsBanPrivateChat: false,
ProfilePhoto: v.GroupInfo.FaceURL,
})
}
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.GroupNums = int(respPb.GroupNums)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func CreateGroup(c *gin.Context) {
var (
req cms_api_struct.CreateGroupRequest
_ cms_api_struct.CreateGroupResponse
reqPb pbGroup.CreateGroupReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupInfo = &commonPb.GroupInfo{}
reqPb.GroupInfo.GroupName = req.GroupName
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
reqPb.OwnerUserID = req.GroupMasterId
reqPb.OpUserID = req.GroupMasterId
for _, v := range req.GroupMembers {
reqPb.InitMemberList = append(reqPb.InitMemberList, &pbGroup.GroupAddMemberInfo{
UserID: v,
RoleLevel: 1,
})
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.CreateGroup(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "CreateGroup failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func BanGroupChat(c *gin.Context) {
var (
req cms_api_struct.BanGroupChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BanGroupChat failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func BanPrivateChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanPrivateChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func OpenGroupChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func OpenPrivateChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OpenPrivateChat failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func GetGroupMembers(c *gin.Context) {
var (
req cms_api_struct.GetGroupMembersRequest
reqPb pbGroup.GetGroupMembersCMSReq
resp cms_api_struct.GetGroupMembersResponse
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.Pagination = &commonPb.RequestPagination{
PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber),
}
reqPb.GroupId = req.GroupId
reqPb.UserName = req.UserName
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.ResponsePagination = cms_api_struct.ResponsePagination{
CurrentPage: int(respPb.Pagination.CurrentPage),
ShowNumber: int(respPb.Pagination.ShowNumber),
}
resp.MemberNums = int(respPb.MemberNums)
for _, groupMembers := range respPb.Members {
resp.GroupMembers = append(resp.GroupMembers, cms_api_struct.GroupMemberResponse{
MemberPosition: int(groupMembers.RoleLevel),
MemberNickName: groupMembers.Nickname,
MemberId: groupMembers.UserID,
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
})
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func AddGroupMembers(c *gin.Context) {
var (
req cms_api_struct.RemoveGroupMembersRequest
resp cms_api_struct.RemoveGroupMembersResponse
reqPb pbGroup.AddGroupMembersCMSReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func RemoveGroupMembers(c *gin.Context) {
var (
req cms_api_struct.RemoveGroupMembersRequest
resp cms_api_struct.RemoveGroupMembersResponse
reqPb pbGroup.RemoveGroupMembersCMSReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "RemoveGroupMembersCMS failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func DeleteGroup(c *gin.Context) {
var (
req cms_api_struct.DeleteGroupRequest
_ cms_api_struct.DeleteGroupResponse
reqPb pbGroup.DeleteGroupReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.DeleteGroup(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func SetGroupMaster(c *gin.Context) {
var (
req cms_api_struct.SetGroupMasterRequest
_ cms_api_struct.SetGroupMasterResponse
reqPb pbGroup.OperateUserRoleReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOwner
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateUserRole(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func SetGroupOrdinaryUsers(c *gin.Context) {
var (
req cms_api_struct.SetGroupMemberRequest
_ cms_api_struct.AdminLoginResponse
reqPb pbGroup.OperateUserRoleReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOrdinaryUsers
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateUserRole(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func AlterGroupInfo(c *gin.Context) {
var (
req cms_api_struct.AlterGroupInfoRequest
_ cms_api_struct.SetGroupMasterResponse
reqPb pbGroup.SetGroupInfoReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.OpUserID = c.MustGet("userID").(string)
reqPb.GroupInfo = &commonPb.GroupInfo{
GroupID: req.GroupID,
GroupName: req.GroupName,
Introduction: req.Introduction,
Notification: req.Notification,
FaceURL: req.ProfilePhoto,
GroupType: int32(req.GroupType),
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.SetGroupInfo(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
+109
View File
@@ -0,0 +1,109 @@
package messageCMS
import (
"Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbMessage "Open_IM/pkg/proto/message_cms"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"strings"
"Open_IM/pkg/common/constant"
"github.com/gin-gonic/gin"
)
func BroadcastMessage(c *gin.Context) {
var (
reqPb pbMessage.BoradcastMessageReq
)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
_, err := client.BoradcastMessage(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func MassSendMassage(c *gin.Context) {
var (
reqPb pbMessage.MassSendMessageReq
)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
_, err := client.MassSendMessage(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func WithdrawMessage(c *gin.Context) {
var (
reqPb pbMessage.WithdrawMessageReq
)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
_, err := client.WithdrawMessage(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func GetChatLogs(c *gin.Context) {
var (
req cms_api_struct.GetChatLogsRequest
resp cms_api_struct.GetChatLogsResponse
reqPb pbMessage.GetChatLogsReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber),
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
openIMHttp.RespHttp200(c, err, resp)
return
}
//utils.CopyStructFields(&resp, &respPb)
for _, chatLog := range respPb.ChatLogs {
resp.ChatLogs = append(resp.ChatLogs, cms_api_struct.ChatLog{
SessionType: int(chatLog.SessionType),
ContentType: int(chatLog.ContentType),
SenderNickName: chatLog.SenderNickName,
SenderId: chatLog.SenderId,
SearchContent: chatLog.SearchContent,
WholeContent: chatLog.WholeContent,
ReceiverNickName: chatLog.ReciverNickName,
ReceiverID: chatLog.ReciverId,
GroupName: chatLog.GroupName,
GroupId: chatLog.GroupId,
Date: chatLog.Date,
})
}
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.ChatLogsNum = int(respPb.ChatLogsNum)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
+23
View File
@@ -0,0 +1,23 @@
package middleware
import (
"github.com/gin-gonic/gin"
"net/http"
)
func CorsHandler() gin.HandlerFunc {
return func(context *gin.Context) {
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
context.Header("Access-Control-Allow-Methods", "*")
context.Header("Access-Control-Allow-Headers", "*")
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
context.Header("content-type", "application/json") // 设置返回格式是json
//Release all option pre-requests
if context.Request.Method == http.MethodOptions {
context.JSON(http.StatusOK, "Options Request!")
}
context.Next()
}
}
+24
View File
@@ -0,0 +1,24 @@
package middleware
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/utils"
"github.com/gin-gonic/gin"
)
func JWTAuth() gin.HandlerFunc {
return func(c *gin.Context) {
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
c.Set("userID", userID)
if !ok {
log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.Abort()
http.RespHttp200(c, constant.ErrParseToken, nil)
return
}
}
}
@@ -0,0 +1,49 @@
package organization
import (
"github.com/gin-gonic/gin"
)
func GetStaffs(c *gin.Context) {
}
func GetOrganizations(c *gin.Context) {
}
func GetSquads(c *gin.Context) {
}
func AlterStaff(c *gin.Context) {
}
func AddOrganization(c *gin.Context) {
}
func InquireOrganization(g *gin.Context) {
}
func AlterOrganization(c *gin.Context) {
}
func DeleteOrganization(g *gin.Context) {
}
func GetOrganizationSquads(c *gin.Context) {
}
func AlterStaffsInfo(c *gin.Context) {
}
func AddChildOrganization(c *gin.Context) {
}
+95
View File
@@ -0,0 +1,95 @@
package cms_api
import (
"Open_IM/internal/cms_api/admin"
"Open_IM/internal/cms_api/group"
messageCMS "Open_IM/internal/cms_api/message_cms"
"Open_IM/internal/cms_api/middleware"
"Open_IM/internal/cms_api/organization"
"Open_IM/internal/cms_api/statistics"
"Open_IM/internal/cms_api/user"
"github.com/gin-gonic/gin"
)
func NewGinRouter() *gin.Engine {
gin.SetMode(gin.ReleaseMode)
baseRouter := gin.Default()
router := baseRouter.Group("/api")
router.Use(middleware.CorsHandler())
adminRouterGroup := router.Group("/admin")
{
adminRouterGroup.POST("/login", admin.AdminLogin)
}
r2 := router.Group("")
r2.Use(middleware.JWTAuth())
statisticsRouterGroup := r2.Group("/statistics")
{
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
statisticsRouterGroup.GET("/get_group_statistics", statistics.GetGroupStatistics)
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
}
organizationRouterGroup := r2.Group("/organization")
{
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
organizationRouterGroup.GET("/get_squad", organization.GetSquads)
organizationRouterGroup.POST("/add_organization", organization.AddOrganization)
organizationRouterGroup.POST("/alter_staff", organization.AlterStaff)
organizationRouterGroup.GET("/inquire_organization", organization.InquireOrganization)
organizationRouterGroup.POST("/alter_organization", organization.AlterOrganization)
organizationRouterGroup.POST("/delete_organization", organization.DeleteOrganization)
organizationRouterGroup.POST("/get_organization_squad", organization.GetOrganizationSquads)
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
}
groupRouterGroup := r2.Group("/group")
{
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
groupRouterGroup.GET("/get_groups", group.GetGroups)
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
groupRouterGroup.GET("/get_group_members", group.GetGroupMembers)
groupRouterGroup.POST("/create_group", group.CreateGroup)
groupRouterGroup.POST("/add_members", group.AddGroupMembers)
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
groupRouterGroup.POST("/delete_group", group.DeleteGroup)
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
groupRouterGroup.POST("/set_group_master", group.SetGroupMaster)
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
}
userRouterGroup := r2.Group("/user")
{
userRouterGroup.POST("/resign", user.ResignUser)
userRouterGroup.GET("/get_user", user.GetUserById)
userRouterGroup.POST("/alter_user", user.AlterUser)
userRouterGroup.GET("/get_users", user.GetUsers)
userRouterGroup.POST("/add_user", user.AddUser)
userRouterGroup.POST("/unblock_user", user.UnblockUser)
userRouterGroup.POST("/block_user", user.BlockUser)
userRouterGroup.GET("/get_block_users", user.GetBlockUsers)
userRouterGroup.GET("/get_block_user", user.GetBlockUserById)
userRouterGroup.POST("/delete_user", user.DeleteUser)
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
}
friendRouterGroup := r2.Group("/friend")
{
friendRouterGroup.POST("/get_friends_by_id")
friendRouterGroup.POST("/set_friend")
friendRouterGroup.POST("/remove_friend")
}
messageCMSRouterGroup := r2.Group("/message")
{
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
messageCMSRouterGroup.POST("/broadcast_message", messageCMS.BroadcastMessage)
messageCMSRouterGroup.POST("/mass_send_message", messageCMS.MassSendMassage)
messageCMSRouterGroup.POST("/withdraw_message", messageCMS.WithdrawMessage)
}
return baseRouter
}
+224
View File
@@ -0,0 +1,224 @@
package statistics
import (
"Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/statistics"
"Open_IM/pkg/utils"
"context"
"strings"
"github.com/gin-gonic/gin"
)
func GetMessagesStatistics(c *gin.Context) {
var (
req cms_api_struct.GetMessageStatisticsRequest
resp cms_api_struct.GetMessageStatisticsResponse
reqPb pb.GetMessageStatisticsReq
)
reqPb.StatisticsReq = &pb.StatisticsReq{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
openIMHttp.RespHttp200(c, err, resp)
return
}
// utils.CopyStructFields(&resp, respPb)
resp.GroupMessageNum = int(respPb.GroupMessageNum)
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
for _, v := range respPb.PrivateMessageNumList {
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
Date string "json:\"date\""
MessageNum int "json:\"message_num\""
}{
Date: v.Date,
MessageNum: int(v.Num),
})
}
for _, v := range respPb.GroupMessageNumList {
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
Date string "json:\"date\""
MessageNum int "json:\"message_num\""
}{
Date: v.Date,
MessageNum: int(v.Num),
})
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetUserStatistics(c *gin.Context) {
var (
req cms_api_struct.GetUserStatisticsRequest
resp cms_api_struct.GetUserStatisticsResponse
reqPb pb.GetUserStatisticsReq
)
reqPb.StatisticsReq = &pb.StatisticsReq{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
// utils.CopyStructFields(&resp, respPb)
resp.ActiveUserNum = int(respPb.ActiveUserNum)
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
resp.TotalUserNum = int(respPb.TotalUserNum)
for _, v := range respPb.ActiveUserNumList {
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
Date string "json:\"date\""
ActiveUserNum int "json:\"active_user_num\""
}{
Date: v.Date,
ActiveUserNum: int(v.Num),
})
}
for _, v := range respPb.IncreaseUserNumList {
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
Date string "json:\"date\""
IncreaseUserNum int "json:\"increase_user_num\""
}{
Date: v.Date,
IncreaseUserNum: int(v.Num),
})
}
for _, v := range respPb.TotalUserNumList {
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
Date string "json:\"date\""
TotalUserNum int "json:\"total_user_num\""
}{
Date: v.Date,
TotalUserNum: int(v.Num),
})
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetGroupStatistics(c *gin.Context) {
var (
req cms_api_struct.GetGroupStatisticsRequest
resp cms_api_struct.GetGroupStatisticsResponse
reqPb pb.GetGroupStatisticsReq
)
reqPb.StatisticsReq = &pb.StatisticsReq{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
// utils.CopyStructFields(&resp, respPb)
resp.IncreaseGroupNum = int(respPb.GetIncreaseGroupNum())
resp.TotalGroupNum = int(respPb.GetTotalGroupNum())
for _, v := range respPb.IncreaseGroupNumList {
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
struct {
Date string "json:\"date\""
IncreaseGroupNum int "json:\"increase_group_num\""
}{
Date: v.Date,
IncreaseGroupNum: int(v.Num),
})
}
for _, v := range respPb.TotalGroupNumList {
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
struct {
Date string "json:\"date\""
TotalGroupNum int "json:\"total_group_num\""
}{
Date: v.Date,
TotalGroupNum: int(v.Num),
})
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetActiveUser(c *gin.Context) {
var (
req cms_api_struct.GetActiveUserRequest
resp cms_api_struct.GetActiveUserResponse
reqPb pb.GetActiveUserReq
)
reqPb.StatisticsReq = &pb.StatisticsReq{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetActiveGroup(c *gin.Context) {
var (
req cms_api_struct.GetActiveGroupRequest
resp cms_api_struct.GetActiveGroupResponse
reqPb pb.GetActiveGroupReq
)
reqPb.StatisticsReq = &pb.StatisticsReq{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
for _, group := range respPb.Groups {
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
GroupName string "json:\"group_name\""
GroupId string "json:\"group_id\""
MessageNum int "json:\"message_num\""
}{
GroupName: group.GroupName,
GroupId: group.GroupId,
MessageNum: int(group.MessageNum),
})
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
+307
View File
@@ -0,0 +1,307 @@
package user
import (
"Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
commonPb "Open_IM/pkg/proto/sdk_ws"
pb "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"fmt"
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
func GetUserById(c *gin.Context) {
var (
req cms_api_struct.GetUserRequest
resp cms_api_struct.GetUserResponse
reqPb pb.GetUserByIdReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUserById(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
if respPb.User.UserId == "" {
openIMHttp.RespHttp200(c, constant.OK, nil)
return
}
utils.CopyStructFields(&resp, respPb.User)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetUsersByName(c *gin.Context) {
var (
req cms_api_struct.GetUsersByNameRequest
resp cms_api_struct.GetUsersByNameResponse
reqPb pb.GetUsersByNameReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.UserName = req.UserName
reqPb.Pagination = &commonPb.RequestPagination{
PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber),
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
utils.CopyStructFields(&resp.Users, respPb.Users)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetUsers(c *gin.Context) {
var (
req cms_api_struct.GetUsersRequest
resp cms_api_struct.GetUsersResponse
reqPb pb.GetUsersReq
)
reqPb.Pagination = &commonPb.RequestPagination{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.Pagination, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUsers(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
return
}
utils.CopyStructFields(&resp.Users, respPb.User)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func ResignUser(c *gin.Context) {
var (
req cms_api_struct.ResignUserRequest
resp cms_api_struct.ResignUserResponse
reqPb pb.ResignUserReq
)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
utils.CopyStructFields(&reqPb, &req)
fmt.Println(reqPb.UserId)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.ResignUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func AlterUser(c *gin.Context) {
var (
req cms_api_struct.AlterUserRequest
resp cms_api_struct.AlterUserResponse
reqPb pb.AlterUserReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.AlterUser(context.Background(), &reqPb)
if err != nil {
log.NewError("0", "microserver failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func AddUser(c *gin.Context) {
var (
req cms_api_struct.AddUserRequest
reqPb pb.AddUserReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.AddUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func BlockUser(c *gin.Context) {
var (
req cms_api_struct.BlockUserRequest
resp cms_api_struct.BlockUserResponse
reqPb pb.BlockUserReq
)
if err := c.BindJSON(&req); err != nil {
fmt.Println(err)
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
fmt.Println(reqPb)
_, err := client.BlockUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
return
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func UnblockUser(c *gin.Context) {
var (
req cms_api_struct.UnblockUserRequest
resp cms_api_struct.UnBlockUserResponse
reqPb pb.UnBlockUserReq
)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.UnBlockUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
return
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetBlockUsers(c *gin.Context) {
var (
req cms_api_struct.GetBlockUsersRequest
resp cms_api_struct.GetBlockUsersResponse
reqPb pb.GetBlockUsersReq
respPb *pb.GetBlockUsersResp
)
reqPb.Pagination = &commonPb.RequestPagination{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb.Pagination, &req)
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
openIMHttp.RespHttp200(c, err, resp)
return
}
for _, v := range respPb.BlockUsers {
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
UserResponse: cms_api_struct.UserResponse{
UserId: v.User.UserId,
ProfilePhoto: v.User.ProfilePhoto,
Nickname: v.User.Nickname,
IsBlock: v.User.IsBlock,
CreateTime: v.User.CreateTime,
},
BeginDisableTime: v.BeginDisableTime,
EndDisableTime: v.EndDisableTime,
})
}
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetBlockUserById(c *gin.Context) {
var (
req cms_api_struct.GetBlockUserRequest
resp cms_api_struct.GetBlockUserResponse
reqPb pb.GetBlockUserByIdReq
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
if err != nil {
log.NewError("0", "GetBlockUserById rpc failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
utils.CopyStructFields(&resp, respPb.BlockUser.User)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func DeleteUser(c *gin.Context) {
var (
req cms_api_struct.DeleteUserRequest
reqPb pb.DeleteUserReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.DeleteUser(context.Background(), &reqPb)
if err != nil {
log.NewError("0", "DeleteUser rpc failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
+70
View File
@@ -0,0 +1,70 @@
package register
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
http2 "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)
type ParamsLogin struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
Password string `json:"password"`
Platform int32 `json:"platform"`
OperationID string `json:"operationID" binding:"required"`
}
func Login(c *gin.Context) {
params := ParamsLogin{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
var account string
if params.Email != "" {
account = params.Email
} else {
account = params.PhoneNumber
}
r, err := im_mysql_model.GetRegister(account)
if err != nil {
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})
return
}
if r.Password != params.Password {
log.NewError(params.OperationID, "password err", params.Password, account, r.Password, r.Account)
c.JSON(http.StatusOK, gin.H{"errCode": constant.PasswordErr, "errMsg": "password err"})
return
}
url := fmt.Sprintf("http://%s:10000/auth/user_token", utils.ServerIP)
openIMGetUserToken := api.UserTokenReq{}
openIMGetUserToken.OperationID = params.OperationID
openIMGetUserToken.Platform = params.Platform
openIMGetUserToken.Secret = config.Config.Secret
openIMGetUserToken.UserID = account
openIMGetUserTokenResp := api.UserTokenResp{}
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
if err != nil {
log.NewError(params.OperationID, "request openIM get user token error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": err.Error()})
return
}
err = json.Unmarshal(bMsg, &openIMGetUserTokenResp)
if err != nil || openIMGetUserTokenResp.ErrCode != 0 {
log.NewError(params.OperationID, "request get user token", account, "err", "")
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": ""})
return
}
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMGetUserTokenResp.UserToken})
}
+56
View File
@@ -0,0 +1,56 @@
package register
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"github.com/gin-gonic/gin"
"net/http"
)
type resetPasswordRequest struct {
VerificationCode string `json:"verificationCode" binding:"required"`
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
NewPassword string `json:"newPassword" binding:"required"`
OperationID string `json:"operationID"`
}
func ResetPassword(c *gin.Context) {
var (
req resetPasswordRequest
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
var account string
if req.Email != "" {
account = req.Email
} else {
account = req.PhoneNumber
}
if req.VerificationCode != config.Config.Demo.SuperCode {
accountKey := account + "_" + constant.VerificationCodeForResetSuffix
v, err := db.DB.GetAccountCode(accountKey)
if err != nil || v != req.VerificationCode {
log.NewError(req.OperationID, "password Verification code error", account, req.VerificationCode, v)
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!"})
return
}
}
user, err := im_mysql_model.GetRegister(account)
if err != nil || user.Account == "" {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "user not register!"})
return
}
if err := im_mysql_model.ResetPassword(account, req.NewPassword); err != nil {
c.JSON(http.StatusOK, gin.H{"errCode": constant.ResetPasswordFailed, "errMsg": "reset password failed: "+err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "reset password success"})
}
+130
View File
@@ -0,0 +1,130 @@
package register
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"fmt"
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gin-gonic/gin"
"gopkg.in/gomail.v2"
"math/rand"
"net/http"
"time"
)
type paramsVerificationCode struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
OperationID string `json:"operationID" binding:"required"`
UsedFor int `json:"usedFor"`
}
func SendVerificationCode(c *gin.Context) {
params := paramsVerificationCode{}
if err := c.BindJSON(&params); err != nil {
log.NewError("", "BindJSON failed", "err:", err.Error(), "phoneNumber", params.PhoneNumber, "email", params.Email)
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
var account string
if params.Email != "" {
account = params.Email
} else {
account = params.PhoneNumber
}
var accountKey string
if params.UsedFor == 0 {
params.UsedFor = constant.VerificationCodeForRegister
}
switch params.UsedFor {
case constant.VerificationCodeForRegister:
_, err := im_mysql_model.GetRegister(account)
if err == nil {
log.NewError(params.OperationID, "The phone number has been registered", params)
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
return
}
ok, err := db.DB.JudgeAccountEXISTS(account)
if ok || err != nil {
log.NewError(params.OperationID, "The phone number has been registered", params)
c.JSON(http.StatusOK, gin.H{"errCode": constant.RepeatSendCode, "errMsg": "The phone number has been registered"})
return
}
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
case constant.VerificationCodeForReset:
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
}
rand.Seed(time.Now().UnixNano())
code := 100000 + rand.Intn(900000)
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey, code)
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
if err != nil {
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
return
}
log.NewDebug("", config.Config.Demo)
if params.Email != "" {
m := gomail.NewMessage()
m.SetHeader(`From`, config.Config.Demo.Mail.SenderMail)
m.SetHeader(`To`, []string{account}...)
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
log.ErrorByKv("send mail error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
return
}
} else {
client, err := CreateClient(tea.String(config.Config.Demo.AliSMSVerify.AccessKeyID), tea.String(config.Config.Demo.AliSMSVerify.AccessKeySecret))
if err != nil {
log.NewError(params.OperationID, "create sendSms client err", "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
return
}
sendSmsRequest := &dysmsapi20170525.SendSmsRequest{
PhoneNumbers: tea.String(account),
SignName: tea.String(config.Config.Demo.AliSMSVerify.SignName),
TemplateCode: tea.String(config.Config.Demo.AliSMSVerify.VerificationCodeTemplateCode),
TemplateParam: tea.String(fmt.Sprintf("{\"code\":\"%d\"}", code)),
}
response, err := client.SendSms(sendSmsRequest)
if err != nil {
log.NewError(params.OperationID, "sendSms error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
return
}
if *response.Body.Code != "OK" {
log.NewError(params.OperationID, "alibabacloud sendSms error", account, "err", response.Body.Code, response.Body.Message)
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
return
}
}
data := make(map[string]interface{})
data["account"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code has been set!", "data": data})
}
func CreateClient(accessKeyId *string, accessKeySecret *string) (result *dysmsapi20170525.Client, err error) {
c := &openapi.Config{
// 您的AccessKey ID
AccessKeyId: accessKeyId,
// 您的AccessKey Secret
AccessKeySecret: accessKeySecret,
}
// 访问的域名
c.Endpoint = tea.String("dysmsapi.aliyuncs.com")
result = &dysmsapi20170525.Client{}
result, err = dysmsapi20170525.NewClient(c)
return result, err
}
+89
View File
@@ -0,0 +1,89 @@
package register
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
http2 "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)
type ParamsSetPassword struct {
Email string `json:"email"`
Name string `json:"name"`
PhoneNumber string `json:"phoneNumber"`
Password string `json:"password"`
VerificationCode string `json:"verificationCode"`
Platform int32 `json:"platform" binding:"required,min=1,max=7"`
Ex string `json:"ex"`
OperationID string `json:"operationID" binding:"required"`
}
func SetPassword(c *gin.Context) {
params := ParamsSetPassword{}
if err := c.BindJSON(&params); err != nil {
log.NewError(params.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
var account string
if params.Email != "" {
account = params.Email
} else {
account = params.PhoneNumber
}
if params.Name == "" {
params.Name = account
}
if params.VerificationCode != config.Config.Demo.SuperCode {
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
v, err := db.DB.GetAccountCode(accountKey)
if err != nil || v != params.VerificationCode {
log.NewError(params.OperationID, "password Verification code error", account, params.VerificationCode)
data := make(map[string]interface{})
data["PhoneNumber"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
return
}
}
url := fmt.Sprintf("http://%s:10000/auth/user_register", utils.ServerIP)
openIMRegisterReq := api.UserRegisterReq{}
openIMRegisterReq.OperationID = params.OperationID
openIMRegisterReq.Platform = params.Platform
openIMRegisterReq.UserID = account
openIMRegisterReq.Nickname = params.Name
openIMRegisterReq.Secret = config.Config.Secret
openIMRegisterResp := api.UserRegisterResp{}
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
if err != nil {
log.NewError(params.OperationID, "request openIM register error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
return
}
err = json.Unmarshal(bMsg, &openIMRegisterResp)
if err != nil || openIMRegisterResp.ErrCode != 0 {
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
if err != nil {
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
}
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
return
}
log.Info(params.OperationID, "begin store mysql", account, params.Password)
err = im_mysql_model.SetPassword(account, params.Password, params.Ex)
if err != nil {
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
return
}
log.Info(params.OperationID, "end setPassword", account, params.Password)
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
return
}
+80
View File
@@ -0,0 +1,80 @@
package register
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
"net/http"
)
type paramsCertification struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
VerificationCode string `json:"verificationCode"`
OperationID string `json:"operationID" binding:"required"`
UsedFor int `json:"usedFor"`
}
func Verify(c *gin.Context) {
params := paramsCertification{}
if err := c.BindJSON(&params); err != nil {
log.NewError("", "request params json parsing failed", "", "err", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
log.NewInfo("recv req: ", params)
var account string
if params.Email != "" {
account = params.Email
} else {
account = params.PhoneNumber
}
if params.VerificationCode == config.Config.Demo.SuperCode {
log.InfoByKv("Super Code Verified successfully", account)
data := make(map[string]interface{})
data["account"] = account
data["verificationCode"] = params.VerificationCode
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
return
}
log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
log.NewInfo(params.OperationID, "begin get form redis", account)
if params.UsedFor == 0 {
params.UsedFor = constant.VerificationCodeForRegister
}
var accountKey string
switch params.UsedFor {
case constant.VerificationCodeForRegister:
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
case constant.VerificationCodeForReset:
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
}
code, err := db.DB.GetAccountCode(accountKey)
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
if err != nil {
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
data := make(map[string]interface{})
data["account"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code expired!", "data": data})
return
}
if params.VerificationCode == code {
log.Info(params.OperationID, "Verified successfully", account)
data := make(map[string]interface{})
data["account"] = account
data["verificationCode"] = params.VerificationCode
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
return
} else {
log.Info(params.OperationID, "Verification code error", account, params.VerificationCode)
data := make(map[string]interface{})
data["account"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
}
}
+35
View File
@@ -0,0 +1,35 @@
package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/statistics"
"fmt"
"github.com/go-playground/validator/v10"
"sync"
)
var (
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgCount uint64
userCount uint64
)
func Init(rpcPort, wsPort int) {
//log initialization
rwLock = new(sync.RWMutex)
validate = validator.New()
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", userCount), 300)
ws.onInit(wsPort)
rpcSvr.onInit(rpcPort)
}
func Run() {
go ws.run()
go rpcSvr.run()
}
+297
View File
@@ -0,0 +1,297 @@
package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
pbRtc "Open_IM/pkg/proto/rtc"
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"bytes"
"context"
"encoding/gob"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"google.golang.org/grpc"
"runtime"
"strconv"
"strings"
)
func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
//ws online debug data
//{"ReqIdentifier":1001,"Token":"123","SendID":"c4ca4238a0b923820dcc509a6f75849b","Time":"123","OperationID":"123","MsgIncr":0}
//{"ReqIdentifier":1002,"Token":"123","SendID":"c4ca4238a0b923820dcc509a6f75849b","Time":"123","OperationID":"123","MsgIncr":0,"SeqBegin":1,"SeqEnd":6}
//{"ReqIdentifier":1003,"Token":"123","SendID":"c4ca4238a0b923820dcc509a6f75849b",
//"RecvID":"a87ff679a2f3e71d9181a67b7542122c","ClientMsgID":"2343","Time":"147878787","OperationID":
//"123","MsgIncr":0,"SubMsgType":101,"MsgType":100,"MsgFrom":1,"Content":"sdfsdf"}
b := bytes.NewBuffer(binaryMsg)
m := Req{}
dec := gob.NewDecoder(b)
err := dec.Decode(&m)
if err != nil {
log.NewError("", "ws Decode err", err.Error())
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
err = conn.Close()
if err != nil {
log.NewError("", "ws close err", err.Error())
}
return
}
if err := validate.Struct(m); err != nil {
log.NewError("", "ws args validate err", err.Error())
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
return
}
//if !utils.VerifyToken(m.Token, m.SendID) {
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
// return
//}
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m)
switch m.ReqIdentifier {
case constant.WSGetNewestSeq:
ws.getSeqReq(conn, &m)
case constant.WSSendMsg:
ws.sendMsgReq(conn, &m)
case constant.WSSendSignalMsg:
ws.sendSignalMsgReq(conn, &m)
case constant.WSPullMsgBySeqList:
ws.pullMsgBySeqListReq(conn, &m)
default:
}
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
}
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier, m.Data)
rpcReq := pbChat.GetMaxAndMinSeqReq{}
nReply := new(pbChat.GetMaxAndMinSeqResp)
rpcReq.UserID = m.SendID
rpcReq.OperationID = m.OperationID
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
if grpcConn == nil {
log.ErrorByKv("get grpcConn err", rpcReq.OperationID, "args", m)
}
msgClient := pbChat.NewChatClient(grpcConn)
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
if err != nil {
log.Error(rpcReq.OperationID, "rpc call failed to getSeqReq", err, rpcReq.String())
nReply.ErrCode = 500
nReply.ErrMsg = err.Error()
ws.getSeqResp(conn, m, nReply)
} else {
log.InfoByKv("rpc call success to getSeqReq", rpcReq.OperationID, "replyData", rpcReply.String())
ws.getSeqResp(conn, m, rpcReply)
}
}
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeqResp) {
var mReplyData sdk_ws.GetMaxAndMinSeqResp
mReplyData.MaxSeq = pb.GetMaxSeq()
mReplyData.MinSeq = pb.GetMinSeq()
b, _ := proto.Marshal(&mReplyData)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
MsgIncr: m.MsgIncr,
ErrCode: pb.GetErrCode(),
ErrMsg: pb.GetErrMsg(),
OperationID: m.OperationID,
Data: b,
}
ws.sendMsg(conn, mReply)
}
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, m.Data)
nReply := new(sdk_ws.PullMessageBySeqListResp)
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
if isPass {
rpcReq := sdk_ws.PullMessageBySeqListReq{}
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
rpcReq.UserID = m.SendID
rpcReq.OperationID = m.OperationID
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
if err != nil {
log.NewError(rpcReq.OperationID, "pullMsgBySeqListReq err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.pullMsgBySeqListResp(conn, m, nReply)
} else {
log.NewInfo(rpcReq.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), len(reply.List))
ws.pullMsgBySeqListResp(conn, m, reply)
}
} else {
nReply.ErrCode = errCode
nReply.ErrMsg = errMsg
ws.pullMsgBySeqListResp(conn, m, nReply)
}
}
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
c, _ := proto.Marshal(pb)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
MsgIncr: m.MsgIncr,
ErrCode: pb.GetErrCode(),
ErrMsg: pb.GetErrMsg(),
OperationID: m.OperationID,
Data: c,
}
log.NewInfo(m.OperationID, "pullMsgBySeqListResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
len(mReply.Data))
ws.sendMsg(conn, mReply)
}
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
sendMsgCount++
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
nReply := new(pbChat.SendMsgResp)
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
if isPass {
data := pData.(sdk_ws.MsgData)
pbData := pbChat.SendMsgReq{
Token: m.Token,
OperationID: m.OperationID,
MsgData: &data,
}
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn)
reply, err := client.SendMsg(context.Background(), &pbData)
if err != nil {
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.sendMsgResp(conn, m, nReply)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
ws.sendMsgResp(conn, m, reply)
}
} else {
nReply.ErrCode = errCode
nReply.ErrMsg = errMsg
ws.sendMsgResp(conn, m, nReply)
}
}
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
// := make(map[string]interface{})
var mReplyData sdk_ws.UserSendMsgResp
mReplyData.ClientMsgID = pb.GetClientMsgID()
mReplyData.ServerMsgID = pb.GetServerMsgID()
mReplyData.SendTime = pb.GetSendTime()
b, _ := proto.Marshal(&mReplyData)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
MsgIncr: m.MsgIncr,
ErrCode: pb.GetErrCode(),
ErrMsg: pb.GetErrMsg(),
OperationID: m.OperationID,
Data: b,
}
ws.sendMsg(conn, mReply)
}
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
nReply := new(pbChat.SendMsgResp)
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
if isPass {
signalResp := pbRtc.SignalResp{}
//isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
connGrpc, err := grpc.Dial(config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port), grpc.WithInsecure())
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "grpc.Dial failed", err.Error())
ws.sendSignalMsgResp(conn, 204, "create grpc failed"+err.Error(), m, nil)
return
}
rtcClient := pbRtc.NewRtcServiceClient(connGrpc)
req := &pbRtc.SignalMessageAssembleReq{
SignalReq: pData.(*pbRtc.SignalReq),
OperationID: m.OperationID,
}
respPb, err := rtcClient.SignalMessageAssemble(context.Background(), req)
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "SignalMessageAssemble", err.Error(), config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port))
ws.sendSignalMsgResp(conn, 204, "grpc SignalMessageAssemble failed: "+err.Error(), m, &signalResp)
return
}
signalResp.Payload = respPb.SignalResp.Payload
msgData := sdk_ws.MsgData{}
utils.CopyStructFields(&msgData, respPb.MsgData)
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), respPb.String())
if respPb.IsPass {
pbData := pbChat.SendMsgReq{
Token: m.Token,
OperationID: m.OperationID,
MsgData: &msgData,
}
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), "pbData: ", pbData)
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn)
reply, err := client.SendMsg(context.Background(), &pbData)
if err != nil {
log.NewError(pbData.OperationID, utils.GetSelfFuncName(), "rpc sendMsg err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
}
} else {
log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)
ws.sendSignalMsgResp(conn, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg, m, &signalResp)
}
} else {
ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil)
}
}
func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *pbRtc.SignalResp) {
// := make(map[string]interface{})
log.Debug(m.OperationID, "SignalMsgResp is", pb.String())
b, _ := proto.Marshal(pb)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
MsgIncr: m.MsgIncr,
ErrCode: errCode,
ErrMsg: errMsg,
OperationID: m.OperationID,
Data: b,
}
ws.sendMsg(conn, mReply)
}
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
var b bytes.Buffer
enc := gob.NewEncoder(&b)
err := enc.Encode(mReply)
if err != nil {
uid, platform := ws.getUserUid(conn)
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "Encode Msg error", conn.RemoteAddr().String(), uid, platform, err.Error())
return
}
err = ws.writeMsg(conn, websocket.BinaryMessage, b.Bytes())
if err != nil {
uid, platform := ws.getUserUid(conn)
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "WS WriteMsg error", conn.RemoteAddr().String(), uid, platform, err.Error())
}
}
func (ws *WServer) sendErrMsg(conn *UserConn, errCode int32, errMsg string, reqIdentifier int32, msgIncr string, operationID string) {
mReply := Resp{
ReqIdentifier: reqIdentifier,
MsgIncr: msgIncr,
ErrCode: errCode,
ErrMsg: errMsg,
OperationID: operationID,
}
ws.sendMsg(conn, mReply)
}
@@ -0,0 +1,58 @@
package open_im_media
const (
// Address gRPC服务地址
Address = "127.0.0.1:11300"
)
//var roomClient *lksdk.RoomServiceClient
type Media struct {
}
func NewMedia() *Media {
return &Media{}
}
//func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
// var newData pbRtc.ParticipantMetaData
// copier.Copy(&newData, data)
// conn, err := grpc.Dial(Address, grpc.WithInsecure())
// if err != nil {
// return "", "", err
// }
// defer conn.Close()
// c := pbRtc.NewRtcServiceClient(conn)
// req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
// resp, err := c.GetJoinToken(context.Background(), req)
// if err != nil {
// return "", "", err
// }
// if resp.CommonResp.ErrCode != 0 {
// return "", "", errors.New(resp.CommonResp.ErrMsg)
// }
// return resp.Jwt, resp.LiveURL, nil
// //at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
// //grant := &auth.VideoGrant{
// // RoomJoin: true,
// // Room: room,
// //}
// //at.AddGrant(grant).
// // SetIdentity(identity).
// // SetValidFor(time.Hour)
// //
// //return at.ToJWT()
//}
func init() {
//roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)
}
func (m *Media) CreateRoom(roomName string) (error, error) {
return nil, nil
//return roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
// Name: roomName,
// EmptyTimeout: 60 * 3,
//})
}
+149
View File
@@ -0,0 +1,149 @@
package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbRelay "Open_IM/pkg/proto/relay"
"Open_IM/pkg/utils"
"bytes"
"context"
"encoding/gob"
"fmt"
"github.com/golang/protobuf/proto"
"net"
"strings"
"github.com/gorilla/websocket"
"google.golang.org/grpc"
)
type RPCServer struct {
rpcPort int
rpcRegisterName string
etcdSchema string
etcdAddr []string
}
func (r *RPCServer) onInit(rpcPort int) {
r.rpcPort = rpcPort
r.rpcRegisterName = config.Config.RpcRegisterName.OpenImOnlineMessageRelayName
r.etcdSchema = config.Config.Etcd.EtcdSchema
r.etcdAddr = config.Config.Etcd.EtcdAddr
}
func (r *RPCServer) run() {
ip := utils.ServerIP
registerAddress := ip + ":" + utils.IntToString(r.rpcPort)
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.ErrorByArgs(fmt.Sprintf("fail to listening consumer, err:%v\n", err))
return
}
defer listener.Close()
srv := grpc.NewServer()
defer srv.GracefulStop()
pbRelay.RegisterOnlineMessageRelayServiceServer(srv, r)
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10)
if err != nil {
log.ErrorByKv("register push message rpc to etcd err", "", "err", err.Error())
}
err = srv.Serve(listener)
if err != nil {
log.ErrorByKv("push message rpc listening err", "", "err", err.Error())
return
}
}
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
var resp []*pbRelay.SingleMsgToUser
msgBytes, _ := proto.Marshal(in.MsgData)
mReply := Resp{
ReqIdentifier: constant.WSPushMsg,
OperationID: in.OperationID,
Data: msgBytes,
}
var replyBytes bytes.Buffer
enc := gob.NewEncoder(&replyBytes)
err := enc.Encode(mReply)
if err != nil {
log.NewError(in.OperationID, "data encode err", err.Error())
}
var tag bool
recvID := in.PushToUserID
platformList := genPlatformArray()
for _, v := range platformList {
if conn := ws.getUserConn(recvID, v); conn != nil {
tag = true
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
temp := &pbRelay.SingleMsgToUser{
ResultCode: resultCode,
RecvID: recvID,
RecvPlatFormID: constant.PlatformNameToID(v),
}
resp = append(resp, temp)
} else {
temp := &pbRelay.SingleMsgToUser{
ResultCode: -1,
RecvID: recvID,
RecvPlatFormID: constant.PlatformNameToID(v),
}
resp = append(resp, temp)
}
}
if !tag {
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
}
return &pbRelay.OnlinePushMsgResp{
Resp: resp,
}, nil
}
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
log.NewInfo(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
if !token_verify.IsMangerUserID(req.OpUserID) {
log.NewError(req.OperationID, "no permission GetUsersOnlineStatus ", req.OpUserID)
return &pbRelay.GetUsersOnlineStatusResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
}
var resp pbRelay.GetUsersOnlineStatusResp
for _, userID := range req.UserIDList {
platformList := genPlatformArray()
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
temp.UserID = userID
for _, platform := range platformList {
if conn := ws.getUserConn(userID, platform); conn != nil {
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
ps.Platform = platform
ps.Status = constant.OnlineStatus
temp.Status = constant.OnlineStatus
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
}
}
if temp.Status == constant.OnlineStatus {
resp.SuccessResult = append(resp.SuccessResult, temp)
}
}
log.NewInfo(req.OperationID, "GetUsersOnlineStatus rpc return ", resp.String())
return &resp, nil
}
func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.OnlinePushMsgReq, RecvPlatForm, RecvID string) (ResultCode int64) {
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
if err != nil {
log.ErrorByKv("PushMsgToUser is failed By Ws", "", "Addr", conn.RemoteAddr().String(),
"error", err, "senderPlatform", constant.PlatformIDToName(in.MsgData.SenderPlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
ResultCode = -2
return ResultCode
} else {
log.InfoByKv("PushMsgToUser is success By Ws", in.OperationID, "args", in.String(), "recvPlatForm", RecvPlatForm, "recvID", RecvID)
ResultCode = 0
return ResultCode
}
}
func genPlatformArray() (array []string) {
for i := 1; i <= constant.LinuxPlatformID; i++ {
array = append(array, constant.PlatformIDToName(int32(i)))
}
return array
}
+253
View File
@@ -0,0 +1,253 @@
/*
** description("").
** copyright('Open_IM,www.Open_IM.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/5/21 15:29).
*/
package gate
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
pbRtc "Open_IM/pkg/proto/rtc"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"github.com/golang/protobuf/proto"
)
type Req struct {
ReqIdentifier int32 `json:"reqIdentifier" validate:"required"`
Token string `json:"token" `
SendID string `json:"sendID" validate:"required"`
OperationID string `json:"operationID" validate:"required"`
MsgIncr string `json:"msgIncr" validate:"required"`
Data []byte `json:"data"`
}
type Resp struct {
ReqIdentifier int32 `json:"reqIdentifier"`
MsgIncr string `json:"msgIncr"`
OperationID string `json:"operationID"`
ErrCode int32 `json:"errCode"`
ErrMsg string `json:"errMsg"`
Data []byte `json:"data"`
}
type SeqData struct {
SeqBegin int64 `mapstructure:"seqBegin" validate:"required"`
SeqEnd int64 `mapstructure:"seqEnd" validate:"required"`
}
type MsgData struct {
PlatformID int32 `mapstructure:"platformID" validate:"required"`
SessionType int32 `mapstructure:"sessionType" validate:"required"`
MsgFrom int32 `mapstructure:"msgFrom" validate:"required"`
ContentType int32 `mapstructure:"contentType" validate:"required"`
RecvID string `mapstructure:"recvID" validate:"required"`
ForceList []string `mapstructure:"forceList"`
Content string `mapstructure:"content" validate:"required"`
Options map[string]interface{} `mapstructure:"options" validate:"required"`
ClientMsgID string `mapstructure:"clientMsgID" validate:"required"`
OfflineInfo map[string]interface{} `mapstructure:"offlineInfo" validate:"required"`
Ext map[string]interface{} `mapstructure:"ext"`
}
type MaxSeqResp struct {
MaxSeq int64 `json:"maxSeq"`
}
type PullMessageResp struct {
}
type SeqListData struct {
SeqList []int64 `mapstructure:"seqList" validate:"required"`
}
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
switch r {
case constant.WSSendMsg:
data := open_im_sdk.MsgData{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
return false, 204, err.Error(), nil
}
return true, 0, "", data
case constant.WSSendSignalMsg:
data := pbRtc.SignalReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
return false, 204, err.Error(), nil
}
return true, 0, "", &data
case constant.WSPullMsgBySeqList:
data := open_im_sdk.PullMessageBySeqListReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
return false, 204, err.Error(), nil
}
return true, 0, "", data
default:
}
return false, 204, "args err", nil
//b := bytes.NewBuffer(m.Data)
//dec := gob.NewDecoder(b)
//err := dec.Decode(&data)
//if err != nil {
// log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
// return false, 203, err.Error(), nil
//}
//if err := mapstructure.WeakDecode(m.Data, &data); err != nil {
// log.ErrorByKv("map to Data struct err", "", "err", err.Error(), "reqIdentifier", r)
// return false, 203, err.Error(), nil
//} else
}
//func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
// var msg open_im_sdk.MsgData
// var resp open_im_sdk.SignalResp
// media := open_im_media.NewMedia()
// msg.MsgFrom = constant.UserMsgType
// msg.ContentType = constant.SignalingNotification
// reqData, e := proto.Marshal(s)
// if e != nil {
// return false, 201, e.Error(), nil, nil
// }
// msg.Content = reqData
// msg.CreateTime = utils.GetCurrentTimestampByMill()
// options := make(map[string]bool, 6)
// utils.SetSwitchFromOptions(options, constant.IsHistory, false)
// utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
// utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
// utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
// utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
// utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
// utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
// msg.Options = options
// switch payload := s.Payload.(type) {
// case *open_im_sdk.SignalReq_Invite:
// token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
// if err2 != nil {
// return false, 202, err2.Error(), nil, nil
// }
// invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
// Token: token,
// RoomID: payload.Invite.Invitation.RoomID,
// LiveURL: liveURL,
// }}
// resp.Payload = &invite
// msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
// msg.SessionType = payload.Invite.Invitation.SessionType
// msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
// msg.SendID = payload.Invite.Invitation.InviterUserID
// if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
// msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
// } else {
// return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_InviteInGroup:
// token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
// if err2 != nil {
// return false, 204, err2.Error(), nil, nil
// }
// inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
// RoomID: payload.InviteInGroup.Invitation.RoomID,
// Token: token,
// LiveURL: liveURL,
// }}
// resp.Payload = &inviteGroup
// msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
// msg.SessionType = payload.InviteInGroup.Invitation.SessionType
// msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
// msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
// if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
// msg.GroupID = payload.InviteInGroup.Invitation.GroupID
// } else {
// return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
//
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_Cancel:
// cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
// resp.Payload = &cancel
// msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
// msg.SendID = payload.Cancel.Invitation.InviterUserID
// msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
// msg.SessionType = payload.Cancel.Invitation.SessionType
// if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
// switch payload.Cancel.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
// case constant.GroupChatType:
// msg.GroupID = payload.Cancel.Invitation.GroupID
// }
// } else {
// return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_Accept:
// token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
// if err2 != nil {
// return false, 207, err2.Error(), nil, nil
// }
// accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
// Token: token,
// LiveURL: liveURL,
// RoomID: payload.Accept.Invitation.RoomID,
// }}
// resp.Payload = &accept
// msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
// msg.SendID = payload.Accept.OpUserID
// msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
// msg.SessionType = payload.Accept.Invitation.SessionType
// if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
// switch payload.Accept.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Accept.Invitation.InviterUserID
// case constant.GroupChatType:
// msg.GroupID = payload.Accept.Invitation.GroupID
// }
// } else {
// return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_HungUp:
// case *open_im_sdk.SignalReq_Reject:
// reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
// resp.Payload = &reject
// msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
// msg.SendID = payload.Reject.OpUserID
// msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
// msg.SessionType = payload.Reject.Invitation.SessionType
// if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
// switch payload.Reject.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Reject.Invitation.InviterUserID
// case constant.GroupChatType:
// msg.GroupID = payload.Reject.Invitation.GroupID
// }
// } else {
// return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
// return true, 0, "", &resp, &msg
// }
// return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
//}
+285
View File
@@ -0,0 +1,285 @@
package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/utils"
"bytes"
"encoding/gob"
"github.com/garyburd/redigo/redis"
"net/http"
"sync"
"time"
"github.com/gorilla/websocket"
)
type UserConn struct {
*websocket.Conn
w *sync.Mutex
}
type WServer struct {
wsAddr string
wsMaxConnNum int
wsUpGrader *websocket.Upgrader
wsConnToUser map[*UserConn]map[string]string
wsUserToConn map[string]map[string]*UserConn
}
func (ws *WServer) onInit(wsPort int) {
ws.wsAddr = ":" + utils.IntToString(wsPort)
ws.wsMaxConnNum = config.Config.LongConnSvr.WebsocketMaxConnNum
ws.wsConnToUser = make(map[*UserConn]map[string]string)
ws.wsUserToConn = make(map[string]map[string]*UserConn)
ws.wsUpGrader = &websocket.Upgrader{
HandshakeTimeout: time.Duration(config.Config.LongConnSvr.WebsocketTimeOut) * time.Second,
ReadBufferSize: config.Config.LongConnSvr.WebsocketMaxMsgLen,
CheckOrigin: func(r *http.Request) bool { return true },
}
}
func (ws *WServer) run() {
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
err := http.ListenAndServe(ws.wsAddr, nil) //Start listening
if err != nil {
log.ErrorByKv("Ws listening err", "", "err", err.Error())
}
}
func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
if ws.headerCheck(w, r) {
query := r.URL.Query()
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
if err != nil {
log.ErrorByKv("upgrade http conn err", "", "err", err)
return
} else {
//Connection mapping relationship,
//userID+" "+platformID->conn
//Initialize a lock for each user
newConn := &UserConn{conn, new(sync.Mutex)}
ws.addUserConn(query["sendID"][0], int32(utils.StringToInt64(query["platformID"][0])), newConn, query["token"][0])
go ws.readMsg(newConn)
}
}
}
func (ws *WServer) readMsg(conn *UserConn) {
for {
messageType, msg, err := conn.ReadMessage()
if messageType == websocket.PingMessage {
log.NewInfo("", "this is a pingMessage")
}
if err != nil {
uid, platform := ws.getUserUid(conn)
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
ws.delUserConn(conn)
return
} else {
//log.ErrorByKv("test", "", "msgType", msgType, "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn))
}
ws.msgParse(conn, msg)
//ws.writeMsg(conn, 1, chat)
}
}
func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
conn.w.Lock()
defer conn.w.Unlock()
return conn.WriteMessage(a, msg)
}
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newConn *UserConn, token string, operationID string) {
switch config.Config.MultiLoginPolicy {
case constant.AllLoginButSameTermKick:
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
if oldConn, ok := oldConnMap[constant.PlatformIDToName(platformID)]; ok {
log.NewDebug(operationID, uid, platformID, "kick old conn")
ws.sendKickMsg(oldConn, newConn)
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
if err != nil && err != redis.ErrNil {
log.NewError(operationID, "get token from redis err", err.Error())
return
}
if m == nil {
log.NewError(operationID, "get token from redis err", "m is nil")
return
}
for k, _ := range m {
if k != token {
m[k] = constant.KickedToken
}
}
log.NewDebug(operationID, "get map is ", m)
err = db.DB.SetTokenMapByUidPid(uid, platformID, m)
if err != nil {
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error())
return
}
err = oldConn.Close()
delete(oldConnMap, constant.PlatformIDToName(platformID))
ws.wsUserToConn[uid] = oldConnMap
if len(oldConnMap) == 0 {
delete(ws.wsUserToConn, uid)
}
delete(ws.wsConnToUser, oldConn)
if err != nil {
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
}
} else {
log.NewWarn(operationID, "abnormal uid-conn ", uid, platformID, oldConnMap[constant.PlatformIDToName(platformID)])
}
} else {
log.NewDebug(operationID, "no other conn", ws.wsUserToConn, uid, platformID)
}
case constant.SingleTerminalLogin:
case constant.WebAndOther:
}
}
func (ws *WServer) sendKickMsg(oldConn, newConn *UserConn) {
mReply := Resp{
ReqIdentifier: constant.WSKickOnlineMsg,
ErrCode: constant.ErrTokenInvalid.ErrCode,
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
}
var b bytes.Buffer
enc := gob.NewEncoder(&b)
err := enc.Encode(mReply)
if err != nil {
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "Encode Msg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())
return
}
err = ws.writeMsg(oldConn, websocket.BinaryMessage, b.Bytes())
if err != nil {
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "WS WriteMsg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())
}
}
func (ws *WServer) addUserConn(uid string, platformID int32, conn *UserConn, token string) {
rwLock.Lock()
defer rwLock.Unlock()
operationID := utils.OperationIDGenerator()
ws.MultiTerminalLoginChecker(uid, platformID, conn, token, operationID)
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
oldConnMap[constant.PlatformIDToName(platformID)] = conn
ws.wsUserToConn[uid] = oldConnMap
log.Debug(operationID, "user not first come in, add conn ", uid, platformID, conn, oldConnMap)
} else {
i := make(map[string]*UserConn)
i[constant.PlatformIDToName(platformID)] = conn
ws.wsUserToConn[uid] = i
log.Debug(operationID, "user first come in, new user, conn", uid, platformID, conn, ws.wsUserToConn[uid])
}
if oldStringMap, ok := ws.wsConnToUser[conn]; ok {
oldStringMap[constant.PlatformIDToName(platformID)] = uid
ws.wsConnToUser[conn] = oldStringMap
} else {
i := make(map[string]string)
i[constant.PlatformIDToName(platformID)] = uid
ws.wsConnToUser[conn] = i
}
count := 0
for _, v := range ws.wsUserToConn {
count = count + len(v)
}
log.Debug(operationID, "WS Add operation", "", "wsUser added", ws.wsUserToConn, "connection_uid", uid, "connection_platform", constant.PlatformIDToName(platformID), "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
userCount = uint64(len(ws.wsUserToConn))
}
func (ws *WServer) delUserConn(conn *UserConn) {
rwLock.Lock()
defer rwLock.Unlock()
var platform, uid string
if oldStringMap, ok := ws.wsConnToUser[conn]; ok {
for k, v := range oldStringMap {
platform = k
uid = v
}
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
delete(oldConnMap, platform)
ws.wsUserToConn[uid] = oldConnMap
if len(oldConnMap) == 0 {
delete(ws.wsUserToConn, uid)
}
count := 0
for _, v := range ws.wsUserToConn {
count = count + len(v)
}
log.WarnByKv("WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
} else {
log.WarnByKv("WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn))
}
userCount = uint64(len(ws.wsUserToConn))
delete(ws.wsConnToUser, conn)
}
err := conn.Close()
if err != nil {
log.ErrorByKv("close err", "", "uid", uid, "platform", platform)
}
}
func (ws *WServer) getUserConn(uid string, platform string) *UserConn {
rwLock.RLock()
defer rwLock.RUnlock()
if connMap, ok := ws.wsUserToConn[uid]; ok {
if conn, flag := connMap[platform]; flag {
return conn
}
}
return nil
}
func (ws *WServer) getSingleUserAllConn(uid string) map[string]*UserConn {
rwLock.RLock()
defer rwLock.RUnlock()
if connMap, ok := ws.wsUserToConn[uid]; ok {
return connMap
}
return nil
}
func (ws *WServer) getUserUid(conn *UserConn) (uid, platform string) {
rwLock.RLock()
defer rwLock.RUnlock()
if stringMap, ok := ws.wsConnToUser[conn]; ok {
for k, v := range stringMap {
platform = k
uid = v
}
return uid, platform
}
return "", ""
}
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
status := http.StatusUnauthorized
query := r.URL.Query()
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
if ok, err, msg := token_verify.WsVerifyToken(query["token"][0], query["sendID"][0], query["platformID"][0]); !ok {
e := err.(*constant.ErrInfo)
log.ErrorByKv("Token verify failed", "", "query", query, msg)
w.Header().Set("Sec-Websocket-Version", "13")
http.Error(w, e.ErrMsg, int(e.ErrCode))
return false
} else {
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
return true
}
} else {
log.ErrorByKv("Args err", "", "query", query)
w.Header().Set("Sec-Websocket-Version", "13")
http.Error(w, http.StatusText(status), status)
return false
}
}
func genMapKey(uid string, platformID int32) string {
return uid + " " + constant.PlatformIDToName(platformID)
}
+23
View File
@@ -0,0 +1,23 @@
package logic
import (
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/chat"
"Open_IM/pkg/utils"
)
func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error {
time := utils.GetCurrentTimestampByMill()
seq, err := db.DB.IncrUserSeq(uid)
if err != nil {
log.NewError(msg.OperationID, "data insert to redis err", err.Error(), msg.String())
return err
}
msg.MsgData.Seq = uint32(seq)
pbSaveData := pbMsg.MsgDataToDB{}
pbSaveData.MsgData = msg.MsgData
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
}

Some files were not shown because too many files have changed in this diff Show More