Compare commits

..

1491 Commits

Author SHA1 Message Date
Gordon 381e72f1ef send message 2022-05-13 21:05:39 +08:00
Gordon 91fe549c25 add log 2022-05-13 16:30:36 +08:00
Gordon a472da9ea6 msg bug fix 2022-05-13 16:19:11 +08:00
Gordon 20c7fe81dc Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-13 16:00:03 +08:00
Gordon 3ef445eb2e msg bug fix 2022-05-13 15:59:38 +08:00
wangchuxiao 4afc38523d organization 2022-05-13 15:41:11 +08:00
wangchuxiao 15616e8d07 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-13 15:38:19 +08:00
wangchuxiao 2534921af9 organization 2022-05-13 15:38:05 +08:00
Gordon 0206198f55 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-13 10:07:43 +08:00
Gordon 3c8c402f10 compose restore 2022-05-13 10:06:56 +08:00
wangchuxiao 098dae9640 organization 2022-05-12 19:11:55 +08:00
wangchuxiao 42c38de3e2 organization 2022-05-12 19:09:25 +08:00
wangchuxiao be10e6a9de organization 2022-05-12 19:07:26 +08:00
wangchuxiao 6b5fb81e01 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-12 19:06:25 +08:00
wangchuxiao bb5991b111 organization 2022-05-12 19:00:48 +08:00
wenxu12345 8f261970e9 Update group members' faceURL immediately 2022-05-12 18:00:23 +08:00
Gordon 093a8f18ef test 2022-05-11 21:01:36 +08:00
Gordon 9c19b5b785 test 2022-05-11 20:54:04 +08:00
Gordon 35958ca3a2 test 2022-05-11 20:49:47 +08:00
Gordon 3bc2e97e8b test 2022-05-11 20:02:33 +08:00
Gordon eb7ff77461 test 2022-05-11 19:45:44 +08:00
Gordon d36f4cf6f8 test 2022-05-11 19:44:08 +08:00
Gordon f373669f02 test 2022-05-11 19:31:32 +08:00
Gordon 37596589a7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-11 19:28:00 +08:00
Gordon 3e90426d8e test 2022-05-11 19:27:49 +08:00
wenxu12345 35a184827a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-11 19:25:33 +08:00
wenxu12345 2edd3c5614 When you create a group chat, the group member can be empty 2022-05-11 19:25:06 +08:00
Gordon cec5a6ceeb test 2022-05-11 19:21:28 +08:00
Gordon dc6b0b4dde test 2022-05-11 19:16:57 +08:00
Gordon 3ecc1816be test 2022-05-11 18:58:11 +08:00
Gordon 9a90c2e568 test 2022-05-11 18:54:22 +08:00
Gordon ab747d0338 test 2022-05-11 18:49:21 +08:00
Gordon 8753f91a4a send group message split topic 2022-05-11 18:38:58 +08:00
Gordon f8af109821 send group message split topic 2022-05-11 18:33:48 +08:00
Gordon 804eb6c076 video message send 2022-05-11 14:34:21 +08:00
Gordon f4f3ff0eda Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-11 13:26:50 +08:00
Gordon 03c0b1ea91 add kafka manager 2022-05-11 13:26:39 +08:00
wenxu12345 38535bde84 add RpcRegisterIP 2022-05-11 12:20:28 +08:00
wenxu12345 17e1fa54cf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-11 12:13:43 +08:00
wenxu12345 a4f5dd9d89 add log 2022-05-11 12:13:17 +08:00
wangchuxiao 6269902140 update app 2022-05-11 11:07:04 +08:00
wangchuxiao b964e424b2 update app 2022-05-11 10:47:32 +08:00
wangchuxiao 73665f62b3 update app 2022-05-11 10:46:54 +08:00
wangchuxiao 3fca780132 update app 2022-05-11 10:27:00 +08:00
wangchuxiao b5e01dcb5e update app 2022-05-11 10:24:11 +08:00
wangchuxiao f180b89a9c Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-11 10:20:13 +08:00
wangchuxiao 98a903e60c update app 2022-05-11 10:19:58 +08:00
Gordon c20cc8fb18 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-11 09:55:13 +08:00
Gordon 99f5c4e12f update sarama version 2022-05-11 09:54:47 +08:00
wangchuxiao 17759f9a98 update app 2022-05-10 19:28:36 +08:00
wangchuxiao 6c0e96213f update app 2022-05-10 19:04:08 +08:00
wangchuxiao 2c89d80a27 update app 2022-05-10 18:28:57 +08:00
wangchuxiao e314fd4a0a update app 2022-05-10 18:22:18 +08:00
wangchuxiao affbe9f5a9 update app 2022-05-10 17:50:57 +08:00
wangchuxiao 7a423eb6e1 update app 2022-05-10 17:50:22 +08:00
wangchuxiao 7137924baa update app 2022-05-10 17:39:27 +08:00
wangchuxiao c998bce34f update app 2022-05-10 17:23:28 +08:00
wangchuxiao f5d4397f0b update app 2022-05-10 17:17:20 +08:00
wangchuxiao 608b166b32 update app 2022-05-10 17:00:52 +08:00
wangchuxiao 472cda8315 update app 2022-05-10 16:59:45 +08:00
wangchuxiao 7a78e5d869 update app 2022-05-10 16:53:58 +08:00
wangchuxiao 8effca3a7c update app 2022-05-10 16:39:08 +08:00
wangchuxiao fab52b6a56 update app 2022-05-10 16:23:56 +08:00
wangchuxiao e98ef5f5f2 update app 2022-05-10 16:22:16 +08:00
wangchuxiao 7aa84607c8 update app 2022-05-10 16:21:26 +08:00
wangchuxiao 928fc374c7 update app 2022-05-10 16:07:58 +08:00
wangchuxiao 4ea8cb5903 update app 2022-05-10 16:04:26 +08:00
wangchuxiao db6acacf2e update app 2022-05-10 16:02:05 +08:00
wangchuxiao 59aa71b3b8 update app 2022-05-10 15:58:29 +08:00
wangchuxiao ccfa487493 update app 2022-05-10 15:41:59 +08:00
wangchuxiao 9fcc41aeff update app 2022-05-10 15:34:00 +08:00
wangchuxiao d9a4fa3f49 update app 2022-05-10 15:21:51 +08:00
wangchuxiao 6c821dc42a update app 2022-05-10 15:16:20 +08:00
wangchuxiao d58e34ed3d update app 2022-05-10 15:07:07 +08:00
wangchuxiao ff37d1cb02 update app 2022-05-10 14:57:54 +08:00
wangchuxiao dcf119ae59 update app 2022-05-10 14:38:43 +08:00
wangchuxiao 1338cf875a update app 2022-05-10 14:20:15 +08:00
wangchuxiao ed3e299e0b update app 2022-05-10 14:18:36 +08:00
wangchuxiao f85645a78a update app 2022-05-10 14:17:31 +08:00
wangchuxiao e412abd017 update app 2022-05-10 14:07:44 +08:00
wangchuxiao 1efa654e7d update app 2022-05-10 13:06:13 +08:00
wangchuxiao 00b58068dc Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-10 12:30:16 +08:00
wangchuxiao 7be5208daf update app 2022-05-10 12:30:00 +08:00
wenxu12345 7ad555a41b add ParseToken 2022-05-10 12:20:53 +08:00
wenxu12345 872f70a418 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 12:07:33 +08:00
wenxu12345 c37d2e78d2 add ParseToken 2022-05-10 12:07:09 +08:00
wangchuxiao b606d066fc Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-10 12:07:07 +08:00
wangchuxiao d4608eec26 update app 2022-05-10 12:05:02 +08:00
wenxu12345 0bc8e231ad Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 12:01:26 +08:00
wenxu12345 2dab5e4a78 add ParseToken 2022-05-10 11:57:25 +08:00
wangchuxiao c6aa37851d Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-10 11:53:08 +08:00
wangchuxiao 31bd106ffd update app 2022-05-10 11:52:52 +08:00
wenxu12345 74cea2b41c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 11:49:11 +08:00
wangchuxiao 46f9a00b75 update app 2022-05-10 11:48:33 +08:00
wenxu12345 450d8c21cf Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 11:48:28 +08:00
wenxu12345 2073bc77c8 add ParseToken 2022-05-10 11:48:10 +08:00
wangchuxiao b6a5501f71 update app 2022-05-10 11:41:13 +08:00
wangchuxiao e27b98cdc1 update app 2022-05-10 11:40:40 +08:00
wangchuxiao 8af500462f update app 2022-05-10 11:22:10 +08:00
wangchuxiao 30fc4c28b7 cache 2022-05-10 11:17:54 +08:00
Gordon 74b582369a log change 2022-05-10 11:00:15 +08:00
Gordon c9ab2b507b Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 10:52:43 +08:00
Gordon 2b479319c1 log change 2022-05-10 10:52:32 +08:00
wangchuxiao 3a3ac012bb Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-10 10:45:21 +08:00
wangchuxiao 00265a7e8e cache 2022-05-10 10:44:43 +08:00
wenxu12345 0dafb50223 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 10:13:23 +08:00
wenxu12345 ac9620c253 add ParseToken 2022-05-10 10:12:53 +08:00
Gordon 6e226b165c sdk version 2022-05-10 10:01:46 +08:00
wenxu12345 6226f65e20 add ParseToken 2022-05-10 09:47:00 +08:00
wenxu12345 7de29c29e9 add ParseToken 2022-05-10 09:45:55 +08:00
wenxu12345 deed6c7bbe Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 09:17:22 +08:00
wenxu12345 c234e2ca3d log 2022-05-10 09:16:56 +08:00
Gordon 19bffa288d Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 09:13:34 +08:00
Gordon 9303096430 log change 2022-05-10 09:09:37 +08:00
wenxu12345 98d5f5ee3e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-10 09:09:20 +08:00
wenxu12345 ba16fceeb8 log 2022-05-10 09:06:49 +08:00
Gordon c49b5f78bf test 2022-05-09 18:45:44 +08:00
Gordon 446688d5b2 test 2022-05-09 18:34:14 +08:00
Gordon e2cacd9c4b test 2022-05-09 18:23:06 +08:00
Gordon d5c9e08888 manager send message to mysql duplicate primary key fix 2022-05-09 14:15:29 +08:00
skiffer-git ab0ead4e05 grpc 2022-05-09 11:39:55 +08:00
wenxu12345 9a267db583 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-09 11:38:22 +08:00
wenxu12345 fb15cbef90 grpc 1.45.0 2022-05-09 11:38:08 +08:00
wangchuxiao 97e5d9f610 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-09 10:00:12 +08:00
wangchuxiao 305ee394b1 cache 2022-05-09 10:00:03 +08:00
skiffer-git a251d521a1 set api ip in config 2022-05-07 19:52:18 +08:00
skiffer-git b5065cb52f Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-07 17:05:56 +08:00
skiffer-git dca16e83d3 rpc register ip 2022-05-07 17:05:05 +08:00
wangchuxiao c5256fe2cb Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-07 15:02:03 +08:00
wangchuxiao 1b93ba5355 cache 2022-05-07 15:01:48 +08:00
FG fd7171f5a4 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-07 14:25:54 +08:00
wangchuxiao 685fc1a37b cache 2022-05-07 14:13:47 +08:00
wangchuxiao a738c93163 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-07 13:21:22 +08:00
wangchuxiao 4ac863fa6a cache 2022-05-07 13:21:05 +08:00
skiffer-git fed369ad5d add err log 2022-05-07 12:04:07 +08:00
skiffer-git f2c91d015e add err log 2022-05-07 12:01:01 +08:00
skiffer-git e122349f9e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-07 11:55:32 +08:00
skiffer-git bb07c3ab45 add err log 2022-05-07 11:55:19 +08:00
wangchuxiao 65a4b38ee5 cache 2022-05-07 11:42:47 +08:00
wangchuxiao bbc3f5c19a cache 2022-05-07 11:39:27 +08:00
wangchuxiao 0b4ba548a5 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-07 11:14:56 +08:00
wangchuxiao 747b963bd4 cache 2022-05-07 11:14:29 +08:00
FG 32b9820725 remove timer and database init 2022-05-07 10:37:52 +08:00
skiffer-git b217fede87 upgrade etcd & grpc 2022-05-07 09:41:56 +08:00
skiffer-git a9ce8a3b2e upgrade etcd & grpc 2022-05-07 09:34:49 +08:00
wangchuxiao 7914e7bc14 office 2022-05-06 17:35:33 +08:00
wangchuxiao ed8716510b office 2022-05-06 17:32:52 +08:00
wangchuxiao efd2ae59f5 office 2022-05-06 17:23:37 +08:00
wangchuxiao 1923d0b809 office 2022-05-06 17:05:59 +08:00
wangchuxiao 99f6752590 office 2022-05-06 16:51:59 +08:00
wangchuxiao 131746f94e office 2022-05-06 16:51:34 +08:00
wangchuxiao f0ed6973c8 office 2022-05-06 16:50:19 +08:00
wangchuxiao 2cf070a26c office 2022-05-06 16:38:29 +08:00
wangchuxiao 3c68ecb7f1 office 2022-05-06 15:58:50 +08:00
wangchuxiao 243f5fcda4 fix bug 2022-05-06 11:19:16 +08:00
wangchuxiao e22b7f36ce fix bug 2022-05-06 11:07:32 +08:00
wangchuxiao 308ea15763 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-05 19:23:01 +08:00
wangchuxiao e26f9c58fa office 2022-05-05 19:22:47 +08:00
Gordon 4ca758174e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-05-05 16:14:16 +08:00
Gordon bf8e35e168 log change 2022-05-05 16:13:45 +08:00
wangchuxiao 2a3265ed71 office 2022-05-05 14:14:30 +08:00
wangchuxiao 3a06617a7d office 2022-05-05 11:59:44 +08:00
wangchuxiao d75eb456dc office 2022-05-05 11:58:48 +08:00
wangchuxiao 8ed0f8ec73 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-05-05 10:11:00 +08:00
skiffer-git 185e0dce6e delete msg by index 2022-05-04 18:35:13 +08:00
skiffer-git d9e74a78f0 delete msg by index 2022-05-04 18:02:24 +08:00
skiffer-git 700483dd48 group chat log 2022-05-02 20:03:13 +08:00
skiffer-git 1c80b820cb group chat log 2022-05-02 20:00:09 +08:00
skiffer-git 59e5cfb04d group chat log 2022-05-02 19:45:32 +08:00
skiffer-git b06550e2cb group chat log 2022-05-02 19:43:22 +08:00
skiffer-git ca4bf13569 group chat log 2022-05-02 19:23:26 +08:00
skiffer-git eae3a50435 group chat log 2022-05-02 19:16:00 +08:00
skiffer-git de2956ec3c group chat log 2022-05-02 08:47:21 +08:00
skiffer-git a2e62c9fb5 fix bug: group chat share pb 2022-05-01 16:21:28 +08:00
wangchuxiao e7fdc318f1 cache bug fix 2022-05-01 13:27:52 +08:00
wangchuxiao 62dd559b7c cache bug fix 2022-05-01 13:08:46 +08:00
skiffer-git 4a631753a0 add msgToMQSingle && msgToMQGroup 2022-05-01 12:04:31 +08:00
wangchuxiao b696984655 cache 2022-04-29 19:36:36 +08:00
wangchuxiao f1dbec122a cache 2022-04-29 18:59:08 +08:00
wangchuxiao 47cb54461f cache 2022-04-29 18:56:53 +08:00
wangchuxiao 91e03f7cfd cache 2022-04-29 18:53:33 +08:00
Gordon c0314d95c9 send message parallel 2022-04-29 18:47:55 +08:00
wenxu12345 8e17b3ff51 Revert "update etcd to v3.5.2 (#206)"
This reverts commit 766b6e9f
2022-04-29 18:45:11 +08:00
wenxu12345 b932a659b6 etcd 2022-04-29 18:35:55 +08:00
wenxu12345 80b2ed19e0 etcd 2022-04-29 18:32:46 +08:00
wenxu12345 88000926f4 etcd 2022-04-29 18:30:02 +08:00
wenxu12345 12245fefed etcd 2022-04-29 18:24:18 +08:00
wenxu12345 8eebd5fb9a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-29 18:20:09 +08:00
wenxu12345 c5b0e31d36 config 2022-04-29 18:19:59 +08:00
wangchuxiao 5c5e828cc6 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-29 18:00:29 +08:00
Gordon ecb11cf927 test 2022-04-29 17:59:53 +08:00
wangchuxiao 485241d080 cache & workMoments 2022-04-29 17:59:42 +08:00
Gordon 8701f8868c test 2022-04-29 17:58:57 +08:00
wenxu12345 e68086e149 config 2022-04-29 17:04:15 +08:00
wenxu12345 16a2d80801 config 2022-04-29 17:02:03 +08:00
wenxu12345 d5e5659a2c config 2022-04-29 16:42:42 +08:00
wenxu12345 3c2e8dcf87 config 2022-04-29 16:33:01 +08:00
wangchuxiao 03320e8644 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-29 15:52:18 +08:00
wangchuxiao 40ae6ccf2f cache & workMoments 2022-04-29 14:26:04 +08:00
Gordon bcbade3729 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-28 21:21:27 +08:00
Gordon 58a6f9cae3 test 2022-04-28 21:17:50 +08:00
Gordon bf154eb8c3 Merge branch 'main' into tuoyun
# Conflicts:
#	script/sdk_svr_start.sh
2022-04-28 21:12:14 +08:00
yiippee 766b6e9fef update etcd to v3.5.2 (#206)
Co-authored-by: lizhanbin <lizhanbin@52tt.com>
2022-04-28 21:09:43 +08:00
wangchuxiao d89a41d4c7 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-28 19:08:15 +08:00
wangchuxiao d24a7d7b22 cache & workMoments 2022-04-28 19:05:04 +08:00
wenxu12345 57a746fc21 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-28 19:01:20 +08:00
wenxu12345 2c1bd41fba ulimit -n 2022-04-28 19:00:37 +08:00
wangchuxiao 6260cf24cc cache 2022-04-28 18:25:10 +08:00
wangchuxiao 88d4a670d4 cache 2022-04-28 18:23:55 +08:00
wangchuxiao ea0b6c5ee5 cache 2022-04-28 17:38:09 +08:00
wangchuxiao 20f61042fc cache 2022-04-28 17:35:19 +08:00
wangchuxiao 2751a967e8 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-28 16:48:52 +08:00
wangchuxiao 93057870a7 cache 2022-04-28 16:48:39 +08:00
Gordon 6b98c3fed5 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-28 16:47:56 +08:00
Gordon eb63ed926d log modify 2022-04-28 16:47:46 +08:00
wangchuxiao b72787f5bb cache 2022-04-28 16:38:33 +08:00
wangchuxiao 0793b2ab38 cache 2022-04-28 16:29:40 +08:00
wangchuxiao 604ed3e3e1 cache 2022-04-28 16:19:51 +08:00
wangchuxiao 0aefbc2c7d Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
# Conflicts:
#	internal/rpc/friend/firend.go
2022-04-28 15:32:38 +08:00
wangchuxiao eb1fa90788 cache 2022-04-28 15:17:19 +08:00
wangchuxiao 65f02e5139 cache 2022-04-28 15:13:39 +08:00
Gordon bbfe65a905 send message add cache 2022-04-28 15:10:42 +08:00
wangchuxiao 59468eb162 fix work moments bug 2022-04-28 10:46:21 +08:00
wangchuxiao 1889a283ee fix work moments bug 2022-04-27 14:43:46 +08:00
wangchuxiao 0655b2021d Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-27 14:36:15 +08:00
wangchuxiao a1b8c9b6fd fix work moments bug 2022-04-27 14:35:02 +08:00
wenxu12345 c4a60bc6f6 Merge remote-tracking branch 'origin/main' 2022-04-27 10:09:18 +08:00
wenxu12345 eb7037eea8 ulimit -n 2022-04-27 10:09:05 +08:00
wenxu12345 7546083cd5 ulimit -n 2022-04-27 10:08:09 +08:00
wangchuxiao 74ee36f43a Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-26 20:20:39 +08:00
wangchuxiao f8c3e4d66f Merge branch 'tuoyun'
# Conflicts:
#	cmd/open_im_cms_api/main.go
#	config/config.yaml
2022-04-26 20:19:02 +08:00
wenxu12345 6db8d9a38a Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-26 18:26:48 +08:00
wenxu12345 61145a2d03 fix bug user_register port 2022-04-26 18:23:10 +08:00
wangchuxiao 4a9410742a Merge branch 'tuoyun'
# Conflicts:
#	cmd/open_im_cms_api/main.go
#	config/config.yaml
2022-04-26 16:50:43 +08:00
wangchuxiao db78e4ef03 Merge branch 'main' of github.com:OpenIMSDK/Open-IM-Server 2022-04-26 16:46:17 +08:00
wangchuxiao 7b0eb4e79d work moments 2022-04-26 16:24:43 +08:00
wangchuxiao 17f6b8eb2a work moments 2022-04-26 16:01:48 +08:00
wangchuxiao 37c40d7dda work moments 2022-04-26 15:52:03 +08:00
wangchuxiao 1a2aa876e3 work moments 2022-04-26 15:06:43 +08:00
wangchuxiao 39822f323f work moments 2022-04-26 15:05:23 +08:00
wangchuxiao 338acfba75 cache rpc 2022-04-26 14:57:15 +08:00
wangchuxiao 490f4f36f1 cache rpc 2022-04-26 14:43:55 +08:00
wangchuxiao 69c46f684f cache rpc 2022-04-26 14:38:11 +08:00
wangchuxiao 1626406557 cache rpc 2022-04-26 14:13:36 +08:00
wangchuxiao f662defcf9 cache rpc 2022-04-26 11:19:21 +08:00
wangchuxiao 8f07f8e9e1 cache rpc 2022-04-26 11:19:14 +08:00
wangchuxiao 7e44f7f110 cache rpc 2022-04-26 10:33:49 +08:00
skiffer-git b211a66e99 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-26 09:09:44 +08:00
skiffer-git 0bdb066820 add cache 2022-04-26 09:09:33 +08:00
wenxu12345 4ee84e10fd fix bug 2022-04-25 21:13:46 +08:00
wenxu12345 ab706f4076 fix bug 2022-04-25 21:13:32 +08:00
wangchuxiao bd7266653f cache rpc 2022-04-25 20:29:33 +08:00
wangchuxiao 08f968dced cache rpc 2022-04-25 20:20:34 +08:00
wangchuxiao 9f9ebd838a cache rpc 2022-04-25 20:16:43 +08:00
wangchuxiao a03f89fb68 cache rpc 2022-04-25 20:05:21 +08:00
wangchuxiao 51146a4ed5 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-25 19:57:54 +08:00
wangchuxiao 80301f2cb2 alter router 2022-04-25 19:57:35 +08:00
Gordon 9a9f26c435 conversation update 2022-04-25 19:56:46 +08:00
Gordon eebe9cbd5f conversation update 2022-04-25 19:41:17 +08:00
Gordon 503d43b552 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-25 19:15:01 +08:00
Gordon b3077fc15d conversation update 2022-04-25 19:14:51 +08:00
wenxu12345 fdc462d071 Adjust port 2022-04-25 17:30:13 +08:00
wenxu12345 f44a26da3c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-25 17:28:56 +08:00
wenxu12345 d12d03fd5e Adjust port 2022-04-25 17:28:43 +08:00
Gordon 51ee2df755 flag parse update 2022-04-25 17:13:54 +08:00
wenxu12345 a89bb33015 Adjust port 2022-04-25 16:58:35 +08:00
wenxu12345 7659cca8ba Adjust port 2022-04-25 16:58:05 +08:00
wenxu12345 f754e951f7 Adjust port 2022-04-25 16:55:56 +08:00
wenxu12345 e2905d01ac Adjust port 2022-04-25 16:47:51 +08:00
wenxu12345 9d691f2452 Adjust port 2022-04-25 16:21:48 +08:00
wenxu12345 a426c8bb26 Adjust port 2022-04-25 15:45:39 +08:00
wenxu12345 bc8b1722b0 config 2022-04-25 15:29:56 +08:00
wangchuxiao ac31c612b3 work_moments 2022-04-25 10:40:31 +08:00
wangchuxiao 03c3eea54e work_moments 2022-04-25 10:35:20 +08:00
wangchuxiao bccaf16343 work_moments 2022-04-25 10:07:14 +08:00
wangchuxiao 30df45ef2e work_moments 2022-04-24 18:49:03 +08:00
wangchuxiao 6500ba48a7 work_moments 2022-04-24 18:23:44 +08:00
wangchuxiao 03b35721a2 work_moments 2022-04-24 18:01:27 +08:00
wangchuxiao 14327d4462 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-24 18:00:18 +08:00
wangchuxiao 1b968903e2 work_moments 2022-04-24 18:00:04 +08:00
Gordon b719e95e6e Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-24 17:54:25 +08:00
Gordon 318eb2f47d shell update 2022-04-24 17:54:02 +08:00
wangchuxiao 010f24e5c3 work_moments 2022-04-24 17:46:47 +08:00
wangchuxiao db9762c5b2 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-24 17:44:10 +08:00
wangchuxiao d1ebcde725 work_moments 2022-04-24 17:42:41 +08:00
Gordon 545f9cad2d add modify conversation api 2022-04-24 17:30:53 +08:00
Gordon 3247d84b6b add modify conversation api 2022-04-24 17:27:26 +08:00
Gordon e73f0a916a add modify conversation api 2022-04-24 16:55:47 +08:00
Gordon 150af5ff8b @ people update 2022-04-24 15:55:19 +08:00
wangchuxiao 1659ab146d fix docker-compose 2022-04-24 11:57:21 +08:00
wangchuxiao 86e17d38d4 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-24 11:54:08 +08:00
Gordon 1809c59f25 config 2022-04-24 11:53:50 +08:00
wangchuxiao 4eb9661730 fix docker-compose 2022-04-24 11:50:36 +08:00
Gordon 4acbe4b31a config 2022-04-24 11:49:01 +08:00
Gordon df17dd749f add rpc conversation 2022-04-24 11:23:54 +08:00
wangchuxiao 20e5a88e56 Merge branch 'tuoyun' 2022-04-24 10:51:20 +08:00
wangchuxiao 0a939a5b91 Merge branch 'tuoyun'
# Conflicts:
#	config/config.yaml
2022-04-24 10:38:22 +08:00
wangchuxiao 6ad7c30a18 Merge branch 'main' of github.com:OpenIMSDK/Open-IM-Server 2022-04-24 10:34:54 +08:00
wangchuxiao e6bfc60139 Merge branch 'tuoyun'
# Conflicts:
#	config/config.yaml
2022-04-24 10:34:15 +08:00
Gordon c866baa4eb Merge branch 'tuoyun' 2022-04-22 19:46:31 +08:00
Gordon 91303acdbe conversation update 2022-04-22 19:45:29 +08:00
Gordon 1273af4b1b Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-22 19:45:10 +08:00
Gordon e682b408f3 conversation update 2022-04-22 19:44:58 +08:00
skiffer-git 0a0c206998 add cache 2022-04-22 18:56:39 +08:00
wangchuxiao 44ffd98d0c Merge branch 'tuoyun'
# Conflicts:
#	config/config.yaml
2022-04-22 18:37:59 +08:00
wangchuxiao 53ec93c8f8 minio config 2022-04-22 18:36:02 +08:00
wangchuxiao f779ed7628 workMoments 2022-04-22 17:19:35 +08:00
wangchuxiao f2fdb74f23 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-22 16:41:50 +08:00
wangchuxiao 4ba87e3349 workMoments 2022-04-22 16:41:41 +08:00
Gordon 7abee90992 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-22 15:12:21 +08:00
Gordon 159a9e00c8 conversation update 2022-04-22 15:12:10 +08:00
wangchuxiao 9c62f38345 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-21 18:39:01 +08:00
wangchuxiao 1443f5f997 workMoments 2022-04-21 18:38:48 +08:00
Gordon 17d8a124cd kick group invite group update 2022-04-21 18:09:20 +08:00
Gordon 5cd565306e kick group invite group update 2022-04-21 17:23:40 +08:00
Gordon 67010e20d7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-21 16:47:10 +08:00
Gordon 704604f6fe kick group invite group update 2022-04-21 16:46:48 +08:00
wangchuxiao e687f56c7f Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-21 16:14:41 +08:00
wangchuxiao ff85575e98 workMoments 2022-04-21 16:14:26 +08:00
Gordon 26be25c218 quit group and dismiss group update 2022-04-21 14:58:57 +08:00
Gordon d3d5e0cbfb Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-21 12:53:39 +08:00
Gordon 4796bf632c quit group and dismiss group update 2022-04-21 12:53:28 +08:00
wangchuxiao 5eef365baf workMoments 2022-04-21 11:52:31 +08:00
wangchuxiao 937ff63af9 workMoments 2022-04-21 11:34:15 +08:00
wangchuxiao 33211bfb27 workMoments 2022-04-21 11:18:11 +08:00
wangchuxiao a243da8b1e Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-21 10:43:46 +08:00
wangchuxiao 62e605a443 workMoments 2022-04-21 10:43:31 +08:00
skiffer-git 2bdaaa5a33 log 2022-04-20 20:58:51 +08:00
Gordon bcad3c1ced add save message to mysql switch 2022-04-20 18:53:23 +08:00
Gordon b865f5d6e7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-20 18:47:31 +08:00
Gordon 00664822ec conversation add fields 2022-04-20 18:47:21 +08:00
skiffer-git 4594c15de7 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-20 18:39:23 +08:00
skiffer-git 2b6ec1672c Organization 2022-04-20 18:39:12 +08:00
Gordon d44d5711cb Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-20 18:06:53 +08:00
Gordon 54cb13ba62 pb file 2022-04-20 18:06:43 +08:00
Gordon c32f5dd951 pb file 2022-04-20 18:06:24 +08:00
wangchuxiao 2e6c42c8ac workMoments 2022-04-20 16:33:19 +08:00
wangchuxiao 5757b86d39 workMoments 2022-04-20 16:32:22 +08:00
wangchuxiao 9df4a79827 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-20 16:25:48 +08:00
wangchuxiao 071dd46a4c workMoments 2022-04-20 16:25:33 +08:00
skiffer-git 030d619910 Organization 2022-04-20 11:53:32 +08:00
skiffer-git c56fd399c1 Organization 2022-04-20 09:07:35 +08:00
skiffer-git 31c954db0e Organization 2022-04-19 21:28:12 +08:00
skiffer-git cb6a040c4d Organization 2022-04-19 21:27:06 +08:00
skiffer-git 51c3a753a9 Organization 2022-04-19 20:57:59 +08:00
skiffer-git c28c592c80 OrganizationChangedNotification 2022-04-19 18:52:28 +08:00
skiffer-git fc07f851f7 OrganizationChangedNotification 2022-04-19 18:46:33 +08:00
skiffer-git ab4a5e6719 OrganizationChangedNotification 2022-04-19 18:46:02 +08:00
skiffer-git 88e9dd54b2 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-19 16:41:43 +08:00
skiffer-git f53f34559a organization 2022-04-19 16:40:57 +08:00
wangchuxiao 3e5d9a394f workMoments 2022-04-19 16:33:44 +08:00
wangchuxiao 3f287eb148 workMoments 2022-04-19 16:28:03 +08:00
wangchuxiao dfe854a236 workMoments 2022-04-19 16:15:41 +08:00
wangchuxiao 3854c7bba2 workMoments 2022-04-19 15:52:44 +08:00
wangchuxiao 01c066419d workMoments 2022-04-19 15:38:16 +08:00
wangchuxiao 040b1d9bc8 workMoments 2022-04-19 15:37:20 +08:00
wangchuxiao 6c4acbad68 workMoments 2022-04-19 14:54:43 +08:00
wangchuxiao b5c11ece57 workMoments 2022-04-19 14:33:48 +08:00
wangchuxiao 50696d2e88 workMoments 2022-04-19 14:12:30 +08:00
wangchuxiao e7661fd4be Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-19 13:06:10 +08:00
wangchuxiao 957e11eff0 workMoments 2022-04-19 13:05:54 +08:00
skiffer-git bd6e8d093a add operationID when ws connecting 2022-04-18 21:39:46 +08:00
skiffer-git f7b5a86a09 add operationID when ws connecting 2022-04-18 21:34:58 +08:00
skiffer-git 97fd107f47 add operationID when ws connecting 2022-04-18 21:29:48 +08:00
skiffer-git fc688dca99 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-18 21:16:56 +08:00
skiffer-git fe3bd2a1f1 add operationID when ws connecting 2022-04-18 21:16:23 +08:00
wangchuxiao 3625befc0b Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
# Conflicts:
#	pkg/common/constant/constant.go
2022-04-18 19:26:26 +08:00
wangchuxiao 6e6508aafd workMoments 2022-04-18 19:24:36 +08:00
skiffer-git 3a8a0a541e organization 2022-04-18 18:11:07 +08:00
skiffer-git 650495306f organization 2022-04-18 18:06:47 +08:00
skiffer-git 5664c34790 organization 2022-04-18 18:02:11 +08:00
skiffer-git b1c66997ca organization 2022-04-18 17:25:54 +08:00
skiffer-git 114ffd4667 organization 2022-04-18 16:58:41 +08:00
skiffer-git ad1770ec95 organization 2022-04-18 16:46:03 +08:00
skiffer-git 5f22402761 organization 2022-04-18 16:42:50 +08:00
skiffer-git c11094a11e organization 2022-04-18 16:27:04 +08:00
skiffer-git 6873bf384e organization 2022-04-18 16:24:12 +08:00
skiffer-git 42242daf9b organization 2022-04-18 16:18:10 +08:00
skiffer-git 1f96b960ab organization 2022-04-18 15:51:17 +08:00
skiffer-git f6b30ed0c6 organization 2022-04-18 15:45:44 +08:00
skiffer-git c59dc129a8 /user/get_users_online_status 2022-04-18 14:27:12 +08:00
skiffer-git 472c1a9e3e set group member nickname 2022-04-18 13:01:16 +08:00
skiffer-git 24fe8ab4a4 set group member nickname 2022-04-18 11:53:03 +08:00
skiffer-git 453c6f05bd set group member nickname 2022-04-18 11:52:49 +08:00
skiffer-git 248de7f1f2 set groupmember nickname 2022-04-18 11:52:17 +08:00
skiffer-git 3bbf84861e organization 2022-04-18 10:53:23 +08:00
skiffer-git 0dac9044a5 organization 2022-04-17 15:18:21 +08:00
skiffer-git a981d1082a organization 2022-04-17 15:11:27 +08:00
skiffer-git 803d0c2ae2 organization 2022-04-17 15:09:18 +08:00
skiffer-git 06e44cc649 organization 2022-04-17 15:03:50 +08:00
skiffer-git fd01e5c263 organization 2022-04-17 15:01:26 +08:00
skiffer-git ecc47dcfbb organization 2022-04-17 14:54:51 +08:00
skiffer-git b6e06dfdc2 organization 2022-04-17 14:47:52 +08:00
skiffer-git eb630b23ae organization 2022-04-17 14:45:45 +08:00
skiffer-git eae7a48991 organization 2022-04-17 14:44:44 +08:00
skiffer-git 9436c836e6 organization 2022-04-17 14:42:07 +08:00
skiffer-git 7c64239b36 organization 2022-04-17 14:39:48 +08:00
skiffer-git 80ba371296 organization 2022-04-17 12:41:42 +08:00
skiffer-git 6787563efe organization 2022-04-17 12:37:00 +08:00
skiffer-git 9def85f9ba organization 2022-04-17 12:32:28 +08:00
skiffer-git 6d55f35404 organization 2022-04-17 11:59:31 +08:00
skiffer-git 1902c37924 organization 2022-04-17 11:51:36 +08:00
skiffer-git 02b5ff38a4 organization 2022-04-16 21:41:38 +08:00
skiffer-git f076a927c9 organization 2022-04-16 21:34:29 +08:00
skiffer-git 6184eaa30e organization 2022-04-16 21:32:53 +08:00
skiffer-git a42b72e9ce organization 2022-04-16 21:31:28 +08:00
skiffer-git f4dcae722c organization 2022-04-16 21:28:37 +08:00
skiffer-git bbcb3e9403 organization 2022-04-16 21:26:16 +08:00
skiffer-git 3d690b7c72 organization 2022-04-16 21:23:38 +08:00
skiffer-git b4ab2c69ae organization 2022-04-16 21:20:17 +08:00
skiffer-git 4a7f406edb organization 2022-04-16 21:17:32 +08:00
skiffer-git 9e18bcaeb8 organization 2022-04-16 21:14:28 +08:00
skiffer-git 9abfe233bc organization 2022-04-16 21:10:46 +08:00
skiffer-git 3267958541 organization 2022-04-16 20:59:38 +08:00
skiffer-git af5ee45206 organization 2022-04-16 20:56:28 +08:00
skiffer-git 300b72b9b8 organization 2022-04-16 20:47:00 +08:00
skiffer-git 42af55a740 organization 2022-04-16 20:45:41 +08:00
skiffer-git 3c1e6d0e5c organization 2022-04-16 20:42:50 +08:00
skiffer-git edf7df368e organization 2022-04-16 20:30:02 +08:00
skiffer-git cde38e012f organization 2022-04-16 20:27:18 +08:00
skiffer-git bef4f0c4e2 organization 2022-04-16 20:25:01 +08:00
skiffer-git bf081dce32 organization 2022-04-16 20:22:01 +08:00
skiffer-git 0bb3cb4aab organization 2022-04-16 20:19:24 +08:00
skiffer-git 0d5132f710 organization 2022-04-16 20:17:21 +08:00
skiffer-git cad147faf8 organization 2022-04-16 20:14:47 +08:00
skiffer-git cc405b83e2 organization 2022-04-16 20:10:10 +08:00
skiffer-git c65f5b7279 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-15 20:37:26 +08:00
skiffer-git c216340120 organization 2022-04-15 19:48:17 +08:00
wangchuxiao ff5cbc490e getui 2022-04-15 18:22:27 +08:00
wangchuxiao 27cba5ba31 getui 2022-04-15 18:16:28 +08:00
wangchuxiao 9976b8132f getui 2022-04-15 17:45:33 +08:00
wangchuxiao dbc5bd96f3 getui 2022-04-15 17:43:04 +08:00
wangchuxiao 9489ab862b getui 2022-04-15 12:10:33 +08:00
wangchuxiao 1bb634bc6f merge code 2022-04-15 12:03:23 +08:00
wangchuxiao 07b5c7fef4 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-15 11:58:32 +08:00
wangchuxiao 4a7cfab543 getui 2022-04-15 11:56:36 +08:00
Gordon 426ef5cb88 push update 2022-04-13 18:34:36 +08:00
Gordon 5b86412407 Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-13 18:33:35 +08:00
Gordon 4f8fcd2d3d push update 2022-04-13 18:33:22 +08:00
wangchuxiao 16c40aa51c getui 2022-04-13 16:25:33 +08:00
Gordon 6449c4a53d push update 2022-04-13 16:20:30 +08:00
wangchuxiao d670356388 getui 2022-04-13 15:29:35 +08:00
wangchuxiao fb4c8549dc Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-13 15:22:03 +08:00
wangchuxiao 42dc5c1f0f getui 2022-04-13 15:21:53 +08:00
skiffer-git 659c3bc1cf add department db 2022-04-13 08:58:52 +08:00
skiffer-git f5684f2c45 add department db 2022-04-13 08:58:16 +08:00
skiffer-git 1d2d2b1c9c Merge remote-tracking branch 'origin/tuoyun' into tuoyun 2022-04-12 22:07:03 +08:00
skiffer-git bc06ba54b9 organization && department 2022-04-12 22:02:43 +08:00
wangchuxiao 1b6e223456 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-12 11:13:17 +08:00
wangchuxiao 9e4a2168c0 getui 2022-04-12 11:12:36 +08:00
Gordon 46aa26a444 version code 2022-04-12 09:51:25 +08:00
wangchuxiao 4d01aa3006 getui 2022-04-11 18:12:00 +08:00
wangchuxiao 2c308af615 getui 2022-04-11 17:58:23 +08:00
wangchuxiao caf4ab60cd minio add inner ip 2022-04-11 17:08:54 +08:00
wangchuxiao 4a8d37bde1 getui 2022-04-11 16:18:36 +08:00
wangchuxiao 3289dd8419 Merge branch 'tuoyun' 2022-04-11 15:09:24 +08:00
wangchuxiao 13473eeb4d getui 2022-04-11 14:44:58 +08:00
wangchuxiao 4264cd8830 Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun 2022-04-11 14:43:15 +08:00
wangchuxiao edcc215774 getui 2022-04-11 14:41:09 +08:00
skiffer-git 3085fffb49 add department db 2022-04-11 14:08:23 +08:00
wangchuxiao 81a6e4b46c getui 2022-04-11 11:31:20 +08:00
wangchuxiao e0d612c92f getui 2022-04-11 10:35:33 +08:00
wangchuxiao fadbb91287 getui 2022-04-08 19:31:13 +08:00
wangchuxiao 72146c08ae getui 2022-04-08 19:18:00 +08:00
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
skiffer-git b84dbbc3b8 notification 2021-12-14 15:11:35 +08:00
skiffer-git 7adde6a0a9 notification 2021-12-14 14:53:27 +08:00
289 changed files with 48768 additions and 13226 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
+2
View File
@@ -5,6 +5,8 @@ components
logs
out-test
.github
.idea
deploy/open_im_demo
deploy/open_im_api
+2
View File
@@ -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)
+138 -47
View File
@@ -7,100 +7,191 @@ import (
"Open_IM/internal/api/friend"
"Open_IM/internal/api/group"
"Open_IM/internal/api/manage"
"Open_IM/internal/api/office"
"Open_IM/internal/api/organization"
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)
gin.SetMode(gin.DebugMode)
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)
userRouterGroup.POST("/get_user_info", user.GetUserInfo)
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus)
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
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache)
userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache)
}
//friend routing group
friendRouterGroup := r.Group("/friend")
{
friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
friendRouterGroup.POST("/add_friend", friend.AddFriend)
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList)
friendRouterGroup.POST("/get_self_apply_list", friend.GetSelfApplyList)
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList)
friendRouterGroup.POST("/add_blacklist", friend.AddBlacklist)
friendRouterGroup.POST("/get_blacklist", friend.GetBlacklist)
friendRouterGroup.POST("/remove_blacklist", friend.RemoveBlacklist)
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend)
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse)
friendRouterGroup.POST("/set_friend_comment", friend.SetFriendComment)
friendRouterGroup.POST("/is_friend", friend.IsFriend)
friendRouterGroup.POST("/import_friend", friend.ImportFriend)
// 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)
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo)
groupRouterGroup.POST("join_group", group.JoinGroup)
groupRouterGroup.POST("/quit_group", group.QuitGroup)
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo)
groupRouterGroup.POST("/kick_group", group.KickGroupMember)
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList)
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMember)
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo)
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup)
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
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)
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
}
//certificate
authRouterGroup := r.Group("/auth")
{
authRouterGroup.POST("/user_register", apiAuth.UserRegister)
authRouterGroup.POST("/user_token", apiAuth.UserToken)
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //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)
thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp)
thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL)
}
//Message
chatGroup := r.Group("/chat")
chatGroup := r.Group("/msg")
{
chatGroup.POST("/newest_seq", apiChat.UserGetSeq)
chatGroup.POST("/pull_msg", apiChat.UserPullMsg)
chatGroup.POST("/send_msg", apiChat.UserSendMsg)
chatGroup.POST("/pull_msg_by_seq", apiChat.UserPullMsgBySeqList)
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)
managementGroup.POST("/delete_user", manage.DeleteUser) //1
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid)
managementGroup.POST("/account_check", manage.AccountCheck)
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus)
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)
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
}
// office
officeGroup := r.Group("/office")
{
conversationGroup.POST("/set_receive_message_opt", conversation.SetReceiveMessageOpt)
conversationGroup.POST("/get_receive_message_opt", conversation.GetReceiveMessageOpt)
conversationGroup.POST("/get_all_conversation_message_opt", conversation.GetAllConversationMessageOpt)
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)
officeGroup.POST("/create_one_work_moment", office.CreateOneWorkMoment)
officeGroup.POST("/delete_one_work_moment", office.DeleteOneWorkMoment)
officeGroup.POST("/like_one_work_moment", office.LikeOneWorkMoment)
officeGroup.POST("/comment_one_work_moment", office.CommentOneWorkMoment)
officeGroup.POST("/get_work_moment_by_id", office.GetWorkMomentByID)
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
officeGroup.POST("/delete_comment", office.DeleteComment)
}
log.NewPrivateLog("api")
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
organizationGroup := r.Group("/organization")
{
organizationGroup.POST("/create_department", organization.CreateDepartment)
organizationGroup.POST("/update_department", organization.UpdateDepartment)
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
organizationGroup.POST("/get_all_department", organization.GetAllDepartment)
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
organizationGroup.POST("/delete_organization_user", organization.DeleteOrganizationUser)
organizationGroup.POST("/create_department_member", organization.CreateDepartmentMember)
organizationGroup.POST("/get_user_in_department", organization.GetUserInDepartment)
organizationGroup.POST("/update_user_in_department", organization.UpdateUserInDepartment)
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
}
go apiThird.MinioInit()
ginPort := flag.Int("port", 10002, "get ginServerPort from cmd,default 10002 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start api server, address: ", address)
err := r.Run(address)
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
}
@@ -1,8 +1,9 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_timer_task
BINARY_NAME=open_im_cms_api
BIN_DIR=../../bin/
all: gotool build
build:
@@ -22,4 +23,3 @@ install:
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"Open_IM/internal/cms_api"
"Open_IM/pkg/utils"
"flag"
"fmt"
"strconv"
"Open_IM/pkg/common/config"
"github.com/gin-gonic/gin"
)
func main() {
gin.SetMode(gin.ReleaseMode)
router := cms_api.NewGinRouter()
router.Use(utils.CorsHandler())
ginPort := flag.Int("port", 10006, "get ginServerPort from cmd,default 10006 as port")
flag.Parse()
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start cms api server, address: ", address)
router.Run(address)
}
+24 -4
View File
@@ -2,28 +2,48 @@ package main
import (
"Open_IM/internal/demo/register"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
"fmt"
"io"
"os"
"strconv"
"Open_IM/pkg/common/config"
"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 := r.Group("/demo")
{
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)
}
log.NewPrivateLog("demo")
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))
fmt.Println("start demo api server, port: ", *ginPort)
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start demo api server address: ", address)
err := r.Run(address)
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
}
+5
View File
@@ -2,16 +2,21 @@ 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()
+5
View File
@@ -2,13 +2,18 @@ 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()
}
+5
View File
@@ -2,7 +2,10 @@ package main
import (
"Open_IM/internal/push/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"fmt"
"sync"
)
@@ -11,6 +14,8 @@ func main() {
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()
-65
View File
@@ -1,65 +0,0 @@
package main
import (
commonDB "Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"time"
)
func main() {
log.NewPrivateLog("timer")
//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.SelectAllUID()
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()
}
+3
View File
@@ -3,11 +3,14 @@ package main
import (
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()
}
+24
View File
@@ -0,0 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cache
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
+16
View File
@@ -0,0 +1,16 @@
package main
import (
rpcCache "Open_IM/internal/rpc/cache"
"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 := rpcCache.NewCacheServer(*rpcPort)
rpcServer.Run()
}
+24
View File
@@ -0,0 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_conversation
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
+16
View File
@@ -0,0 +1,16 @@
package main
import (
rpcConversation "Open_IM/internal/rpc/conversation"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 11400, "RpcConversation default listen port 11300")
flag.Parse()
fmt.Println("start conversation rpc server, port: ", *rpcPort)
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
rpcServer.Run()
}
+2
View File
@@ -3,12 +3,14 @@ package main
import (
"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()
}
+2
View File
@@ -3,11 +3,13 @@ package main
import (
"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()
}
+3 -1
View File
@@ -1,13 +1,15 @@
package main
import (
rpcChat "Open_IM/internal/rpc/chat"
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()
}
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_organization
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/organization"
"flag"
"fmt"
)
func main() {
rpcPort := flag.Int("port", 11200, "get RpcOrganizationPort from cmd,default 11200 as port")
flag.Parse()
fmt.Println("start organization rpc server, port: ", *rpcPort)
rpcServer := organization.NewServer(*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()
}
+2
View File
@@ -3,11 +3,13 @@ package main
import (
"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)
}
}
}
+558 -65
View File
@@ -1,50 +1,55 @@
# 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
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:13306 ]
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:37017 ]
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:16379
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"
ws2mschatoffline:
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
topic: "ws2ms_chat_offline"
ms2pschat:
addr: [ 127.0.0.1:9092 ]
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
topic: "ms2ps_chat"
consumergroupid:
msgToMongo: mongo
msgToMongoOffline: mongo_offline
msgToMySql: mysql
msgToPush: push
@@ -55,11 +60,18 @@ 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
#如果是单机模式,用0.0.0.0或者不填,默认即可
serverip: 0.0.0.0
rpcRegisterIP: 127.0.0.1
listenIP: 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
@@ -67,29 +79,65 @@ endpoints:
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: [ 10002 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
listenIP: 0.0.0.0
cmsapi:
openImCmsApiPort: [ 10006 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
listenIP: 0.0.0.0
sdk:
openImSdkWsPort: [ 30000 ]
credential:
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
dataDir: [ ../db/sdk/ ]
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
tencent:
appID: 1302656840
region: ap-chengdu
bucket: echat-1302656840
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
bucket: openim # 存储内容桶
appBucket: app # 存储app的桶
location: us-east-1
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
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:
openImUserPort: [ 10100 ]
openImFriendPort: [ 10200 ]
openImOfflineMessagePort: [ 10300]
openImOnlineRelayPort: [ 10400 ]
openImGroupPort: [ 10500 ]
openImAuthPort: [ 10600 ]
openImPushPort: [ 10700 ]
rpcport: #rpc服务端口 默认即可
openImUserPort: [ 10110 ]
openImFriendPort: [ 10120 ]
openImMessagePort: [ 10130 ]
openImMessageGatewayPort: [ 10140 ]
openImGroupPort: [ 10150 ]
openImAuthPort: [ 10160 ]
openImPushPort: [ 10170 ]
openImStatisticsPort: [ 10180 ]
openImMessageCmsPort: [ 10190 ]
openImAdminCmsPort: [ 10200 ]
openImOfficePort: [ 10210 ]
openImOrganizationPort: [ 10220 ]
openImConversationPort: [ 10230 ]
openImCachePort: [10240]
c2c:
callbackBeforeSendMsg:
switch: false
@@ -100,7 +148,7 @@ rpcport:
stateChange:
switch: false
rpcregistername:
rpcregistername: #rpc注册服务名,默认即可
openImUserName: User
openImFriendName: Friend
openImOfflineMessageName: OfflineMessage
@@ -108,85 +156,530 @@ rpcregistername:
openImOnlineMessageRelayName: OnlineMessageRelay
openImGroupName: Group
openImAuthName: Auth
openImStatisticsName: Statistics
openImMessageCMSName: MessageCMS
openImAdminCMSName: AdminCMS
openImOfficeName: Office
openImOrganizationName: Organization
openImConversationName: Conversation
openImCacheName: Cache
openImRealTimeCommName: RealTimeComm
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: [ 10001 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
websocketMaxConnNum: 10000
websocketMaxMsgLen: 4096
websocketTimeOut: 10
## 推送只能开启一个 enable代表开启
push:
tpns:
tpns: #腾讯推送,暂未测试 暂不要使用
ios:
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
android:
accessID: 111
secretKey: 111
jpns:
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
# 多端互踢策略
# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线
multiloginpolicy: 1
#chat log insert to db
chatPersistenceMysql: true
#token config
tokenpolicy:
accessSecret: "open_im_server"
accessSecret: "open_im_server" #token生成相关,默认即可
# Token effective time day as a unit
accessExpire: 7
accessExpire: 3650 #token过期时间(天) 默认即可
messageverify:
friendVerify: false
messagecallback:
callbackUrl: "http://www.xxx.com/msg/judge"
#TimeOut use second as unit
callbackTimeOut: 10
c2c:
callbackBeforeSendMsg:
# 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
timeoutStrategy: 1 #1:send
callbackAfterSendMsg:
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
state:
stateChange:
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"
groupMemberInfoSet:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: "groupMemberInfoSet title"
desc: "groupMemberInfoSet desc"
ext: "groupMemberInfoSet ext"
defaultTips:
tips: "group member info set"
organizationChanged:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: "organizationChanged title"
desc: "organizationChanged desc"
ext: "organizationChanged ext"
defaultTips:
tips: "organization changed"
#############################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: 3
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"
###################workMoments################
workMomentsNotification:
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"
###################organization################
joinDepartmentNotification:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "welcome user join department"
desc: "welcome user join department"
ext: "welcome user join department"
defaultTips:
tips: "welcome user join department"
#---------------demo configuration---------------------#
#The following configuration items are applied to openIM Demo configuration
#是否启动demo,如果自身没有账号体系,设置为true
demoswitch: true
demo:
openImDemoPort: [ 42233 ]
alismsverify:
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
signName: OpenIM Corporation
verificationCodeTemplateCode: SMS_2268101641
superCode: 666666
mail:
listenIP: 0.0.0.0
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
openImDemoPort: [ 10004 ]
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: "1765567899@qq.com"
senderAuthorizationCode: "1gxyausfoevlzbfag"
senderMail: "765567899@qq.com"
senderAuthorizationCode: "gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25
smtpPort: 25 #需开放此端口 出口方向
testDepartMentID: 001
rtc:
port: 11300
address: 127.0.0.1
+6 -1
View File
@@ -19,6 +19,7 @@ mysql:
dbMaxLifeTime: 120
mongo:
dbUri: ""#当dbUri值不为空则直接使用该值
dbAddress: [ openim_mongo:27017 ]
dbDirect: false
dbTimeout: 10
@@ -73,6 +74,8 @@ api:
openImApiPort: [ 10000 ]
sdk:
openImSdkWsPort: [ 30000 ]
cmsapi:
openImCmsApiPort: [ 8000 ]
credential:
tencent:
@@ -91,7 +94,9 @@ rpcport:
openImGroupPort: [ 10500 ]
openImAuthPort: [ 10600 ]
openImPushPort: [ 10700 ]
openImStatisticsPort: [ 10800 ]
openImMessageCmsPort: [ 10900 ]
openImAdminCmsPort: [ 11000 ]
rpcregistername:
openImUserName: User
+6 -1
View File
@@ -24,10 +24,15 @@ services:
- ./components/mongodb/data/db:/data/db
- ./components/mongodb/data/logs:/data/logs
- ./components/mongodb/data/conf:/etc/mongo
environment:
- TZ=Asia/Shanghai
# cache
- wiredTigerCacheSizeGB=1
# environment:
# - MONGO_INITDB_ROOT_USERNAME=openIM
# - MONGO_INITDB_ROOT_PASSWORD=openIM
#TZ: Asia/Shanghai
restart: always
@@ -89,7 +94,7 @@ services:
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
open_im_server:
image: openim/open_im_server
image: openim/open_im_server:v2.0.9
container_name: open_im_server
volumes:
- ./logs:/Open-IM-Server/logs
+17 -11
View File
@@ -3,51 +3,57 @@ module Open_IM
go 1.15
require (
github.com/Shopify/sarama v1.19.0
github.com/Shopify/sarama v1.32.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/bwmarrin/snowflake v0.3.0
github.com/dustin/go-humanize v1.0.0 // 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.14.0 // indirect
github.com/fatih/structs v1.1.0
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.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/mattn/go-sqlite3 v1.14.6 // indirect
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.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.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 v0.0.0-20200402134248-51bdeb39e698
go.etcd.io/etcd/api/v3 v3.5.4
go.etcd.io/etcd/client/v3 v3.5.4
go.mongodb.org/mongo-driver v1.8.3
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
google.golang.org/grpc v1.40.0
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 // indirect
google.golang.org/grpc v1.45.0
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-20210107192922-496545a6307b
sigs.k8s.io/yaml v1.2.0 // indirect
)
replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
+173 -493
View File
File diff suppressed because it is too large Load Diff
+126
View File
@@ -0,0 +1,126 @@
package apiAuth
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/auth"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/fatih/structs"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func UserRegister(c *gin.Context) {
params := api.UserRegisterReq{}
if err := c.BindJSON(&params); err != nil {
errMsg := " BindJSON failed " + err.Error()
log.NewError("0", errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
if params.Secret != config.Config.Secret {
errMsg := " params.Secret != config.Config.Secret "
log.NewError(params.OperationID, errMsg, params.Secret, config.Config.Secret)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
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 {
errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if reply.CommonResp.ErrCode != 0 {
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
replyToken, err := client.UserToken(context.Background(), pbDataToken)
if err != nil {
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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 {
errMsg := " BindJSON failed " + err.Error()
log.NewError("0", errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
if params.Secret != config.Config.Secret {
errMsg := params.OperationID + " 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": errMsg})
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 {
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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, "UserToken return ", resp)
c.JSON(http.StatusOK, resp)
}
func ParseToken(c *gin.Context) {
params := api.ParseTokenReq{}
if err := c.BindJSON(&params); err != nil {
errMsg := " BindJSON failed " + err.Error()
log.NewError("0", errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
var ok bool
var errInfo string
var expireTime int64
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
if !ok {
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(params.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: api.ExpireTime{ExpireTimeSeconds: uint32(expireTime)}}
resp.Data = structs.Map(&resp.ExpireTime)
log.NewInfo(params.OperationID, "ParseToken return ", resp)
c.JSON(http.StatusOK, resp)
}
-95
View File
@@ -1,95 +0,0 @@
package apiAuth
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbAuth "Open_IM/pkg/proto/auth"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsUserRegister struct {
Secret string `json:"secret" binding:"required,max=32"`
Platform int32 `json:"platform" binding:"required,min=1,max=7"`
UID string `json:"uid" binding:"required,min=1,max=64"`
Name string `json:"name" binding:"required,min=1,max=64"`
Icon string `json:"icon" binding:"omitempty,max=1024"`
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
Mobile string `json:"mobile" binding:"omitempty,max=32"`
Birth string `json:"birth" binding:"omitempty,max=16"`
Email string `json:"email" binding:"omitempty,max=64"`
Ex string `json:"ex" binding:"omitempty,max=1024"`
}
func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq {
pbData := pbAuth.UserRegisterReq{
UID: params.UID,
Name: params.Name,
Icon: params.Icon,
Gender: params.Gender,
Mobile: params.Mobile,
Birth: params.Birth,
Email: params.Email,
Ex: params.Ex,
}
return &pbData
}
func UserRegister(c *gin.Context) {
log.Info("", "", "api user_register init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := pbAuth.NewAuthClient(etcdConn)
//defer etcdConn.Close()
params := paramsUserRegister{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if params.Secret != config.Config.Secret {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
return
}
pbData := newUserRegisterReq(&params)
log.Info("", "", "api user_register is server, [data: %s]", pbData.String())
reply, err := client.UserRegister(context.Background(), pbData)
if err != nil || !reply.Success {
log.Error("", "", "api user_register call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api user_register call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
pbDataToken := &pbAuth.UserTokenReq{
Platform: params.Platform,
UID: params.UID,
}
replyToken, err := client.UserToken(context.Background(), pbDataToken)
if err != nil {
log.Error("", "", "api user_register call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api user_register call success, [data: %s] [reply: %s]", pbData.String(), reply.String())
if replyToken.ErrCode == 0 {
c.JSON(http.StatusOK, gin.H{
"errCode": replyToken.ErrCode,
"errMsg": replyToken.ErrMsg,
"data": gin.H{
"uid": pbData.UID,
"token": replyToken.Token,
"expiredTime": replyToken.ExpiredTime,
},
})
} else {
c.JSON(http.StatusOK, gin.H{
"errCode": replyToken.ErrCode,
"errMsg": replyToken.ErrMsg,
})
}
}
-72
View File
@@ -1,72 +0,0 @@
package apiAuth
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbAuth "Open_IM/pkg/proto/auth"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsUserToken struct {
Secret string `json:"secret" binding:"required,max=32"`
Platform int32 `json:"platform" binding:"required,min=1,max=8"`
UID string `json:"uid" binding:"required,min=1,max=64"`
}
func newUserTokenReq(params *paramsUserToken) *pbAuth.UserTokenReq {
pbData := pbAuth.UserTokenReq{
Platform: params.Platform,
UID: params.UID,
}
return &pbData
}
func UserToken(c *gin.Context) {
log.Info("", "", "api user_token init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := pbAuth.NewAuthClient(etcdConn)
//defer etcdConn.Close()
params := paramsUserToken{}
if err := c.BindJSON(&params); err != nil {
log.Error("", "", params.UID, params.Platform, params.Secret)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if params.Secret != config.Config.Secret {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
return
}
pbData := newUserTokenReq(&params)
log.Info("", "", "api user_token is server, [data: %s]", pbData.String())
reply, err := client.UserToken(context.Background(), pbData)
if err != nil {
log.Error("", "", "api user_token call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api user_token call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
if reply.ErrCode == 0 {
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"data": gin.H{
"uid": pbData.UID,
"token": reply.Token,
"expiredTime": reply.ExpiredTime,
},
})
} else {
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
})
}
}
+44
View File
@@ -0,0 +1,44 @@
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
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
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
+1 -5
View File
@@ -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()})
@@ -35,10 +35,6 @@ func UserGetSeq(c *gin.Context) {
pbData.UserID = params.SendID
pbData.OperationID = params.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", pbData.OperationID, "args", params)
}
msgClient := pbMsg.NewChatClient(grpcConn)
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
if err != nil {
+15 -75
View File
@@ -6,6 +6,8 @@ import (
"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"
@@ -22,64 +24,14 @@ type paramsUserPullMsg struct {
}
}
func UserPullMsg(c *gin.Context) {
params := paramsUserPullMsg{}
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 {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
return
}
pbData := pbChat.PullMessageReq{}
pbData.UserID = params.SendID
pbData.OperationID = params.OperationID
pbData.SeqBegin = *params.Data.SeqBegin
pbData.SeqEnd = *params.Data.SeqEnd
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.PullMessage(context.Background(), &pbData)
if err != nil {
log.NewError(params.OperationID, "UserPullMsg rpc failed, ", params, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserPullMsg rpc failed, " + err.Error()})
return
}
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
msg := make(map[string]interface{})
if v := reply.GetSingleUserMsg(); v != nil {
msg["single"] = v
} else {
msg["single"] = []pbChat.GatherFormat{}
}
if v := reply.GetGroupUserMsg(); v != nil {
msg["group"] = v
} else {
msg["group"] = []pbChat.GatherFormat{}
}
msg["maxSeq"] = reply.GetMaxSeq()
msg["minSeq"] = reply.GetMinSeq()
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"reqIdentifier": *params.ReqIdentifier,
"data": msg,
})
}
type paramsUserPullMsgBySeqList struct {
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
SendID string `json:"sendID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
SeqList []int64 `json:"seqList"`
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
SendID string `json:"sendID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
SeqList []uint32 `json:"seqList"`
}
func UserPullMsgBySeqList(c *gin.Context) {
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()})
@@ -88,10 +40,13 @@ func UserPullMsgBySeqList(c *gin.Context) {
token := c.Request.Header.Get("token")
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
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 := pbChat.PullMessageBySeqListReq{}
pbData := open_im_sdk.PullMessageBySeqListReq{}
pbData.UserID = params.SendID
pbData.OperationID = params.OperationID
pbData.SeqList = params.SeqList
@@ -100,29 +55,14 @@ func UserPullMsgBySeqList(c *gin.Context) {
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
if err != nil {
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
return
}
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
msg := make(map[string]interface{})
if v := reply.GetSingleUserMsg(); v != nil {
msg["single"] = v
} else {
msg["single"] = []pbChat.GatherFormat{}
}
if v := reply.GetGroupUserMsg(); v != nil {
msg["group"] = v
} else {
msg["group"] = []pbChat.GatherFormat{}
}
msg["maxSeq"] = reply.GetMaxSeq()
msg["minSeq"] = reply.GetMinSeq()
log.NewInfo(pbData.OperationID, "rpc call success to PullMessageBySeqList", reply.String(), len(reply.List))
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"reqIdentifier": params.ReqIdentifier,
"data": msg,
"data": reply.List,
})
}
+49 -51
View File
@@ -4,7 +4,7 @@ import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
pbChat "Open_IM/pkg/proto/chat"
"Open_IM/pkg/utils"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"context"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
@@ -14,81 +14,79 @@ import (
)
type paramsUserSendMsg struct {
ReqIdentifier int32 `json:"reqIdentifier" binding:"required"`
PlatformID int32 `json:"platformID" 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" binding:"required"`
ForceList []string `json:"forceList"`
Content string `json:"content" binding:"required"`
Options map[string]int32 `json:"options" `
ClientMsgID string `json:"clientMsgID" binding:"required"`
OffLineInfo map[string]interface{} `json:"offlineInfo" `
Ex map[string]interface{} `json:"ext"`
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.UserSendMsgReq {
pbData := pbChat.UserSendMsgReq{
ReqIdentifier: params.ReqIdentifier,
Token: token,
SendID: params.SendID,
SenderNickName: params.SenderNickName,
SenderFaceURL: params.SenderFaceURL,
OperationID: params.OperationID,
PlatformID: params.PlatformID,
SessionType: params.Data.SessionType,
MsgFrom: params.Data.MsgFrom,
ContentType: params.Data.ContentType,
RecvID: params.Data.RecvID,
ForceList: params.Data.ForceList,
Content: params.Data.Content,
Options: utils.MapIntToJsonString(params.Data.Options),
ClientMsgID: params.Data.ClientMsgID,
OffLineInfo: utils.MapToJsonString(params.Data.OffLineInfo),
Ex: utils.MapToJsonString(params.Data.Ex),
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 UserSendMsg(c *gin.Context) {
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"))
log.Error("0", "BindJSON failed ", err.Error())
return
}
token := c.Request.Header.Get("token")
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
log.NewInfo(params.OperationID, "api call success to sendMsgReq", params)
pbData := newUserSendMsgReq(token, &params)
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())
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 UserSendMsg call, api call rpc...")
log.Info("", "", "api SendMsg call, api call rpc...")
reply, err := client.UserSendMsg(context.Background(), pbData)
reply, err := client.SendMsg(context.Background(), pbData)
if err != nil {
log.NewError(params.OperationID, "UserSendMsg rpc failed, ", params, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserSendMsg rpc failed, " + err.Error()})
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 UserSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
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,
"reqIdentifier": reply.ReqIdentifier,
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"data": gin.H{
"clientMsgID": reply.ClientMsgID,
"serverMsgID": reply.ServerMsgID,
+216 -160
View File
@@ -1,11 +1,12 @@
package conversation
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"
"Open_IM/pkg/proto/user"
pbConversation "Open_IM/pkg/proto/conversation"
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
@@ -13,182 +14,237 @@ import (
"strings"
)
type paramsSetReceiveMessageOpt struct {
OperationID string `json:"operationID" binding:"required"`
Option *int32 `json:"option" binding:"required"`
ConversationIdList []string `json:"conversationIdList" binding:"required"`
}
type OptResult struct {
ConversationId string `json:"conversationId" binding:"required"`
Result int32 `json:"result" binding:"required"`
}
type SetReceiveMessageOptResp struct {
ErrCode int32 `json:"errCode"`
ErrMsg string `json:"errMsg"`
Data []OptResult `json:"data"`
}
type paramGetReceiveMessageOpt struct {
ConversationIdList []string `json:"conversationIdList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type GetReceiveMessageOptResp struct {
SetReceiveMessageOptResp
}
type paramGetAllConversationMessageOpt struct {
OperationID string `json:"operationID" binding:"required"`
}
type GetAllConversationMessageOptResp struct {
SetReceiveMessageOptResp
}
//CopyStructFields
func GetAllConversationMessageOpt(c *gin.Context) {
params := paramGetAllConversationMessageOpt{}
if err := c.BindJSON(&params); err != nil {
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
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
}
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbUser.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
return
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
req := &user.GetAllConversationMsgOptReq{
UId: claims.UID,
OperationID: params.OperationID,
}
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt req: ", req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := user.NewUserClient(etcdConn)
resp, err := client.GetAllConversationMsgOpt(context.Background(), req)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetConversation(context.Background(), &reqPb)
if err != nil {
log.NewError(params.OperationID, "GetAllConversationMsgOpt rpc failed, ", req, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
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
}
var ginResp GetAllConversationMessageOptResp
ginResp.ErrCode = resp.ErrCode
ginResp.ErrMsg = resp.ErrMsg
for _, v := range resp.ConversationOptResult {
var opt OptResult
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
if err != nil {
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
continue
}
ginResp.Data = append(ginResp.Data, opt)
}
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt resp: ", ginResp, req)
c.JSON(http.StatusOK, ginResp)
resp.ErrMsg = respPb.CommonResp.ErrMsg
resp.ErrCode = respPb.CommonResp.ErrCode
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetReceiveMessageOpt(c *gin.Context) {
params := paramGetReceiveMessageOpt{}
if err := c.BindJSON(&params); err != nil {
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
func ModifyConversationField(c *gin.Context) {
var (
req api.ModifyConversationFieldReq
resp api.ModifyConversationFieldResp
reqPb pbConversation.ModifyConversationFieldReq
)
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
}
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbConversation.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
client := pbConversation.NewConversationClient(etcdConn)
respPb, err := client.ModifyConversationField(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
}
req := &user.GetReceiveMessageOptReq{
UId: claims.UID,
ConversationId: params.ConversationIdList,
OperationID: params.OperationID,
}
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := user.NewUserClient(etcdConn)
resp, err := client.GetReceiveMessageOpt(context.Background(), req)
if err != nil {
log.NewError(params.OperationID, "GetReceiveMessageOpt rpc failed, ", req, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()})
return
}
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req, resp)
var ginResp GetReceiveMessageOptResp
ginResp.ErrCode = resp.ErrCode
ginResp.ErrMsg = resp.ErrMsg
for _, v := range resp.ConversationOptResult {
var opt OptResult
log.NewInfo("CopyStructFields begin ", v, req.OperationID)
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
log.NewInfo("CopyStructFields end ", v, req.OperationID)
if err != nil {
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
continue
}
ginResp.Data = append(ginResp.Data, opt)
}
log.NewInfo(req.OperationID, "GetReceiveMessageOpt resp: ", ginResp)
c.JSON(http.StatusOK, ginResp)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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) {
params := paramsSetReceiveMessageOpt{}
if err := c.BindJSON(&params); err != nil {
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
if err != nil {
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
return
}
req := &user.SetReceiveMessageOptReq{
UId: claims.UID,
Opt: *params.Option,
ConversationId: params.ConversationIdList,
OperationID: params.OperationID,
}
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := user.NewUserClient(etcdConn)
resp, err := client.SetReceiveMessageOpt(context.Background(), req)
if err != nil {
log.NewError(params.OperationID, "SetReceiveMessageOpt rpc failed, ", req, err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()})
return
}
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req, resp)
ginResp := SetReceiveMessageOptResp{
ErrCode: resp.ErrCode,
ErrMsg: resp.ErrMsg,
}
for _, v := range resp.OptResult {
var opt OptResult
log.NewDebug("CopyStructFields begin ", v, req.OperationID)
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
log.NewDebug("CopyStructFields end ", v, req.OperationID)
if err != nil {
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
continue
}
ginResp.Data = append(ginResp.Data, opt)
}
log.NewInfo(req.OperationID, "SetReceiveMessageOpt resp: ", ginResp)
c.JSON(http.StatusOK, ginResp)
}
//Deprecated
func GetReceiveMessageOpt(c *gin.Context) {
}
//Deprecated
func GetAllConversationMessageOpt(c *gin.Context) {
}
-49
View File
@@ -1,49 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
/*
type paramsAddBlackList struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
}*/
func AddBlacklist(c *gin.Context) {
log.Info("", "", "api add blacklist init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsSearchFriend{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.AddBlacklistReq{
Uid: params.UID,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
OwnerUid: params.OwnerUid,
}
log.Info(req.Token, req.OperationID, "api add blacklist is server:userID=%s", req.Uid)
RpcResp, err := client.AddBlacklist(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call add blacklist rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add blacklist rpc server failed"})
return
}
log.InfoByArgs("call add blacklist rpc server success,args=%s", RpcResp.String())
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
log.InfoByArgs("api add blacklist success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-88
View File
@@ -1,88 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsImportFriendReq struct {
OperationID string `json:"operationID" binding:"required"`
UIDList []string `json:"uidList" binding:"required"`
OwnerUid string `json:"ownerUid" binding:"required"`
}
type paramsAddFriend struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
ReqMessage string `json:"reqMessage"`
}
//
func ImportFriend(c *gin.Context) {
log.Info("", "", "ImportFriend init ....")
log.NewDebug("", "api importFriend start")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
params := paramsImportFriendReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.ImportFriendReq{
UidList: params.UIDList,
OperationID: params.OperationID,
OwnerUid: params.OwnerUid,
Token: c.Request.Header.Get("token"),
}
log.NewDebug(req.OperationID, "args is ", req.String())
RpcResp, err := client.ImportFriend(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "rpc importFriend failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed " + err.Error()})
return
}
failedUidList := make([]string, 0)
for _, v := range RpcResp.FailedUidList {
failedUidList = append(failedUidList, v)
}
log.NewDebug(req.OperationID, "rpc importFriend success", RpcResp.CommonResp.ErrorMsg, RpcResp.CommonResp.ErrorCode, RpcResp.FailedUidList)
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": failedUidList})
}
func AddFriend(c *gin.Context) {
log.Info("", "", "api add friend init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
params := paramsAddFriend{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.AddFriendReq{
Uid: params.UID,
OperationID: params.OperationID,
ReqMessage: params.ReqMessage,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api add friend is server")
RpcResp, err := client.AddFriend(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call add friend rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
return
}
log.InfoByArgs("call add friend rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
})
}
@@ -1,49 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsAddFriendResponse struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
Flag int32 `json:"flag" binding:"required"`
}
func AddFriendResponse(c *gin.Context) {
log.Info("", "", fmt.Sprintf("api add friend response init ...."))
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsAddFriendResponse{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.AddFriendResponseReq{
Uid: params.UID,
Flag: params.Flag,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api add friend response is server:userID=%s", req.Uid)
RpcResp, err := client.AddFriendResponse(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call add_friend_response rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add_friend_response rpc server failed"})
return
}
log.InfoByArgs("call add friend response rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
log.InfoByArgs("api add friend response success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-48
View File
@@ -1,48 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsDeleteFriend struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
}
func DeleteFriend(c *gin.Context) {
log.Info("", "", fmt.Sprintf("api delete_friend init ...."))
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsDeleteFriend{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.DeleteFriendReq{
Uid: params.UID,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api delete_friend is server:%s", req.Uid)
RpcResp, err := client.DeleteFriend(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call delete_friend rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete_friend rpc server failed"})
return
}
log.InfoByArgs("call delete_friend rpc server,args=%s", RpcResp.String())
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
log.InfoByArgs("api delete_friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
+466
View File
@@ -0,0 +1,466 @@
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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 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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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)
}
-79
View File
@@ -1,79 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGetBlackList struct {
OperationID string `json:"operationID" binding:"required"`
}
type blackListUserInfo struct {
UID string `json:"uid"`
Name string `json:"name"`
Icon string `json:"icon"`
Gender int32 `json:"gender"`
Mobile string `json:"mobile"`
Birth string `json:"birth"`
Email string `json:"email"`
Ex string `json:"ex"`
}
func GetBlacklist(c *gin.Context) {
log.Info("", "", "api get blacklist init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsGetBlackList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.GetBlacklistReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, fmt.Sprintf("api get blacklist is server"))
RpcResp, err := client.GetBlacklist(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get_friend_list rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get blacklist rpc server failed"})
return
}
log.InfoByArgs("call get blacklist rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
userBlackList := make([]blackListUserInfo, 0)
for _, friend := range RpcResp.Data {
var fi blackListUserInfo
fi.UID = friend.Uid
fi.Name = friend.Name
fi.Icon = friend.Icon
fi.Gender = friend.Gender
fi.Mobile = friend.Mobile
fi.Birth = friend.Birth
fi.Email = friend.Email
fi.Ex = friend.Ex
userBlackList = append(userBlackList, fi)
}
resp := gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
"data": userBlackList,
}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
}
log.InfoByArgs("api get black list success return,get args=%s,return=%s", req.String(), RpcResp.String())
}
@@ -1,129 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGetApplyList struct {
OperationID string `json:"operationID" binding:"required"`
}
type UserInfo struct {
UID string `json:"uid"`
Name string `json:"name"`
Icon string `json:"icon"`
Gender int32 `json:"gender"`
Mobile string `json:"mobile"`
Birth string `json:"birth"`
Email string `json:"email"`
Ex string `json:"ex"`
ReqMessage string `json:"reqMessage"`
ApplyTime string `json:"applyTime"`
Flag int32 `json:"flag"`
}
func GetFriendApplyList(c *gin.Context) {
log.Info("", "", "api get_friend_apply_list init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsGetApplyList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.GetFriendApplyReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api get friend apply list is server")
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get friend apply list rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend apply list rpc server failed"})
return
}
log.InfoByArgs("call get friend apply list rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
userInfoList := make([]UserInfo, 0)
for _, applyUserinfo := range RpcResp.Data {
var un UserInfo
un.UID = applyUserinfo.Uid
un.Name = applyUserinfo.Name
un.Icon = applyUserinfo.Icon
un.Gender = applyUserinfo.Gender
un.Mobile = applyUserinfo.Mobile
un.Birth = applyUserinfo.Birth
un.Email = applyUserinfo.Email
un.Ex = applyUserinfo.Ex
un.Flag = applyUserinfo.Flag
un.ApplyTime = applyUserinfo.ApplyTime
un.ReqMessage = applyUserinfo.ReqMessage
userInfoList = append(userInfoList, un)
}
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
}
log.InfoByArgs("api get friend apply list success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
func GetSelfApplyList(c *gin.Context) {
log.Info("", "", "api get self friend apply list init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsGetApplyList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.GetFriendApplyReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api get self apply list is server")
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get self apply list rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get self apply list rpc server failed"})
return
}
log.InfoByArgs("call get self apply list rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
userInfoList := make([]UserInfo, 0)
for _, selfApplyOtherUserinfo := range RpcResp.Data {
var un UserInfo
un.UID = selfApplyOtherUserinfo.Uid
un.Name = selfApplyOtherUserinfo.Name
un.Icon = selfApplyOtherUserinfo.Icon
un.Gender = selfApplyOtherUserinfo.Gender
un.Mobile = selfApplyOtherUserinfo.Mobile
un.Birth = selfApplyOtherUserinfo.Birth
un.Email = selfApplyOtherUserinfo.Email
un.Ex = selfApplyOtherUserinfo.Ex
un.Flag = selfApplyOtherUserinfo.Flag
un.ApplyTime = selfApplyOtherUserinfo.ApplyTime
un.ReqMessage = selfApplyOtherUserinfo.ReqMessage
userInfoList = append(userInfoList, un)
}
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
}
log.InfoByArgs("api get self apply list success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-83
View File
@@ -1,83 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGetFriendLIst struct {
OperationID string `json:"operationID" binding:"required"`
}
type friendInfo struct {
UID string `json:"uid"`
Name string `json:"name"`
Icon string `json:"icon"`
Gender int32 `json:"gender"`
Mobile string `json:"mobile"`
Birth string `json:"birth"`
Email string `json:"email"`
Ex string `json:"ex"`
Comment string `json:"comment"`
IsInBlackList int32 `json:"isInBlackList"`
}
func GetFriendList(c *gin.Context) {
log.Info("", "", fmt.Sprintf("api get_friendlist init ...."))
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsGetFriendLIst{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.GetFriendListReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api get friend list is server")
RpcResp, err := client.GetFriendList(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get friend list rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend list rpc server failed"})
return
}
log.InfoByArgs("call get friend list rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
friendsInfo := make([]friendInfo, 0)
for _, friend := range RpcResp.Data {
var fi friendInfo
fi.UID = friend.Uid
fi.Name = friend.Name
fi.Icon = friend.Icon
fi.Gender = friend.Gender
fi.Mobile = friend.Mobile
fi.Birth = friend.Birth
fi.Email = friend.Email
fi.Ex = friend.Ex
fi.Comment = friend.Comment
fi.IsInBlackList = friend.IsInBlackList
friendsInfo = append(friendsInfo, fi)
}
resp := gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
"data": friendsInfo,
}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
}
log.InfoByArgs("api get friend list success return,get args=%s,return=%s", req.String(), RpcResp.String())
}
-70
View File
@@ -1,70 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsSearchFriend struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
OwnerUid string `json:"ownerUid"`
}
func GetFriendsInfo(c *gin.Context) {
log.Info("", "", fmt.Sprintf("api search friend init ...."))
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsSearchFriend{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.GetFriendsInfoReq{
Uid: params.UID,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api search_friend is server")
RpcResp, err := client.GetFriendsInfo(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call search friend rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
return
}
log.InfoByArgs("call search friend rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
resp := gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
"data": gin.H{
"uid": RpcResp.Data.Uid,
"icon": RpcResp.Data.Icon,
"name": RpcResp.Data.Name,
"gender": RpcResp.Data.Gender,
"mobile": RpcResp.Data.Mobile,
"birth": RpcResp.Data.Birth,
"email": RpcResp.Data.Email,
"ex": RpcResp.Data.Ex,
"comment": RpcResp.Data.Comment,
},
}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
}
c.JSON(http.StatusOK, resp)
}
log.InfoByArgs("api search_friend success return,get args=%s,return=%s", req.String(), RpcResp.String())
}
-47
View File
@@ -1,47 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsIsFriend struct {
OperationID string `json:"operationID" binding:"required"`
ReceiveUid string `json:"receive_uid"`
}
func IsFriend(c *gin.Context) {
log.Info("", "", "api is friend init....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsIsFriend{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.IsFriendReq{
OperationID: params.OperationID,
ReceiveUid: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api is friend is server")
RpcResp, err := client.IsFriend(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call add friend rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
return
}
log.InfoByArgs("call is friend rpc server success,args=%s", RpcResp.String())
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "isFriend": RpcResp.ShipType}
c.JSON(http.StatusOK, resp)
log.InfoByArgs("api is friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-47
View File
@@ -1,47 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsRemoveBlackList struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
}
func RemoveBlacklist(c *gin.Context) {
log.Info("", "", "api remove_blacklist init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsRemoveBlackList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.RemoveBlacklistReq{
Uid: params.UID,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api remove blacklist is server:userID=%s", req.Uid)
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call remove blacklist rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call remove blacklist rpc server failed"})
return
}
log.InfoByArgs("call remove blacklist rpc server success,args=%s", RpcResp.String())
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
log.InfoByArgs("api remove blacklist success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-48
View File
@@ -1,48 +0,0 @@
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsSetFriendComment struct {
OperationID string `json:"operationID" binding:"required"`
UID string `json:"uid" binding:"required"`
Comment string `json:"comment"`
}
func SetFriendComment(c *gin.Context) {
log.Info("", "", "api set friend comment init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
//defer etcdConn.Close()
params := paramsSetFriendComment{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbFriend.SetFriendCommentReq{
Uid: params.UID,
OperationID: params.OperationID,
Comment: params.Comment,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api set friend comment is server")
RpcResp, err := client.SetFriendComment(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call set friend comment rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call set friend comment rpc server failed"})
return
}
log.Info("", "", "call set friend comment rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
log.Info("", "", "api set friend comment success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-61
View File
@@ -1,61 +0,0 @@
package group
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsCreateGroupStruct struct {
MemberList []*pb.GroupAddMemberInfo `json:"memberList"`
GroupName string `json:"groupName"`
Introduction string `json:"introduction"`
Notification string `json:"notification"`
FaceUrl string `json:"faceUrl"`
OperationID string `json:"operationID" binding:"required"`
Ex string `json:"ex"`
}
func CreateGroup(c *gin.Context) {
log.Info("", "", "api create group init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pb.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsCreateGroupStruct{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pb.CreateGroupReq{
MemberList: params.MemberList,
GroupName: params.GroupName,
Introduction: params.Introduction,
Notification: params.Notification,
FaceUrl: params.FaceUrl,
OperationID: params.OperationID,
Ex: params.Ex,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api create group is server,params=%s", req.String())
RpcResp, err := client.CreateGroup(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call create group rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.InfoByArgs("call create group rpc server success,args=%s", RpcResp.String())
if RpcResp.ErrorCode == 0 {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": gin.H{"groupID": RpcResp.GroupID}}
c.JSON(http.StatusOK, resp)
} else {
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
}
log.InfoByArgs("api create group success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
@@ -1,113 +0,0 @@
package group
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/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGroupApplicationList struct {
OperationID string `json:"operationID" binding:"required"`
}
func newUserRegisterReq(params *paramsGroupApplicationList) *group.GetGroupApplicationListReq {
pbData := group.GetGroupApplicationListReq{
OperationID: params.OperationID,
}
return &pbData
}
type paramsGroupApplicationListRet struct {
ID string `json:"id"`
GroupID string `json:"groupID"`
FromUserID string `json:"fromUserID"`
ToUserID string `json:"toUserID"`
Flag int32 `json:"flag"`
RequestMsg string `json:"reqMsg"`
HandledMsg string `json:"handledMsg"`
AddTime int64 `json:"createTime"`
FromUserNickname string `json:"fromUserNickName"`
ToUserNickname string `json:"toUserNickName"`
FromUserFaceUrl string `json:"fromUserFaceURL"`
ToUserFaceUrl string `json:"toUserFaceURL"`
HandledUser string `json:"handledUser"`
Type int32 `json:"type"`
HandleStatus int32 `json:"handleStatus"`
HandleResult int32 `json:"handleResult"`
}
func GetGroupApplicationList(c *gin.Context) {
log.Info("", "", "api GetGroupApplicationList init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := group.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsGroupApplicationList{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
pbData := newUserRegisterReq(&params)
token := c.Request.Header.Get("token")
if claims, err := token_verify.ParseToken(token); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
return
} else {
pbData.UID = claims.UID
}
log.Info("", "", "api GetGroupApplicationList is server, [data: %s]", pbData.String())
reply, err := client.GetGroupApplicationList(context.Background(), pbData)
if err != nil {
log.Error("", "", "api GetGroupApplicationList call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api GetGroupApplicationList call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
unProcessCount := 0
userReq := make([]paramsGroupApplicationListRet, 0)
if reply != nil && reply.Data != nil && reply.Data.User != nil {
for i := 0; i < len(reply.Data.User); i++ {
req := paramsGroupApplicationListRet{}
req.ID = reply.Data.User[i].ID
req.GroupID = reply.Data.User[i].GroupID
req.FromUserID = reply.Data.User[i].FromUserID
req.ToUserID = reply.Data.User[i].ToUserID
req.Flag = reply.Data.User[i].Flag
req.RequestMsg = reply.Data.User[i].RequestMsg
req.HandledMsg = reply.Data.User[i].HandledMsg
req.AddTime = reply.Data.User[i].AddTime
req.FromUserNickname = reply.Data.User[i].FromUserNickname
req.ToUserNickname = reply.Data.User[i].ToUserNickname
req.FromUserFaceUrl = reply.Data.User[i].FromUserFaceUrl
req.ToUserFaceUrl = reply.Data.User[i].ToUserFaceUrl
req.HandledUser = reply.Data.User[i].HandledUser
req.Type = reply.Data.User[i].Type
req.HandleStatus = reply.Data.User[i].HandleStatus
req.HandleResult = reply.Data.User[i].HandleResult
userReq = append(userReq, req)
if req.Flag == 0 {
unProcessCount++
}
}
}
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"data": gin.H{
"count": unProcessCount,
"user": userReq,
},
})
}
-67
View File
@@ -1,67 +0,0 @@
package group
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGetGroupInfo struct {
GroupIDList []string `json:"groupIDList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
func GetGroupsInfo(c *gin.Context) {
log.Info("", "", "api get groups info init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pb.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsGetGroupInfo{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pb.GetGroupsInfoReq{
GroupIDList: params.GroupIDList,
Token: c.Request.Header.Get("token"),
OperationID: params.OperationID,
}
log.Info(req.Token, req.OperationID, "get groups info is server,params=%s", req.String())
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "call get groups info rpc server failed,err=%s", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.InfoByArgs("call get groups info rpc server success", RpcResp.String())
if RpcResp.ErrorCode == 0 {
groupsInfo := make([]pb.GroupInfo, 0)
for _, v := range RpcResp.Data {
var groupInfo pb.GroupInfo
groupInfo.GroupId = v.GroupId
groupInfo.GroupName = v.GroupName
groupInfo.Notification = v.Notification
groupInfo.Introduction = v.Introduction
groupInfo.FaceUrl = v.FaceUrl
groupInfo.CreateTime = v.CreateTime
groupInfo.OwnerId = v.OwnerId
groupInfo.MemberCount = v.MemberCount
groupsInfo = append(groupsInfo, groupInfo)
}
c.JSON(http.StatusOK, gin.H{
"errCode": RpcResp.ErrorCode,
"errMsg": RpcResp.ErrorMsg,
"data": groupsInfo,
})
} else {
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
}
}
File diff suppressed because it is too large Load Diff
@@ -1,87 +0,0 @@
package group
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/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsGroupApplicationResponse struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
FromUserNickName string `json:"fromUserNickName"`
FromUserFaceUrl string `json:"fromUserFaceUrl"`
ToUserID string `json:"toUserID" binding:"required"`
ToUserNickName string `json:"toUserNickName"`
ToUserFaceUrl string `json:"toUserFaceUrl"`
AddTime int64 `json:"addTime"`
RequestMsg string `json:"requestMsg"`
HandledMsg string `json:"handledMsg"`
Type int32 `json:"type"`
HandleStatus int32 `json:"handleStatus"`
HandleResult int32 `json:"handleResult"`
}
func newGroupApplicationResponse(params *paramsGroupApplicationResponse) *group.GroupApplicationResponseReq {
pbData := group.GroupApplicationResponseReq{
OperationID: params.OperationID,
GroupID: params.GroupID,
FromUserID: params.FromUserID,
FromUserNickName: params.FromUserNickName,
FromUserFaceUrl: params.FromUserFaceUrl,
ToUserID: params.ToUserID,
ToUserNickName: params.ToUserNickName,
ToUserFaceUrl: params.ToUserFaceUrl,
AddTime: params.AddTime,
RequestMsg: params.RequestMsg,
HandledMsg: params.HandledMsg,
Type: params.Type,
HandleStatus: params.HandleStatus,
HandleResult: params.HandleResult,
}
return &pbData
}
func ApplicationGroupResponse(c *gin.Context) {
log.Info("", "", "api GroupApplicationResponse init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := group.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsGroupApplicationResponse{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
pbData := newGroupApplicationResponse(&params)
token := c.Request.Header.Get("token")
if claims, err := token_verify.ParseToken(token); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
return
} else {
pbData.OwnerID = claims.UID
}
log.Info("", "", "api GroupApplicationResponse is server, [data: %s]", pbData.String())
reply, err := client.GroupApplicationResponse(context.Background(), pbData)
if err != nil {
log.Error("", "", "api GroupApplicationResponse call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api GroupApplicationResponse call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
})
}
-47
View File
@@ -1,47 +0,0 @@
package group
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsJoinGroup struct {
GroupID string `json:"groupID" binding:"required"`
Message string `json:"message"`
OperationID string `json:"operationID" binding:"required"`
}
func JoinGroup(c *gin.Context) {
log.Info("", "", "api join group init....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pb.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsJoinGroup{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pb.JoinGroupReq{
GroupID: params.GroupID,
Message: params.Message,
Token: c.Request.Header.Get("token"),
OperationID: params.OperationID,
}
log.Info(req.Token, req.OperationID, "api join group is server,params=%s", req.String())
RpcResp, err := client.JoinGroup(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "call join group rpc server failed,err=%s", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.InfoByArgs("call join group rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
}
-46
View File
@@ -1,46 +0,0 @@
package group
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsQuitGroup struct {
GroupID string `json:"groupID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
func QuitGroup(c *gin.Context) {
log.Info("", "", "api quit group init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pb.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsQuitGroup{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pb.QuitGroupReq{
GroupID: params.GroupID,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.Info(req.Token, req.OperationID, "api quit group is server,params=%s", req.String())
RpcResp, err := client.QuitGroup(context.Background(), req)
if err != nil {
log.Error(req.Token, 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
}
log.InfoByArgs("call quit group rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
log.InfoByArgs("api quit group success return,get args=%s,return args=%s", req.String(), RpcResp.String())
}
-53
View File
@@ -1,53 +0,0 @@
package group
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pb "Open_IM/pkg/proto/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsSetGroupInfo struct {
GroupID string `json:"groupId" binding:"required"`
GroupName string `json:"groupName"`
Notification string `json:"notification"`
Introduction string `json:"introduction"`
FaceUrl string `json:"faceUrl"`
OperationID string `json:"operationID" binding:"required"`
}
func SetGroupInfo(c *gin.Context) {
log.Info("", "", "api set group info init...")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pb.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsSetGroupInfo{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pb.SetGroupInfoReq{
GroupID: params.GroupID,
GroupName: params.GroupName,
Notification: params.Notification,
Introduction: params.Introduction,
FaceUrl: params.FaceUrl,
Token: c.Request.Header.Get("token"),
OperationID: params.OperationID,
}
log.Info(req.Token, req.OperationID, "api set group info is server,params=%s", req.String())
RpcResp, err := client.SetGroupInfo(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "call set group info rpc server failed,err=%s", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.InfoByArgs("call set group info rpc server success,args=%s", RpcResp.String())
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
}
@@ -1,65 +0,0 @@
package group
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/group"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsTransferGroupOwner struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
UID string `json:"uid" binding:"required"`
}
func newTransferGroupOwnerReq(params *paramsTransferGroupOwner) *group.TransferGroupOwnerReq {
pbData := group.TransferGroupOwnerReq{
OperationID: params.OperationID,
GroupID: params.GroupID,
NewOwner: params.UID,
}
return &pbData
}
func TransferGroupOwner(c *gin.Context) {
log.Info("", "", "api TransferGroupOwner init ....")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := group.NewGroupClient(etcdConn)
//defer etcdConn.Close()
params := paramsTransferGroupOwner{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
pbData := newTransferGroupOwnerReq(&params)
token := c.Request.Header.Get("token")
if claims, err := token_verify.ParseToken(token); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
return
} else {
pbData.OldOwner = claims.UID
}
log.Info("", "", "api TransferGroupOwner is server, [data: %s]", pbData.String())
reply, err := client.TransferGroupOwner(context.Background(), pbData)
if err != nil {
log.Error("", "", "api TransferGroupOwner call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
log.Info("", "", "api TransferGroupOwner call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
})
}
+126 -66
View File
@@ -7,16 +7,20 @@
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"
@@ -24,22 +28,9 @@ import (
var validate *validator.Validate
type paramsManagementSendMsg struct {
OperationID string `json:"operationID" binding:"required"`
SendID string `json:"sendID" binding:"required"`
RecvID string `json:"recvID" binding:"required"`
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"`
}
func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
var newContent string
var err error
switch params.ContentType {
case constant.Text:
newContent = params.Content["text"].(string)
@@ -49,42 +40,62 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
fallthrough
case constant.Voice:
fallthrough
case constant.Video:
fallthrough
case constant.File:
newContent = utils.StructToJsonString(params.Content)
case constant.Revoke:
newContent = params.Content["revokeMsgClientID"].(string)
default:
}
options := make(map[string]int32, 2)
var options map[string]bool
if params.IsOnlineOnly {
options["history"] = 0
options["persistent"] = 0
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.UserSendMsgReq{
ReqIdentifier: constant.WSSendMsg,
SendID: params.SendID,
SenderNickName: params.SenderNickName,
SenderFaceURL: params.SenderFaceURL,
OperationID: params.OperationID,
PlatformID: params.SenderPlatformID,
SessionType: params.SessionType,
MsgFrom: constant.UserMsgType,
ContentType: params.ContentType,
RecvID: params.RecvID,
ForceList: params.ForceList,
Content: newContent,
ClientMsgID: utils.GetMsgID(params.SendID),
Options: utils.MapIntToJsonString(options),
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 := paramsManagementSendMsg{}
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"))
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
return
}
switch params.ContentType {
@@ -106,37 +117,57 @@ func ManagementSendMsg(c *gin.Context) {
//case constant.Location:
case constant.Custom:
data = CustomElem{}
//case constant.Revoke:
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"))
log.Error(c.PostForm("operationID"), "contentType err", 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())
log.Error(c.PostForm("operationID"), "content to Data struct 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())
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
return
}
log.NewInfo("", data, params)
token := c.Request.Header.Get("token")
claims, err := token_verify.ParseToken(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
}
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
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.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
pbData := newUserSendMsgReq(&params)
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
@@ -146,35 +177,58 @@ func ManagementSendMsg(c *gin.Context) {
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
reply, err := client.UserSendMsg(context.Background(), pbData)
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(), reply.String())
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)
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,
"sendTime": reply.SendTime,
"msgID": reply.ClientMsgID,
})
}
//
//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" validate:"required"`
Size int64 `mapstructure:"size" validate:"required"`
Width int32 `mapstructure:"width" validate:"required"`
Height int32 `mapstructure:"height" validate:"required"`
Url string `mapstructure:"url" validate:"required"`
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" validate:"required"`
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
}
@@ -206,12 +260,6 @@ type FileElem struct {
FileName string `mapstructure:"fileName"`
FileSize int64 `mapstructure:"fileSize"`
}
//type MergeElem struct {
// Title string `json:"title"`
// AbstractList []string `json:"abstractList"`
// MultiMessage []*MsgStruct `json:"multiMessage"`
//}
type AtElem struct {
Text string `mapstructure:"text"`
AtUserList []string `mapstructure:"atUserList"`
@@ -231,7 +279,19 @@ type TextElem struct {
Text string `mapstructure:"text" validate:"required"`
}
//type QuoteElem struct {
// Text string `json:"text"`
// QuoteMessage *MsgStruct `json:"quoteMessage"`
//}
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"`
}
+90 -77
View File
@@ -7,13 +7,14 @@
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"
pbUser "Open_IM/pkg/proto/user"
rpc "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
@@ -21,128 +22,138 @@ import (
"strings"
)
type paramsDeleteUsers struct {
OperationID string `json:"operationID" binding:"required"`
DeleteUidList []string `json:"deleteUidList" binding:"required"`
}
type paramsGetAllUsersUid struct {
OperationID string `json:"operationID" binding:"required"`
}
type paramsGetUsersOnlineStatus struct {
OperationID string `json:"operationID" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
}
type paramsAccountCheck struct {
OperationID string `json:"operationID" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required,lte=100"`
}
func DeleteUser(c *gin.Context) {
params := paramsDeleteUsers{}
params := api.DeleteUsersReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.InfoByKv("DeleteUser req come here", params.OperationID, "DeleteUidList", params.DeleteUidList)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
//defer etcdConn.Close()
req := &rpc.DeleteUsersReq{}
utils.CopyStructFields(req, &params)
req := &pbUser.DeleteUsersReq{
OperationID: params.OperationID,
DeleteUidList: params.DeleteUidList,
Token: c.Request.Header.Get("token"),
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
}
failedUidList := make([]string, 0)
for _, v := range RpcResp.FailedUidList {
failedUidList = append(failedUidList, v)
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.InfoByKv("call delete user rpc server is success", params.OperationID, "resp args", RpcResp.String())
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
c.JSON(http.StatusOK, resp)
}
func GetAllUsersUid(c *gin.Context) {
params := paramsGetAllUsersUid{}
params := api.GetAllUsersUidReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.InfoByKv("GetAllUsersUid req come here", params.OperationID)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
//defer etcdConn.Close()
req := &rpc.GetAllUserIDReq{}
utils.CopyStructFields(req, &params)
req := &pbUser.GetAllUsersUidReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
RpcResp, err := client.GetAllUsersUid(context.Background(), req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error(), "uidList": []string{}})
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.InfoByKv("call GetAllUsersUid rpc server is success", params.OperationID, "resp args", RpcResp.String())
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "uidList": RpcResp.UidList}
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 := paramsAccountCheck{}
params := api.AccountCheckReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.InfoByKv("AccountCheck req come here", params.OperationID, params.UserIDList)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
//defer etcdConn.Close()
req := &rpc.AccountCheckReq{}
utils.CopyStructFields(req, &params)
req := &pbUser.AccountCheckReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
UidList: params.UserIDList,
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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 {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
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
}
log.InfoByKv("call AccountCheck rpc server is success", params.OperationID, "resp args", RpcResp.String())
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "result": RpcResp.Result}
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 := paramsGetUsersOnlineStatus{}
params := api.GetUsersOnlineStatusReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
if err != nil {
log.ErrorByKv("parse token failed", params.OperationID, "err", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
req := &pbRelay.GetUsersOnlineStatusReq{}
utils.CopyStructFields(req, &params)
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
log.ErrorByKv(" Authentication failed", params.OperationID, "args", c)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 402, "errMsg": "not authorized"})
return
}
req := &pbRelay.GetUsersOnlineStatusReq{
OperationID: params.OperationID,
UserIDList: params.UserIDList,
}
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
flag := false
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
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)
@@ -156,7 +167,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
}
}
}
log.NewDebug(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
log.NewInfo(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
//Online data merge of each node
for _, v1 := range params.UserIDList {
flag = false
@@ -176,8 +187,10 @@ func GetUsersOnlineStatus(c *gin.Context) {
}
respResult = append(respResult, temp)
}
log.NewDebug(params.OperationID, "Finished merged data", respResult)
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
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)
}
+322
View File
@@ -0,0 +1,322 @@
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
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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())
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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())
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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())
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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())
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
}
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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)
}
+522
View File
@@ -0,0 +1,522 @@
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 CreateOneWorkMoment(c *gin.Context) {
var (
req apiStruct.CreateOneWorkMomentReq
resp apiStruct.CreateOneWorkMomentResp
reqPb pbOffice.CreateOneWorkMomentReq
respPb *pbOffice.CreateOneWorkMomentResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
reqPb.WorkMoment.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.CreateOneWorkMoment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CreateOneWorkMoment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateOneWorkMoment rpc server failed" + err.Error()})
return
}
resp.CommResp = apiStruct.CommResp{
ErrCode: respPb.CommonResp.ErrCode,
ErrMsg: respPb.CommonResp.ErrMsg,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func DeleteOneWorkMoment(c *gin.Context) {
var (
req apiStruct.DeleteOneWorkMomentReq
resp apiStruct.DeleteOneWorkMomentResp
reqPb pbOffice.DeleteOneWorkMomentReq
respPb *pbOffice.DeleteOneWorkMomentResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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.DeleteOneWorkMoment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteOneWorkMoment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "DeleteOneWorkMoment rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); 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 LikeOneWorkMoment(c *gin.Context) {
var (
req apiStruct.LikeOneWorkMomentReq
resp apiStruct.LikeOneWorkMomentResp
reqPb pbOffice.LikeOneWorkMomentReq
respPb *pbOffice.LikeOneWorkMomentResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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.LikeOneWorkMoment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "LikeOneWorkMoment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "LikeOneWorkMoment rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); 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 CommentOneWorkMoment(c *gin.Context) {
var (
req apiStruct.CommentOneWorkMomentReq
resp apiStruct.CommentOneWorkMomentResp
reqPb pbOffice.CommentOneWorkMomentReq
respPb *pbOffice.CommentOneWorkMomentResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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.CommentOneWorkMoment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CommentOneWorkMoment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CommentOneWorkMoment rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); 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 DeleteComment(c *gin.Context) {
var (
req apiStruct.DeleteCommentReq
resp apiStruct.DeleteCommentResp
reqPb pbOffice.DeleteCommentReq
respPb *pbOffice.DeleteCommentResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.DeleteComment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteComment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "DeleteComment rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); 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 GetWorkMomentByID(c *gin.Context) {
var (
req apiStruct.GetWorkMomentByIDReq
resp apiStruct.GetWorkMomentByIDResp
reqPb pbOffice.GetWorkMomentByIDReq
respPb *pbOffice.GetWorkMomentByIDResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.OpUserID = userID
reqPb.WorkMomentID = req.WorkMomentID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetWorkMomentByID(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserWorkMoments rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.WorkMoment = &apiStruct.WorkMoment{LikeUserList: []*apiStruct.WorkMomentUser{}, Comments: []*apiStruct.Comment{},
AtUserList: []*apiStruct.WorkMomentUser{}, PermissionUserList: []*apiStruct.WorkMomentUser{}}
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); 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 GetUserWorkMoments(c *gin.Context) {
var (
req apiStruct.GetUserWorkMomentsReq
resp apiStruct.GetUserWorkMomentsResp
reqPb pbOffice.GetUserWorkMomentsReq
respPb *pbOffice.GetUserWorkMomentsResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var opUserID string
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
ShowNumber: req.ShowNumber,
}
reqPb.OpUserID = opUserID
reqPb.UserID = req.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.GetUserWorkMoments(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserWorkMoments rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
return
}
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
//}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
UserID: comment.UserID,
UserName: comment.UserName,
ReplyUserID: comment.ReplyUserID,
ReplyUserName: comment.ReplyUserName,
ContentID: comment.ContentID,
Content: comment.Content,
CreateTime: comment.CreateTime,
}
}
for i, likeUser := range v.LikeUserList {
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
UserID: likeUser.UserID,
UserName: likeUser.UserName,
}
}
for i, atUser := range v.AtUserList {
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
UserID: atUser.UserID,
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
}
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetUserFriendWorkMoments(c *gin.Context) {
var (
req apiStruct.GetUserFriendWorkMomentsReq
resp apiStruct.GetUserFriendWorkMomentsResp
reqPb pbOffice.GetUserFriendWorkMomentsReq
respPb *pbOffice.GetUserFriendWorkMomentsResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
ShowNumber: req.ShowNumber,
}
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.GetUserFriendWorkMoments(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserFriendWorkMoments rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserFriendWorkMoments rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
//}
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
UserID: comment.UserID,
UserName: comment.UserName,
ReplyUserID: comment.ReplyUserID,
ReplyUserName: comment.ReplyUserName,
ContentID: comment.ContentID,
Content: comment.Content,
CreateTime: comment.CreateTime,
}
}
for i, likeUser := range v.LikeUserList {
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
UserID: likeUser.UserID,
UserName: likeUser.UserName,
}
}
for i, atUser := range v.AtUserList {
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
UserID: atUser.UserID,
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
}
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func SetUserWorkMomentsLevel(c *gin.Context) {
var (
req apiStruct.SetUserWorkMomentsLevelReq
resp apiStruct.SetUserWorkMomentsLevelResp
reqPb pbOffice.SetUserWorkMomentsLevelReq
respPb *pbOffice.SetUserWorkMomentsLevelResp
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
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.SetUserWorkMomentsLevel(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetUserWorkMomentsLevel rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "SetUserWorkMomentsLevel rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); 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)
}
+443
View File
@@ -0,0 +1,443 @@
package organization
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/organization"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func CreateDepartment(c *gin.Context) {
params := api.CreateDepartmentReq{}
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.CreateDepartmentReq{DepartmentInfo: &open_im_sdk.Department{}}
utils.CopyStructFields(req, &params)
utils.CopyStructFields(req.DepartmentInfo, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + " " + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.CreateDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc CreateDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.CreateDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, Department: RpcResp.DepartmentInfo}
apiResp.Data = jsonData.JsonDataOne(RpcResp.DepartmentInfo)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func UpdateDepartment(c *gin.Context) {
params := api.UpdateDepartmentReq{}
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.UpdateDepartmentReq{DepartmentInfo: &open_im_sdk.Department{}}
utils.CopyStructFields(req, &params)
utils.CopyStructFields(req.DepartmentInfo, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.UpdateDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc UpdateDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.UpdateDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func GetSubDepartment(c *gin.Context) {
params := api.GetSubDepartmentReq{}
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.GetSubDepartmentReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.GetSubDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc GetDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.GetSubDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, DepartmentList: RpcResp.DepartmentList}
apiResp.Data = jsonData.JsonDataList(RpcResp.DepartmentList)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func GetAllDepartment(c *gin.Context) {
}
func DeleteDepartment(c *gin.Context) {
params := api.DeleteDepartmentReq{}
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.DeleteDepartmentReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.DeleteDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc DeleteDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.DeleteDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func CreateOrganizationUser(c *gin.Context) {
params := api.CreateOrganizationUserReq{}
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.CreateOrganizationUserReq{OrganizationUser: &open_im_sdk.OrganizationUser{}}
utils.CopyStructFields(req, &params)
utils.CopyStructFields(req.OrganizationUser, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.CreateOrganizationUser(context.Background(), req)
if err != nil {
errMsg := "rpc CreateOrganizationUser failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.CreateOrganizationUserResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func UpdateOrganizationUser(c *gin.Context) {
params := api.UpdateOrganizationUserReq{}
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.UpdateOrganizationUserReq{OrganizationUser: &open_im_sdk.OrganizationUser{}}
utils.CopyStructFields(req, &params)
utils.CopyStructFields(req.OrganizationUser, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.UpdateOrganizationUser(context.Background(), req)
if err != nil {
errMsg := "rpc UpdateOrganizationUser failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.UpdateOrganizationUserResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func CreateDepartmentMember(c *gin.Context) {
params := api.CreateDepartmentMemberReq{}
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.CreateDepartmentMemberReq{DepartmentMember: &open_im_sdk.DepartmentMember{}}
utils.CopyStructFields(req, &params)
utils.CopyStructFields(req.DepartmentMember, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.CreateDepartmentMember(context.Background(), req)
if err != nil {
errMsg := "rpc CreateDepartmentMember failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.CreateDepartmentMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func GetUserInDepartment(c *gin.Context) {
params := api.GetUserInDepartmentReq{}
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.GetUserInDepartmentReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.GetUserInDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc GetUserInDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.GetUserInDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, UserInDepartment: RpcResp.UserInDepartment}
apiResp.Data = jsonData.JsonDataOne(RpcResp.UserInDepartment)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func UpdateUserInDepartment(c *gin.Context) {
params := api.UpdateUserInDepartmentReq{}
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.UpdateUserInDepartmentReq{DepartmentMember: &open_im_sdk.DepartmentMember{}}
utils.CopyStructFields(req.DepartmentMember, &params)
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.UpdateUserInDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc UpdateUserInDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.UpdateUserInDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func DeleteOrganizationUser(c *gin.Context) {
params := api.DeleteOrganizationUserReq{}
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.DeleteOrganizationUserReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.DeleteOrganizationUser(context.Background(), req)
if err != nil {
errMsg := "rpc DeleteOrganizationUser failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.DeleteOrganizationUserResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func GetDepartmentMember(c *gin.Context) {
params := api.GetDepartmentMemberReq{}
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.GetDepartmentMemberReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.GetDepartmentMember(context.Background(), req)
if err != nil {
errMsg := "rpc GetDepartmentMember failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.GetDepartmentMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, UserInDepartmentList: RpcResp.UserDepartmentMemberList}
apiResp.Data = jsonData.JsonDataList(RpcResp.UserDepartmentMemberList)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
func DeleteUserInDepartment(c *gin.Context) {
params := api.DeleteUserInDepartmentReq{}
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.DeleteUserInDepartmentReq{}
utils.CopyStructFields(req, &params)
err, opUserID := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
req.OpUserID = opUserID
if err != nil {
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := rpc.NewOrganizationClient(etcdConn)
RpcResp, err := client.DeleteUserInDepartment(context.Background(), req)
if err != nil {
errMsg := "rpc DeleteUserInDepartment failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
apiResp := api.DeleteUserInDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
c.JSON(http.StatusOK, apiResp)
}
+101
View File
@@ -0,0 +1,101 @@
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
}
var ok bool
var userID string
var errInfo string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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)
}
+88
View File
@@ -0,0 +1,88 @@
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)
var initUrl string
if config.Config.Credential.Minio.EndpointInnerEnable {
initUrl = config.Config.Credential.Minio.EndpointInner
} else {
initUrl = config.Config.Credential.Minio.Endpoint
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
minioUrl, err := url2.Parse(initUrl)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
opts := &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
}
if minioUrl.Scheme == "http" {
opts.Secure = false
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
MinioClient, err = minio.New(minioUrl.Host, opts)
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
}
}
// make app bucket
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, 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)
//err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policy.BucketPolicyReadWrite)
//if err != nil {
// log.NewDebug("", 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,245 @@
package apiThird
import (
apiStruct "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
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(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType, MinioClient.EndpointURL())
_, 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(), "upload file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + 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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
var stsOpts cr.STSAssumeRoleOptions
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
stsOpts.DurationSeconds = constant.MinioDurationTimes
var endpoint string
if config.Config.Credential.Minio.EndpointInnerEnable {
endpoint = config.Config.Credential.Minio.EndpointInner
} else {
endpoint = config.Config.Credential.Minio.Endpoint
}
li, err := cr.NewSTSAssumeRole(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})
}
func UploadUpdateApp(c *gin.Context) {
var (
req apiStruct.UploadUpdateAppReq
resp apiStruct.UploadUpdateAppResp
)
if err := c.Bind(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var yamlName string
if req.Yaml == nil {
yamlName = ""
} else {
yamlName = req.Yaml.Filename
}
fileObj, err := req.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": "Open file error" + err.Error()})
return
}
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, req.File.Filename, fileObj, req.File.Size, minio.PutObjectOptions{})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
return
}
if yamlName != "" {
yamlObj, err := req.Yaml.Open()
if err == nil {
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, yamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
return
}
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
}
}
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, req.File.Filename, yamlName, req.UpdateLog); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
resp.ErrCode = http.StatusInternalServerError
resp.ErrMsg = err.Error()
c.JSON(http.StatusInternalServerError, resp)
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
c.JSON(http.StatusOK, resp)
}
func GetDownloadURL(c *gin.Context) {
var (
req apiStruct.GetDownloadURLReq
resp apiStruct.GetDownloadURLResp
)
defer func() {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
}()
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
app, err := imdb.GetNewestVersion(req.Type)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
}
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
if app != nil {
if app.Version != req.Version && app.Version != "" {
resp.Data.HasNewVersion = true
if app.ForceUpdate == true {
resp.Data.ForceUpdate = true
}
if app.YamlName != "" {
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
}
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
resp.Data.Version = app.Version
resp.Data.UpdateLog = app.UpdateLog
c.JSON(http.StatusOK, resp)
return
} else {
resp.Data.HasNewVersion = false
c.JSON(http.StatusOK, resp)
return
}
}
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
}
@@ -1,51 +1,46 @@
package apiThird
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
log2 "Open_IM/pkg/common/log"
"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"
)
type paramsTencentCloudStorageCredential struct {
Token string `json:"token"`
OperationID string `json:"operationID"`
}
var lastTime int64
var lastRes *sts.CredentialResult
func TencentCloudStorageCredential(c *gin.Context) {
params := paramsTencentCloudStorageCredential{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Parameter parsing errorplease check the parameters and request service again"})
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
}
log2.Info(params.Token, params.OperationID, "api TencentUpLoadCredential call start...")
if time.Now().Unix()-lastTime < 10 && lastRes != nil {
c.JSON(http.StatusOK, gin.H{
"errCode": 0,
"errMsg": "",
"region": config.Config.Credential.Tencent.Region,
"bucket": config.Config.Credential.Tencent.Bucket,
"data": lastRes,
})
var ok bool
var userID string
var errInfo string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
lastTime = time.Now().Unix()
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
cli := sts.NewClient(
config.Config.Credential.Tencent.SecretID,
config.Config.Credential.Tencent.SecretKey,
nil,
)
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential sts.NewClient cli = %v", cli)
opt := &sts.CredentialOptions{
DurationSeconds: int64(time.Hour.Seconds()),
@@ -65,29 +60,19 @@ func TencentCloudStorageCredential(c *gin.Context) {
},
},
}
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential sts.CredentialOptions opt = %v", opt)
res, err := cli.GetCredential(opt)
resp := api.TencentCloudStorageCredentialResp{}
if err != nil {
log2.Error(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential err = %s", err.Error())
c.JSON(http.StatusOK, gin.H{
"errCode": constant.ErrTencentCredential.ErrCode,
"errMsg": err.Error(),
"bucket": "",
"region": "",
"data": res,
})
return
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
}
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential success res = %v, res.Credentials = %v", res, res.Credentials)
lastRes = res
resp.Data = structs.Map(&resp.CosData)
log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp)
c.JSON(http.StatusOK, gin.H{
"errCode": 0,
"errMsg": "",
"region": config.Config.Credential.Tencent.Region,
"bucket": config.Config.Credential.Tencent.Bucket,
"data": res,
})
c.JSON(http.StatusOK, resp)
}
-142
View File
@@ -1,142 +0,0 @@
package user
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbRelay "Open_IM/pkg/proto/relay"
pbUser "Open_IM/pkg/proto/user"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type userInfo struct {
UID string `json:"uid"`
Name string `json:"name"`
Icon string `json:"icon"`
Gender int32 `json:"gender"`
Mobile string `json:"mobile"`
Birth string `json:"birth"`
Email string `json:"email"`
Ex string `json:"ex"`
}
type paramsGetUsersOnlineStatus struct {
OperationID string `json:"operationID" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
Secret string `json:"secret" binding:"required,max=32"`
}
func GetUsersOnlineStatus(c *gin.Context) {
params := paramsGetUsersOnlineStatus{}
if err := c.BindJSON(&params); err != nil {
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
if params.Secret != config.Config.Secret {
log.NewError(params.OperationID, "parse token failed ", params.Secret, config.Config.Secret)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "secret failed"})
return
}
req := &pbRelay.GetUsersOnlineStatusReq{
OperationID: params.OperationID,
UserIDList: params.UserIDList,
}
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
flag := false
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
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.NewDebug(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)
}
log.NewDebug(params.OperationID, "Finished merged data", respResult)
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
c.JSON(http.StatusOK, resp)
}
func GetUserInfo(c *gin.Context) {
log.InfoByKv("api get userinfo init...", "")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
//defer etcdConn.Close()
params := paramsStruct{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbUser.GetUserInfoReq{
UserIDList: params.UIDList,
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
}
log.InfoByKv("api get user info is server", c.PostForm("OperationID"), c.Request.Header.Get("token"))
RpcResp, err := client.GetUserInfo(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{
"errorCode": 500,
"errorMsg": "call rpc server failed",
})
return
}
log.InfoByKv("call get user info rpc server success", params.OperationID)
if RpcResp.ErrorCode == 0 {
userInfoList := make([]userInfo, 0)
for _, user := range RpcResp.Data {
var ui userInfo
ui.UID = user.Uid
ui.Name = user.Name
ui.Icon = user.Icon
ui.Gender = user.Gender
ui.Mobile = user.Mobile
ui.Birth = user.Birth
ui.Email = user.Email
ui.Ex = user.Ex
userInfoList = append(userInfoList, ui)
}
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
c.JSON(http.StatusOK, resp)
} else {
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
c.JSON(http.StatusOK, resp)
}
log.InfoByKv("api get user info return success", params.OperationID, "args=%s", RpcResp.String())
}
-62
View File
@@ -1,62 +0,0 @@
package user
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbUser "Open_IM/pkg/proto/user"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
type paramsStruct struct {
OperationID string `json:"operationID" binding:"required"`
UIDList []string `json:"uidList"`
Platform int32 `json:"platform"`
Name string `json:"name"`
Icon string `json:"icon"`
Gender int32 `json:"gender"`
Mobile string `json:"mobile"`
Birth string `json:"birth"`
Email string `json:"email"`
Ex string `json:"ex"`
Uid string `json:"uid"`
}
func UpdateUserInfo(c *gin.Context) {
log.InfoByKv("api update userinfo init...", "")
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
//defer etcdConn.Close()
params := paramsStruct{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
req := &pbUser.UpdateUserInfoReq{
OperationID: params.OperationID,
Token: c.Request.Header.Get("token"),
Name: params.Name,
Icon: params.Icon,
Gender: params.Gender,
Mobile: params.Mobile,
Birth: params.Birth,
Email: params.Email,
Ex: params.Ex,
Uid: params.Uid,
}
log.InfoByKv("api update user info is server", req.OperationID, req.Token)
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
if err != nil {
log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
return
}
log.InfoByKv("call update user info rpc server success", params.OperationID)
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
log.InfoByKv("api update user info return success", params.OperationID, "args=%s", RpcResp.String())
}
+322
View File
@@ -0,0 +1,322 @@
package user
import (
jsonData "Open_IM/internal/utils"
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"
cacheRpc "Open_IM/pkg/proto/cache"
pbRelay "Open_IM/pkg/proto/relay"
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 GetUsersInfoFromCache(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
}
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
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 GetFriendIDListFromCache(c *gin.Context) {
var (
req api.GetFriendIDListFromCacheReq
resp api.GetFriendIDListFromCacheResp
reqPb cacheRpc.GetFriendIDListFromCacheReq
respPb *cacheRpc.GetFriendIDListFromCacheResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
reqPb.OperationID = req.OperationID
var ok bool
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
client := cacheRpc.NewCacheClient(etcdConn)
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
return
}
resp.UserIDList = respPb.UserIDList
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
c.JSON(http.StatusOK, resp)
}
func GetBlackIDListFromCache(c *gin.Context) {
var (
req api.GetBlackIDListFromCacheReq
resp api.GetBlackIDListFromCacheResp
reqPb cacheRpc.GetBlackIDListFromCacheReq
respPb *cacheRpc.GetBlackIDListFromCacheResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.OperationID = req.OperationID
var ok bool
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
client := cacheRpc.NewCacheClient(etcdConn)
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
return
}
resp.UserIDList = respPb.UserIDList
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
c.JSON(http.StatusOK, resp)
}
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
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
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)
}
}
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
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if len(config.Config.Manager.AppManagerUid) == 0 {
log.NewError(req.OperationID, "Manager == 0")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
return
}
req.OpUserID = config.Config.Manager.AppManagerUid[0]
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)
}
+81
View File
@@ -0,0 +1,81 @@
package admin
import (
apiStruct "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"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"strings"
"github.com/gin-gonic/gin"
url2 "net/url"
)
var (
minioClient *minio.Client
)
func init() {
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
var initUrl string
if config.Config.Credential.Minio.EndpointInnerEnable {
initUrl = config.Config.Credential.Minio.EndpointInner
} else {
initUrl = config.Config.Credential.Minio.Endpoint
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
minioUrl, err := url2.Parse(initUrl)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
opts := &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
}
if minioUrl.Scheme == "http" {
opts.Secure = false
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, opts)
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
}
}
// register
func AdminLogin(c *gin.Context) {
var (
req apiStruct.AdminLoginRequest
resp apiStruct.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)
}
+471
View File
@@ -0,0 +1,471 @@
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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(),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
}
+111
View File
@@ -0,0 +1,111 @@
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)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", 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)
log.NewInfo("", utils.GetSelfFuncName(), "resp", resp)
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()
}
}
+26
View File
@@ -0,0 +1,26 @@
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, errInfo := 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
} else {
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
}
}
}
@@ -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("/cms")
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
}
+234
View File
@@ -0,0 +1,234 @@
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
+324
View File
@@ -0,0 +1,324 @@
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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.ResignUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", 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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
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
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
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)
}
+26 -68
View File
@@ -1,16 +1,16 @@
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"
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
)
@@ -19,16 +19,15 @@ type ParamsLogin struct {
PhoneNumber string `json:"phoneNumber"`
Password string `json:"password"`
Platform int32 `json:"platform"`
OperationID string `json:"operationID" binding:"required"`
}
func Login(c *gin.Context) {
log.NewDebug("Login api is statrting...")
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
@@ -36,77 +35,36 @@ func Login(c *gin.Context) {
account = params.PhoneNumber
}
log.InfoByKv("api Login get params", account)
queryParams := im_mysql_model.Register{
Account: account,
Password: params.Password,
}
canLogin := im_mysql_model.Login(&queryParams)
if canLogin == 1 {
log.ErrorByKv("Incorrect phone number password", account, "err", "Mobile phone number is not registered")
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Mobile phone number is not registered"})
return
}
if canLogin == 2 {
log.ErrorByKv("Incorrect phone number password", account, "err", "Incorrect password")
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Incorrect password"})
return
}
resp, err := OpenIMToken(account, params.Platform)
r, err := im_mysql_model.GetRegister(account)
if err != nil {
log.ErrorByKv("get token by phone number err", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
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
}
response, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
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:%d/auth/user_token", utils.ServerIP, config.Config.Api.GinPort[0])
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.ErrorByKv("Failed to read file", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
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
}
imRep := IMRegisterResp{}
err = json.Unmarshal(response, &imRep)
if err != nil {
log.ErrorByKv("json parsing failed", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
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
}
if imRep.ErrCode != 0 {
log.ErrorByKv("openIM Login request failed", account, "err")
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imRep.ErrMsg})
return
}
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imRep.Data})
return
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMGetUserTokenResp.UserToken})
}
func OpenIMToken(Account string, platform int32) (*http.Response, error) {
url := fmt.Sprintf("http://%s:10000/auth/user_token", utils.ServerIP)
client := &http.Client{}
params := make(map[string]interface{})
params["secret"] = config.Config.Secret
params["platform"] = platform
params["uid"] = Account
con, err := json.Marshal(params)
if err != nil {
log.ErrorByKv("json parsing failed", Account, "err", err.Error())
return nil, err
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
if err != nil {
log.ErrorByKv("request error", "/auth/user_token", "err", err.Error())
return nil, err
}
resp, err := client.Do(req)
return resp, err
}
@@ -0,0 +1,197 @@
package register
import (
"Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
groupRpc "Open_IM/pkg/proto/group"
organizationRpc "Open_IM/pkg/proto/organization"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"math/rand"
"strings"
"time"
)
func onboardingProcess(operationID, userID, userName string) {
if err := createOrganizationUser(operationID, userID, userName); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
}
departmentID := config.Config.Demo.TestDepartMentID
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
}
groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
joinGroups(operationID, userID, userName, groupIDList)
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
}
func createOrganizationUser(operationID, userID, userName string) error {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := &organizationRpc.CreateOrganizationUserReq{
OrganizationUser: &commonPb.OrganizationUser{
UserID: userID,
Nickname: userName,
EnglishName: randomEnglishName(),
Gender: constant.Male,
CreateTime: uint32(time.Now().Unix()),
},
OperationID: operationID,
OpUserID: userID,
}
if strings.Contains("@", userID) {
req.OrganizationUser.Email = userID
} else {
req.OrganizationUser.Telephone = userID
}
resp, err := client.CreateOrganizationUser(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
return err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return errors.New(resp.ErrMsg)
}
return nil
}
func joinTestDepartment(operationID, userID, departmentID string) error {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := &organizationRpc.CreateDepartmentMemberReq{
DepartmentMember: &commonPb.DepartmentMember{
UserID: userID,
DepartmentID: departmentID,
Position: randomPosition(),
},
OperationID: operationID,
OpUserID: config.Config.Manager.AppManagerUid[0],
}
resp, err := client.CreateDepartmentMember(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
return err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return errors.New(resp.ErrMsg)
}
return nil
}
func GetDepartmentGroupIDList(operationID, departmentID string) ([]string, error) {
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := organizationRpc.GetDepartmentParentIDListReq{
DepartmentID: departmentID,
OperationID: operationID,
}
resp, err := client.GetDepartmentParentIDList(context.Background(), &req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), req.String())
return nil, err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return nil, errors.New(resp.ErrMsg)
}
resp.ParentIDList = append(resp.ParentIDList, departmentID)
getDepartmentRelatedGroupIDListReq := organizationRpc.GetDepartmentRelatedGroupIDListReq{OperationID: operationID, DepartmentIDList: resp.ParentIDList}
getDepartmentParentIDListResp, err := client.GetDepartmentRelatedGroupIDList(context.Background(), &getDepartmentRelatedGroupIDListReq)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), getDepartmentRelatedGroupIDListReq.String())
return nil, err
}
if getDepartmentParentIDListResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), getDepartmentParentIDListResp)
return nil, errors.New(getDepartmentParentIDListResp.ErrMsg)
}
return getDepartmentParentIDListResp.GroupIDList, nil
}
func joinGroups(operationID, userID, userName string, groupIDList []string) {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID, groupIDList)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := groupRpc.NewGroupClient(etcdConn)
for _, groupID := range groupIDList {
req := &groupRpc.InviteUserToGroupReq{
OperationID: operationID,
GroupID: groupID,
Reason: "register auto join",
InvitedUserIDList: []string{userID},
OpUserID: userID,
}
resp, err := client.InviteUserToGroup(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), req.String())
continue
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
continue
}
onboardingProcessNotification(operationID, userID, groupID)
}
}
// welcome user join department notification
func onboardingProcessNotification(operationID, userID, groupID string) {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID, groupID)
}()
var tips commonPb.TipsComm
tips.DefaultTips = config.Config.Notification.JoinDepartmentNotification.DefaultTips.Tips
content, err := proto.Marshal(&tips)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), "proto marshal failed")
return
}
notification := &msg.NotificationMsg{
SendID: userID,
RecvID: groupID,
Content: content,
MsgFrom: constant.UserMsgType,
ContentType: constant.Text,
SessionType: constant.SingleChatType,
OperationID: operationID,
}
// notification user join group
msg.Notification(notification)
}
func randomEnglishName() string {
l := []string{"abandon", "entail", "nebula", "shrink", "accumulate", "etch", "nostalgia", "slide",
"feudal", "adverse", "exploit", "occupy", "solve", "amazing", "fantasy", "orchid", "spiky", "approve", "flap"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
fmt.Println(index)
return l[index]
}
func randomPosition() string {
l := []string{"Golang工程师", "前端工程师", "后端工程师", "产品经理", "测试开发工程师", "运维开发工程师"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
fmt.Println(index)
return l[index]
}
+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"})
}
+41 -62
View File
@@ -10,7 +10,6 @@ import (
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/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
"gopkg.in/gomail.v2"
"math/rand"
@@ -21,39 +20,55 @@ import (
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) {
log.InfoByKv("sendCode api is statrting...", "")
params := paramsVerificationCode{}
if err := c.BindJSON(&params); err != nil {
log.ErrorByKv("request params json parsing failed", params.PhoneNumber, params.Email, "err", err.Error())
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
}
queryParams := im_mysql_model.GetRegisterParams{
Account: account,
var accountKey string
if params.UsedFor == 0 {
params.UsedFor = constant.VerificationCodeForRegister
}
_, err, rowsAffected := im_mysql_model.GetRegister(&queryParams)
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
if err == nil && rowsAffected != 0 {
log.ErrorByKv("The phone number has been registered", queryParams.Account, "err")
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "The phone number has been registered"})
return
case constant.VerificationCodeForReset:
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
}
log.InfoByKv("begin sendSms", account)
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()
@@ -62,15 +77,15 @@ func SendVerificationCode(c *gin.Context) {
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.IntentionalError, "errMsg": err.Error()})
log.Error(params.OperationID, "send mail error", account, 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.ErrorByKv("create sendSms client err", "", "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
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
}
@@ -83,56 +98,20 @@ func SendVerificationCode(c *gin.Context) {
response, err := client.SendSms(sendSmsRequest)
if err != nil {
log.ErrorByKv("sendSms error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
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.ErrorByKv("alibabacloud sendSms error", account, "err", response.Body.Code, response.Body.Message)
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
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
}
}
log.InfoByKv("begin store redis", account)
v, err := redis.Int(db.DB.Exec("TTL", account))
if err != nil {
log.ErrorByKv("get account from redis error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
return
}
switch {
case v == -2:
_, err = db.DB.Exec("SET", account, code, "EX", 600)
if err != nil {
log.ErrorByKv("set redis error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "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 sent successfully!", "data": data})
log.InfoByKv("send new verification code", account)
return
case v > 540:
data := make(map[string]interface{})
data["account"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Frequent operation!", "data": data})
log.InfoByKv("frequent operation", account)
return
case v < 540:
_, err = db.DB.Exec("SET", account, code, "EX", 600)
if err != nil {
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enterthe 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 reset!", "data": data})
log.InfoByKv("Reset verification code", account)
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) {
+46 -110
View File
@@ -1,155 +1,91 @@
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"
"bytes"
"encoding/json"
"fmt"
"github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
"io/ioutil"
"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"`
}
type Data struct {
ExpiredTime int64 `json:"expiredTime"`
Token string `json:"token"`
Uid string `json:"uid"`
}
type IMRegisterResp struct {
Data Data `json:"data"`
ErrCode int32 `json:"errCode"`
ErrMsg string `json:"errMsg"`
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) {
log.InfoByKv("setPassword api is statrting...", "")
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
}
log.InfoByKv("begin store redis", account)
v, err := redis.String(db.DB.Exec("GET", account))
if params.VerificationCode == config.Config.Demo.SuperCode {
goto openIMRegisterTab
if params.Name == "" {
params.Name = account
}
fmt.Println("Get Redis:", v, err)
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:%d/auth/user_register", utils.ServerIP, config.Config.Api.GinPort[0])
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.ErrorByKv("password Verification code expired", account, "err", err.Error())
data := make(map[string]interface{})
data["phoneNumber"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification expired!", "data": data})
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
}
if v != params.VerificationCode {
log.InfoByKv("password Verification code error", account, params.VerificationCode)
data := make(map[string]interface{})
data["PhoneNumber"] = account
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code error!", "data": data})
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
}
openIMRegisterTab:
log.InfoByKv("openIM register begin", account)
resp, err := OpenIMRegister(account)
log.InfoByKv("openIM register resp", account, resp, err)
log.Info(params.OperationID, "begin store mysql", account, params.Password)
err = im_mysql_model.SetPassword(account, params.Password, params.Ex)
if err != nil {
log.ErrorByKv("request openIM register error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
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
}
response, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
return
}
imrep := IMRegisterResp{}
err = json.Unmarshal(response, &imrep)
if err != nil {
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
if imrep.ErrCode != 0 {
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imrep.ErrMsg})
return
}
queryParams := im_mysql_model.SetPasswordParams{
Account: account,
Password: params.Password,
}
log.InfoByKv("begin store mysql", account, params.Password)
_, err = im_mysql_model.SetPassword(&queryParams)
if err != nil {
log.ErrorByKv("set phone number password error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.DatabaseError, "errMsg": err.Error()})
return
}
log.InfoByKv("end setPassword", account)
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imrep.Data})
log.Info(params.OperationID, "end setPassword", account, params.Password)
// demo onboarding
onboardingProcess(params.OperationID, account, params.Name)
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
return
}
func OpenIMRegister(account string) (*http.Response, error) {
url := fmt.Sprintf("http://%s:10000/auth/user_register", utils.ServerIP)
fmt.Println("1:", config.Config.Secret)
client := &http.Client{}
params := make(map[string]interface{})
params["secret"] = config.Config.Secret
params["platform"] = 2
params["uid"] = account
params["name"] = account
params["icon"] = ""
params["gender"] = 0
params["mobile"] = ""
params["email"] = ""
params["birth"] = ""
params["ex"] = ""
con, err := json.Marshal(params)
if err != nil {
return nil, err
}
log.InfoByKv("openIM register params", account, params)
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
if err != nil {
return nil, err
}
resp, err := client.Do(req)
return resp, err
}
+25 -15
View File
@@ -6,7 +6,6 @@ import (
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
"net/http"
)
@@ -15,14 +14,14 @@ 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) {
log.InfoByKv("Verify api is statrting...", "")
params := paramsCertification{}
if err := c.BindJSON(&params); err != nil {
log.ErrorByKv("request params json parsing failed", "", "err", err.Error())
log.NewError("", "request params json parsing failed", "", "err", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return
}
@@ -36,35 +35,46 @@ func Verify(c *gin.Context) {
}
if params.VerificationCode == config.Config.Demo.SuperCode {
log.InfoByKv("Super Code Verified successfully", account)
log.NewInfo(params.OperationID, "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.InfoByKv("begin get form redis", account)
v, err := redis.String(db.DB.Exec("GET", account))
log.InfoByKv("redis phone number and verificating Code", account, v)
log.NewInfo(params.OperationID, " 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.ErrorByKv("Verification code expired", account, "err", err.Error())
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.LogicalError, "errMsg": "Verification code expired!", "data": data})
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code expired!", "data": data})
return
}
if params.VerificationCode == v {
log.InfoByKv("Verified successfully", account)
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.InfoByKv("Verification code error", account, params.VerificationCode)
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.LogicalError, "errMsg": "Verification code error!", "data": data})
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
}
}
+15 -6
View File
@@ -2,23 +2,32 @@ package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/statistics"
"fmt"
"github.com/go-playground/validator/v10"
"sync"
)
var (
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgAllCount uint64
sendMsgFailedCount uint64
sendMsgSuccessCount uint64
userCount uint64
)
func Init(rpcPort, wsPort int) {
//log initialization
log.NewPrivateLog(config.Config.ModuleName.LongConnSvrName)
rwLock = new(sync.RWMutex)
validate = validator.New()
statistics.NewStatistics(&sendMsgAllCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
ws.onInit(wsPort)
rpcSvr.onInit(rpcPort)
}
+126 -123
View File
@@ -6,12 +6,12 @@ import (
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
pbRtc "Open_IM/pkg/proto/rtc"
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"bytes"
"context"
"encoding/gob"
"encoding/json"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"runtime"
@@ -30,7 +30,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
dec := gob.NewDecoder(b)
err := dec.Decode(&m)
if err != nil {
log.ErrorByKv("ws Decode err", "", "err", err.Error())
log.NewError("", "ws Decode err", err.Error())
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
err = conn.Close()
if err != nil {
@@ -39,7 +39,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
return
}
if err := validate.Struct(m); err != nil {
log.ErrorByKv("ws args validate err", "", "err", err.Error())
log.NewError("", "ws args validate err", err.Error())
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
return
}
@@ -47,46 +47,42 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
// return
//}
log.InfoByKv("Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID, "msgIncr", m.MsgIncr)
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m)
switch m.ReqIdentifier {
case constant.WSGetNewestSeq:
go ws.getSeqReq(conn, &m)
case constant.WSPullMsg:
go ws.pullMsgReq(conn, &m)
ws.getSeqReq(conn, &m)
case constant.WSSendMsg:
sendTime := utils.GetCurrentTimestampByNano()
go ws.sendMsgReq(conn, &m, sendTime)
ws.sendMsgReq(conn, &m)
case constant.WSSendSignalMsg:
ws.sendSignalMsgReq(conn, &m)
case constant.WSPullMsgBySeqList:
go ws.pullMsgBySeqListReq(conn, &m)
ws.pullMsgBySeqListReq(conn, &m)
default:
}
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
log.NewInfo(m.OperationID, "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)
pbData := pbChat.GetMaxAndMinSeqReq{}
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier, m.Data)
rpcReq := pbChat.GetMaxAndMinSeqReq{}
nReply := new(pbChat.GetMaxAndMinSeqResp)
pbData.UserID = m.SendID
pbData.OperationID = m.OperationID
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", pbData.OperationID, "args", m)
}
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
if err != nil {
log.ErrorByKv("rpc call failed to getSeqReq", pbData.OperationID, "err", err, "pbData", pbData.String())
nReply.ErrCode = 200
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", pbData.OperationID, "replyData", reply.String())
ws.getSeqResp(conn, m, reply)
log.NewInfo(rpcReq.OperationID, "rpc call success to getSeqReq", rpcReply.String())
ws.getSeqResp(conn, m, rpcReply)
}
}
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeqResp) {
var mReplyData open_im_sdk.GetMaxAndMinSeqResp
var mReplyData sdk_ws.GetMaxAndMinSeqResp
mReplyData.MaxSeq = pb.GetMaxSeq()
mReplyData.MinSeq = pb.GetMinSeq()
b, _ := proto.Marshal(&mReplyData)
@@ -100,58 +96,38 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeq
}
ws.sendMsg(conn, mReply)
}
func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to pullMsgReq", m.ReqIdentifier, m.MsgIncr, m.SendID)
nReply := new(pbChat.PullMessageResp)
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsg)
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 {
pbData := pbChat.PullMessageReq{}
pbData.UserID = m.SendID
pbData.OperationID = m.OperationID
pbData.SeqBegin = data.(SeqData).SeqBegin
pbData.SeqEnd = data.(SeqData).SeqEnd
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.PullMessage(context.Background(), &pbData)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
if err != nil {
log.ErrorByKv("PullMessage error", pbData.OperationID, "err", err.Error())
log.NewError(rpcReq.OperationID, "pullMsgBySeqListReq err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.pullMsgResp(conn, m, nReply)
ws.pullMsgBySeqListResp(conn, m, nReply)
} else {
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
ws.pullMsgResp(conn, m, reply)
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.pullMsgResp(conn, m, nReply)
ws.pullMsgBySeqListResp(conn, m, nReply)
}
}
func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) {
log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String())
var mReplyData open_im_sdk.PullMessageBySeqListResp
a, err := json.Marshal(pb.SingleUserMsg)
if err != nil {
log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error())
}
log.NewInfo(m.OperationID, "pullMsgResp json is ", len(pb.SingleUserMsg))
err = json.Unmarshal(a, &mReplyData.SingleUserMsg)
if err != nil {
log.NewError(m.OperationID, "SingleUserMsg,json Unmarshal,err", err.Error())
}
b, err := json.Marshal(pb.GroupUserMsg)
if err != nil {
log.NewError(m.OperationID, "mReplyData,json marshal,err", err.Error())
}
err = json.Unmarshal(b, &mReplyData.GroupUserMsg)
if err != nil {
log.NewError(m.OperationID, "test SingleUserMsg,json Unmarshal,err", err.Error())
}
c, err := proto.Marshal(&mReplyData)
log.NewInfo(m.OperationID, "test info is ", len(mReplyData.SingleUserMsg), mReplyData.SingleUserMsg)
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,
@@ -160,92 +136,52 @@ func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageRes
OperationID: m.OperationID,
Data: c,
}
log.NewInfo(m.OperationID, "pullMsgResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
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) pullMsgBySeqListReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr)
nReply := new(pbChat.PullMessageResp)
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(open_im_sdk.PullMessageBySeqListReq).SeqList)
if isPass {
pbData := pbChat.PullMessageBySeqListReq{}
pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList
pbData.UserID = m.SendID
pbData.OperationID = m.OperationID
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.NewError(pbData.OperationID, "pullMsgBySeqListReq err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.pullMsgResp(conn, m, nReply)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), reply.GetMaxSeq(), reply.GetMinSeq(), len(reply.GetSingleUserMsg()), len(reply.GetGroupUserMsg()))
ws.pullMsgResp(conn, m, reply)
}
} else {
nReply.ErrCode = errCode
nReply.ErrMsg = errMsg
ws.pullMsgResp(conn, m, nReply)
}
}
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, sendTime)
nReply := new(pbChat.UserSendMsgResp)
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
sendMsgAllCount++
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.(open_im_sdk.UserSendMsgReq)
pbData := pbChat.UserSendMsgReq{
ReqIdentifier: m.ReqIdentifier,
Token: m.Token,
SendID: m.SendID,
OperationID: m.OperationID,
PlatformID: data.PlatformID,
SessionType: data.SessionType,
MsgFrom: data.MsgFrom,
ContentType: data.ContentType,
RecvID: data.RecvID,
ForceList: data.ForceList,
SenderNickName: data.SenderNickName,
SenderFaceURL: data.SenderFaceURL,
Content: data.Content,
Options: utils.MapIntToJsonString(data.Options),
ClientMsgID: data.ClientMsgID,
SendTime: sendTime,
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.UserSendMsg(context.Background(), &pbData)
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, sendTime)
ws.sendMsgResp(conn, m, nReply)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
ws.sendMsgResp(conn, m, reply, sendTime)
ws.sendMsgResp(conn, m, reply)
}
} else {
nReply.ErrCode = errCode
nReply.ErrMsg = errMsg
ws.sendMsgResp(conn, m, nReply, sendTime)
ws.sendMsgResp(conn, m, nReply)
}
}
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgResp, sendTime int64) {
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
// := make(map[string]interface{})
var mReplyData open_im_sdk.UserSendMsgResp
var mReplyData sdk_ws.UserSendMsgResp
mReplyData.ClientMsgID = pb.GetClientMsgID()
mReplyData.ServerMsgID = pb.GetServerMsgID()
mReplyData.SendTime = sendTime
mReplyData.SendTime = pb.GetSendTime()
b, _ := proto.Marshal(&mReplyData)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
@@ -258,17 +194,84 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgRes
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{}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRealTimeCommName)
rtcClient := pbRtc.NewRtcServiceClient(etcdConn)
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.RpcRegisterName.OpenImRealTimeCommName)
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 {
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "Encode Msg error", conn.RemoteAddr().String(), ws.getUserUid(conn), err.Error())
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 {
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "WS WriteMsg error", conn.RemoteAddr().String(), ws.getUserUid(conn), err.Error())
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) {
@@ -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,
//})
}
+54 -72
View File
@@ -4,16 +4,16 @@ 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_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"bytes"
"context"
"encoding/gob"
"fmt"
"github.com/golang/protobuf/proto"
"net"
"strconv"
"strings"
"github.com/gorilla/websocket"
@@ -34,47 +34,43 @@ func (r *RPCServer) onInit(rpcPort int) {
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)
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(r.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.ErrorByArgs(fmt.Sprintf("fail to listening consumer, err:%v\n", err))
return
panic("listening err:" + err.Error() + r.rpcRegisterName)
}
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)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
if err != nil {
log.ErrorByKv("register push message rpc to etcd err", "", "err", err.Error())
log.Error("", "register push message rpc to etcd err", "", "err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
}
err = srv.Serve(listener)
if err != nil {
log.ErrorByKv("push message rpc listening err", "", "err", err.Error())
log.Error("", "push message rpc listening err", "", "err", err.Error())
return
}
}
func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbRelay.MsgToUserResp, error) {
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
var resp []*pbRelay.SingleMsgToUser
var RecvID string
msg := open_im_sdk.MsgData{
SendID: in.SendID,
RecvID: in.RecvID,
MsgFrom: in.MsgFrom,
ContentType: in.ContentType,
SessionType: in.SessionType,
SenderNickName: in.SenderNickName,
SenderFaceURL: in.SenderFaceURL,
ClientMsgID: in.ClientMsgID,
ServerMsgID: in.ServerMsgID,
Content: in.Content,
Seq: in.RecvSeq,
SendTime: in.SendTime,
SenderPlatformID: in.PlatformID,
}
msgBytes, _ := proto.Marshal(&msg)
msgBytes, _ := proto.Marshal(in.MsgData)
mReply := Resp{
ReqIdentifier: constant.WSPushMsg,
OperationID: in.OperationID,
@@ -86,65 +82,50 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
if err != nil {
log.NewError(in.OperationID, "data encode err", err.Error())
}
switch in.GetSessionType() {
case constant.SingleChatType:
RecvID = in.GetRecvID()
case constant.GroupChatType:
RecvID = strings.Split(in.GetRecvID(), " ")[0]
}
var tag bool
var UIDAndPID []string
userIDList := genUidPlatformArray(RecvID)
for _, v := range userIDList {
UIDAndPID = strings.Split(v, " ")
if conn := ws.getUserConn(v); conn != nil {
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, UIDAndPID[1], UIDAndPID[0])
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
temp := &pbRelay.SingleMsgToUser{
ResultCode: resultCode,
RecvID: UIDAndPID[0],
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
RecvID: recvID,
RecvPlatFormID: constant.PlatformNameToID(v),
}
resp = append(resp, temp)
} else {
temp := &pbRelay.SingleMsgToUser{
ResultCode: -1,
RecvID: UIDAndPID[0],
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
RecvID: recvID,
RecvPlatFormID: constant.PlatformNameToID(v),
}
resp = append(resp, temp)
}
}
//Single chat sender synchronization message
if in.GetSessionType() == constant.SingleChatType && in.ContentType <= constant.Quote && in.ContentType != constant.Typing && in.ContentType != constant.HasReadReceipt {
userIDList = genUidPlatformArray(in.SendID)
for _, v := range userIDList {
UIDAndPID = strings.Split(v, " ")
if conn := ws.getUserConn(v); conn != nil {
_ = sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
}
}
}
if !tag {
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
}
return &pbRelay.MsgToUserResp{
return &pbRelay.OnlinePushMsgResp{
Resp: resp,
}, nil
}
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
log.NewDebug(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
var UIDAndPID []string
log.NewInfo(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
if !token_verify.IsManagerUserID(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 _, v1 := range req.UserIDList {
userIDList := genUidPlatformArray(v1)
for _, userID := range req.UserIDList {
platformList := genPlatformArray()
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
temp.UserID = v1
for _, v2 := range userIDList {
UIDAndPID = strings.Split(v2, " ")
if conn := ws.getUserConn(v2); conn != nil {
temp.UserID = userID
for _, platform := range platformList {
if conn := ws.getUserConn(userID, platform); conn != nil {
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
ps.Platform = UIDAndPID[1]
ps.Platform = platform
ps.Status = constant.OnlineStatus
temp.Status = constant.OnlineStatus
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
@@ -155,25 +136,26 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
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.MsgToUserReq, RecvPlatForm, RecvID string) (ResultCode int64) {
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.PlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
log.NewError(in.OperationID, "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)
log.NewDebug(in.OperationID, "PushMsgToUser is success By Ws", "args", in.String(), "recvPlatForm", RecvPlatForm, "recvID", RecvID)
ResultCode = 0
return ResultCode
}
}
func genUidPlatformArray(uid string) (array []string) {
func genPlatformArray() (array []string) {
for i := 1; i <= constant.LinuxPlatformID; i++ {
array = append(array, uid+" "+constant.PlatformIDToName(int32(i)))
array = append(array, constant.PlatformIDToName(int32(i)))
}
return array
}
+20 -7
View File
@@ -9,6 +9,7 @@ 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"
)
@@ -59,25 +60,37 @@ type SeqListData struct {
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.UserSendMsgReq{}
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)
log.Error("", "Decode Data struct err", err.Error(), 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)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
return true, 0, "", data
case constant.WSPullMsgBySeqList:
data := open_im_sdk.PullMessageBySeqListReq{}
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)
log.Error("", "Decode Data struct err", err.Error(), 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)
log.Error("", "data args validate err", err.Error(), 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.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}

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