mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-29 06:49:19 +08:00
Compare commits
586 Commits
v2.3.0-rc2
...
v2.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
| a4fe45d58c | |||
| db8763b610 | |||
| d971397c8b | |||
| 427a598385 | |||
| 4c0b96d81a | |||
| af2baba1e3 | |||
| 93cb01e7e6 | |||
| 139285c46a | |||
| dc401c784a | |||
| bb0f5e97a2 | |||
| 82cd3fd9f1 | |||
| 06117c98b1 | |||
| aa41dc3650 | |||
| 98fe00a171 | |||
| 3bdafc2a11 | |||
| 3c4227696c | |||
| 5d78fa9519 | |||
| eb2a9d540e | |||
| 665e2e3e83 | |||
| c025d0d030 | |||
| 1ce0a3b5d3 | |||
| 7c79d10f5d | |||
| eeb5ba4c7b | |||
| 5d32627553 | |||
| 07a038503e | |||
| 3a878f8426 | |||
| 1cfa55817a | |||
| 78ce5c3f69 | |||
| 97187af0c7 | |||
| d26076c0e4 | |||
| 1f81bd121f | |||
| 02fa9142fe | |||
| 6759e0c25b | |||
| 46e233ccbb | |||
| 1b31de18e4 | |||
| ccc65c846f | |||
| 9d73fc9932 | |||
| d6abbacbf7 | |||
| 979100850c | |||
| a0a2b6c340 | |||
| 7f1acb4532 | |||
| 9afaba4382 | |||
| 355c672ed1 | |||
| 144cf279f9 | |||
| c1a94a1b6c | |||
| c091b5f385 | |||
| aa6b439e8c | |||
| 07170135e6 | |||
| 024ee6e602 | |||
| a1f79f4508 | |||
| 6a6009827c | |||
| 375fc0c89e | |||
| a110b4c26b | |||
| ebdb875c56 | |||
| 266a2b4c76 | |||
| 7e5b62377f | |||
| 8dce5396b0 | |||
| e78f7a2a37 | |||
| aafbda47d4 | |||
| e1b1af9a48 | |||
| 19f725965d | |||
| 5ce0cf1aad | |||
| 88bcb35a14 | |||
| d534f026b0 | |||
| 939eb95cdc | |||
| 46d3dd409a | |||
| 398be73f5b | |||
| e7ab59a932 | |||
| 285cb346b9 | |||
| 72d0920458 | |||
| 4aaa1a7afa | |||
| f2f35e115c | |||
| 7295f39d68 | |||
| 685cacf490 | |||
| 1f36d970f9 | |||
| 60f0c80c36 | |||
| c018d63117 | |||
| 88af048e90 | |||
| c0190e21c6 | |||
| 2368a8fba3 | |||
| e9ad462f9e | |||
| 4ac9d0410c | |||
| 1c53c90ab5 | |||
| 4d6e05989e | |||
| 54a3a755d6 | |||
| e32a3fbfca | |||
| f498f67f1e | |||
| d491c482a5 | |||
| 7062676f9a | |||
| 0d52759455 | |||
| 9a5c0bae50 | |||
| eb30e54dc8 | |||
| 4ea97ab23f | |||
| 82f2ec24fb | |||
| d487465b2a | |||
| 899e88babe | |||
| 83f923aa10 | |||
| 04a0614319 | |||
| 632ff783c6 | |||
| e4f86ee823 | |||
| f7390c757b | |||
| 7a9b45d257 | |||
| b699ce3512 | |||
| da9003ec46 | |||
| 30a0743c8c | |||
| a4fc493ea5 | |||
| f5f6e9a882 | |||
| 21cda37380 | |||
| 941670a420 | |||
| 15b01a07b5 | |||
| 85565dc137 | |||
| d59f699937 | |||
| ef66b10501 | |||
| 081c47aba9 | |||
| 6cdb64fb8b | |||
| 765e8d4f79 | |||
| 8e7e496b44 | |||
| cf14b19bf6 | |||
| 2131061482 | |||
| 692cebe659 | |||
| 189d5aed69 | |||
| ea38953b47 | |||
| 9130881875 | |||
| 46b1803086 | |||
| 98dde67f65 | |||
| 34eedd7955 | |||
| 98d7c7bb86 | |||
| 74c2bafc9b | |||
| 912da395c9 | |||
| 061ad6df2c | |||
| b5deceaa3b | |||
| 22099d82be | |||
| 07e1de2f62 | |||
| 2203638fc5 | |||
| 5ef7123f78 | |||
| 5ae9b84cce | |||
| f41cebe776 | |||
| dd47dbffe8 | |||
| aebcd1db2e | |||
| 4af9d88771 | |||
| 6f706d9aaf | |||
| 700f1e0001 | |||
| 9cc0825185 | |||
| 26c65d0da8 | |||
| 602ac1ffb8 | |||
| 947609a3b3 | |||
| db38a64a30 | |||
| 783a4d33b4 | |||
| c80b4c1d32 | |||
| b1f1ec5fbb | |||
| 2cad8a879d | |||
| 95910f5c17 | |||
| f3a9c47c2a | |||
| 3d184c95ba | |||
| 6754fdb580 | |||
| 9842e5624e | |||
| d00b265347 | |||
| c72f898238 | |||
| 4a2a9eb997 | |||
| 5b399d0d06 | |||
| 8edacbff2f | |||
| 156e9e2fc7 | |||
| 4682abf4c1 | |||
| 6871c7e665 | |||
| a508dd2c0f | |||
| 5469bb6508 | |||
| 099461dbbf | |||
| 5233e4c097 | |||
| 70e8811d5c | |||
| 7208dd6b2a | |||
| 44af6740c7 | |||
| 8d1dd92df7 | |||
| a5cacaceda | |||
| 821e704b5b | |||
| 82c79bd91c | |||
| bde0adfbd0 | |||
| 6c8b115479 | |||
| 82a8f18e88 | |||
| bdae1f10d4 | |||
| 05b5a0ada3 | |||
| 3fcc2c2678 | |||
| 6af9d3129e | |||
| d7cff79ac7 | |||
| f6137dfc34 | |||
| 6dfbb90b80 | |||
| 72aff32024 | |||
| 9f4c367249 | |||
| 3f87958328 | |||
| a0e689c437 | |||
| 49f05d334d | |||
| a372ef3faa | |||
| 06e48516bb | |||
| a317ebd8e7 | |||
| 6774a8594f | |||
| 56fb579da2 | |||
| b401917c19 | |||
| e990118475 | |||
| ac2cc154b4 | |||
| 99ec0ed8df | |||
| 32daea25de | |||
| 946dbc5efc | |||
| 714dd597f1 | |||
| c36dfd9eea | |||
| 67e5e3b56b | |||
| fdc1cd26e7 | |||
| 988824f3f1 | |||
| 15ef064fc3 | |||
| c7d544685e | |||
| d622f1df3d | |||
| c7e1302377 | |||
| caea072f7d | |||
| 04b22c1a76 | |||
| 26d9d7630c | |||
| 4529047349 | |||
| af110f75d6 | |||
| 1da5ad8830 | |||
| 8e063f6e59 | |||
| d16ceac149 | |||
| c2831e6676 | |||
| a4b95cb7cf | |||
| e5a7810d6e | |||
| 99e913637a | |||
| 9ff80466fc | |||
| 67319031ea | |||
| 5134faeefd | |||
| 77327f59b9 | |||
| 5b68d86052 | |||
| 54c56037e7 | |||
| 8f31bd93fa | |||
| 87dfdb2ddc | |||
| 2c2d3e4641 | |||
| 2a8b19d319 | |||
| f43c042223 | |||
| b75b46f415 | |||
| 42f7af3d52 | |||
| a4767bc7e3 | |||
| 8d4e5ad3f1 | |||
| 49a127d97d | |||
| 8cfb604a0d | |||
| da9918b655 | |||
| c41464b974 | |||
| 5657f617e7 | |||
| 12e6cbb9e5 | |||
| bc1cfed389 | |||
| 9b5e1465c3 | |||
| 7f5b12d4d2 | |||
| c3d3f0986e | |||
| 8c21d0360f | |||
| 650141a498 | |||
| 6ff8fc7f87 | |||
| 0f0e99b42e | |||
| 96814109dc | |||
| 39720d401f | |||
| 5e6e30a5b3 | |||
| a92c0ffac3 | |||
| 43f7ecc75a | |||
| d598ec1852 | |||
| fad61a0a2a | |||
| 3886d49b0a | |||
| 93f8ed223e | |||
| 96e0851563 | |||
| 9d1eb469b5 | |||
| 4001897338 | |||
| 27dd574c4d | |||
| 06a75a0a0e | |||
| 8cf7282f46 | |||
| dd8e42ef71 | |||
| 221b4587d4 | |||
| 4203c4d30c | |||
| 059dd1993a | |||
| e172364e86 | |||
| 0941a8e016 | |||
| de67b9465a | |||
| a2a71ff8f5 | |||
| 0befceef9a | |||
| 203bfbe411 | |||
| 1f4eeaa269 | |||
| aa2d07ca8d | |||
| 3739127044 | |||
| 2dab179166 | |||
| 9590d2865a | |||
| d542cdd898 | |||
| 1d0d063a6c | |||
| 9f15f50f9d | |||
| f0ebc151db | |||
| f0a9c63cd3 | |||
| ec0cd9a348 | |||
| b5afd304d0 | |||
| 4bd4e0863c | |||
| 463a5451e1 | |||
| cb881e81a8 | |||
| 92fc43cb3d | |||
| 73a73b7bc7 | |||
| 3391bd8322 | |||
| 3d5876a8c0 | |||
| 7d04f06f7d | |||
| 24137bffdd | |||
| 621051cfb9 | |||
| 2c21bf3e0e | |||
| c1a2dee0e9 | |||
| 782ad07940 | |||
| d57729d3d7 | |||
| 1f8c2ba8c5 | |||
| b176701e51 | |||
| 7dd6869cd1 | |||
| 33886f106c | |||
| 94ed160eee | |||
| 066eeb6ba6 | |||
| 402b3f5535 | |||
| d4d9e08ae2 | |||
| 6553ada66f | |||
| c0b49ff219 | |||
| d20c89ba21 | |||
| ee577cae4c | |||
| ed5b215bbb | |||
| a5f8e833ba | |||
| decd70ff21 | |||
| 9f002172db | |||
| 5d661f2fc6 | |||
| 9a82dd356c | |||
| 840e08fc8a | |||
| 761b8c40d6 | |||
| 40b7314f6d | |||
| 5c3a43f602 | |||
| dd001ab0e7 | |||
| 30b55ce25e | |||
| 943a5b36e3 | |||
| 0ebaefb8be | |||
| 5a995a8624 | |||
| eee98c5175 | |||
| 4614107b2b | |||
| d6dd99bb4a | |||
| d0a200f652 | |||
| 9138f90843 | |||
| 766a8fa4dd | |||
| 6f2451edd3 | |||
| 864fccbdb2 | |||
| 8956df9599 | |||
| a3daaa55b5 | |||
| 85a52f5d6b | |||
| 92d7ecdf68 | |||
| cdf09aa1bd | |||
| 63a830cc95 | |||
| 3b9cc61669 | |||
| b5166acada | |||
| a38291fc17 | |||
| 723e304ed8 | |||
| 63ac7738bb | |||
| bda96a2175 | |||
| 5b06791a6c | |||
| 64e1361ef5 | |||
| 2f6eb5969e | |||
| 125b6fa779 | |||
| 5e78871c00 | |||
| 487d9a6449 | |||
| 97b1a774fb | |||
| 12a4c12753 | |||
| e8fdc454db | |||
| 69da4410dc | |||
| 5fc6f78555 | |||
| 15e0a7aa38 | |||
| 0d62bfb0c6 | |||
| a37d82e2dd | |||
| 0a14c8b3e6 | |||
| e779280428 | |||
| 753cd95a18 | |||
| 5bd34f19fe | |||
| 0e5b17adcc | |||
| b23f10ecde | |||
| 08d6e142c3 | |||
| 2016a1656b | |||
| 5a44618289 | |||
| 338d7f0df6 | |||
| fd19dd1a03 | |||
| 6d19af02c9 | |||
| 1deb7e9f95 | |||
| 5a6f96f84b | |||
| 3f74022142 | |||
| ccd2ed8ac2 | |||
| a72e422684 | |||
| da8755fcb7 | |||
| 3be284c129 | |||
| 15e2d172a4 | |||
| 4e54cb56e5 | |||
| ad1015c8b0 | |||
| 1dbe80afc4 | |||
| 0683352c4b | |||
| d666f0245d | |||
| 7f252909fc | |||
| 7b9d0b4f1f | |||
| 37193c48d9 | |||
| 1747ae8984 | |||
| dfee8891d3 | |||
| cb10df7c9f | |||
| c6b669eb9d | |||
| 919e2543ca | |||
| b705ac24fa | |||
| 9aa7ba77f5 | |||
| d5b873b70b | |||
| 4ec255917d | |||
| 9b86a18752 | |||
| 630fef29a2 | |||
| 05d45c94d5 | |||
| 44e4c59493 | |||
| 24e7076423 | |||
| 1f8a965b7a | |||
| 8b491f4c94 | |||
| 8b857f9980 | |||
| 7d1707ca7c | |||
| 5e3a3c61f3 | |||
| 073b6d200a | |||
| 652d560a21 | |||
| be69ee8b1d | |||
| fc5aefe435 | |||
| d5239365be | |||
| ac7f905248 | |||
| 1a2ea05361 | |||
| 39606248a1 | |||
| 73118ce447 | |||
| 4e5c1606f3 | |||
| b8aa54a159 | |||
| 7caccce907 | |||
| 82777d641c | |||
| 5b248c82f5 | |||
| 9c7ae3b0ef | |||
| 9b130ae56c | |||
| a48b2e9edb | |||
| e4bbd57c41 | |||
| 0dba30977d | |||
| 69008e08be | |||
| 06236546a8 | |||
| 60029fc618 | |||
| f3e71fec91 | |||
| 54cdb24cec | |||
| 206140c3fa | |||
| c2bd1d0d83 | |||
| 5cb3b8cfbf | |||
| f363722779 | |||
| 5e09e3e072 | |||
| cc3f53d572 | |||
| a2ddf3567c | |||
| aa7ba6d659 | |||
| c53bcd990d | |||
| 78c807a514 | |||
| c4084cbcec | |||
| 062c4b53b6 | |||
| c9d7b63ef7 | |||
| 06729c4e84 | |||
| 5c5f80691a | |||
| 5a0340e927 | |||
| eb7e6a566b | |||
| 079fe089de | |||
| 5f83acf3ad | |||
| 0d16fbe4ab | |||
| c1184fd7d2 | |||
| 429bee7e6c | |||
| 56e2df75b9 | |||
| 547ad7a2c7 | |||
| e2c75f6836 | |||
| ce591227ae | |||
| ace424e78a | |||
| 10223c944c | |||
| 9e190cb5aa | |||
| 5d57e93ee1 | |||
| 75805e3c69 | |||
| 327ae4ac79 | |||
| 911614673b | |||
| e80d3e7dac | |||
| 7b820ebb94 | |||
| 6bfa8643d6 | |||
| 25de6b58c3 | |||
| cdc60ef5f0 | |||
| edeb228315 | |||
| f6c6d58045 | |||
| b1d0ca76c9 | |||
| 5a058d9b97 | |||
| 2892add766 | |||
| 281f4b38d2 | |||
| 7b590e4bd6 | |||
| 923a035e6e | |||
| a2a56980d9 | |||
| 2ee0943115 | |||
| cfe218b8a4 | |||
| 4c10164970 | |||
| a74168d1e1 | |||
| 6c0922a6d8 | |||
| f279b9173e | |||
| 706f6c6747 | |||
| dd6c2df5d2 | |||
| bcc0c7c2df | |||
| 2c0a2d7877 | |||
| 7bd7edfec9 | |||
| db8c4f369c | |||
| 569d5d2d89 | |||
| 5cbea2cab5 | |||
| 57a21ab8e6 | |||
| c52bdce621 | |||
| 9358aa1bd8 | |||
| c304de9288 | |||
| 52e57cf547 | |||
| e33af2a316 | |||
| ffc4da1589 | |||
| 4cfa8d880f | |||
| cd65d42004 | |||
| bba5e7db0c | |||
| eb960f2606 | |||
| 92a68108a6 | |||
| ae8acc6eba | |||
| 1e1381df8e | |||
| 2ba7fcd628 | |||
| 12cbb1f6f9 | |||
| 1f8e161001 | |||
| b4b215a3f8 | |||
| e2ff7ef113 | |||
| 73c998f510 | |||
| 11f29280b1 | |||
| de752c69f4 | |||
| 2cf10fce38 | |||
| 4ba248a101 | |||
| faae01cb8a | |||
| 600c5243dd | |||
| 00bddd5e57 | |||
| 2436ea6ff9 | |||
| 403489865c | |||
| c8590b9e9c | |||
| d1ffa9b330 | |||
| 37799ca0be | |||
| ba5edabb2c | |||
| 1dfe8f866a | |||
| e77b4f334d | |||
| 87c64bdb2b | |||
| 68eed69221 | |||
| 5db5bf17cb | |||
| 319631b5c4 | |||
| 0489c35417 | |||
| 10c0f3075a | |||
| 91a767b4fb | |||
| 4e69ff196a | |||
| 576348b1f2 | |||
| db547d60df | |||
| 0f655e9292 | |||
| 3d0827a6da | |||
| 231d4db71d | |||
| 0117e96d5b | |||
| ca7bba33e6 | |||
| b294a8138c | |||
| a99dbf634b | |||
| cda0fb6a10 | |||
| a1392a7677 | |||
| e9da7f28cc | |||
| c4ee293388 | |||
| 6417977617 | |||
| f687f2eafb | |||
| 7057d7fffb | |||
| d99b0893df | |||
| b32463df53 | |||
| f202d5f54a | |||
| 18891c554d | |||
| 22a39ed4d3 | |||
| 4003befc2a | |||
| c17ca47e7d | |||
| e2e5ab656f | |||
| 8e445caf26 | |||
| b4d82579b7 | |||
| 6734c714d7 | |||
| 526aa15ff6 | |||
| bc0e9eb74e | |||
| a425c62156 | |||
| d99375a536 | |||
| 4c610abd44 | |||
| e1a941b998 | |||
| a8a91fe945 | |||
| 9136838b63 | |||
| ef9c291d9a | |||
| 6f968342dc | |||
| 4930906b62 | |||
| c39df537b4 | |||
| cfa9f2d13f | |||
| 0a8a248349 | |||
| e8f7ad6c09 | |||
| 8dca55aac8 | |||
| adade8fcf1 | |||
| 589ac2863c | |||
| 5e7b2fbdcf | |||
| 456e2f5693 | |||
| 92dc36f480 |
@@ -155,13 +155,6 @@ const docTemplate = `{
|
||||
"summary": "用户注册",
|
||||
"operationId": "UserRegister",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID \u003cbr\u003e ex为拓展字段 \u003cbr\u003e gender为性别, 0为女, 1为男",
|
||||
"name": "req",
|
||||
@@ -209,13 +202,6 @@ const docTemplate = `{
|
||||
"summary": "用户登录",
|
||||
"operationId": "UserToken",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID",
|
||||
"name": "req",
|
||||
@@ -4596,7 +4582,6 @@ const docTemplate = `{
|
||||
"Open_IM_internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@@ -5946,13 +5931,21 @@ const docTemplate = `{
|
||||
"base_info.GetGroupAllMemberReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"count",
|
||||
"groupID",
|
||||
"offset",
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -6521,7 +6514,11 @@ const docTemplate = `{
|
||||
],
|
||||
"properties": {
|
||||
"roleLevel": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
1,
|
||||
3
|
||||
]
|
||||
},
|
||||
"userID": {
|
||||
"type": "string"
|
||||
@@ -6652,6 +6649,12 @@ const docTemplate = `{
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -6751,6 +6754,9 @@ const docTemplate = `{
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -6760,6 +6766,9 @@ const docTemplate = `{
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@@ -6798,6 +6807,9 @@ const docTemplate = `{
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -6807,6 +6819,9 @@ const docTemplate = `{
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@@ -7063,7 +7078,6 @@ const docTemplate = `{
|
||||
"required": [
|
||||
"fromUserID",
|
||||
"operationID",
|
||||
"remark",
|
||||
"toUserID"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7129,6 +7143,9 @@ const docTemplate = `{
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ex": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -7144,6 +7161,9 @@ const docTemplate = `{
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"needVerification": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -7747,7 +7767,6 @@ const docTemplate = `{
|
||||
"internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@@ -8231,6 +8250,9 @@ const docTemplate = `{
|
||||
"server_api_params.GroupInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8255,6 +8277,9 @@ const docTemplate = `{
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"memberCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8264,6 +8289,12 @@ const docTemplate = `{
|
||||
"notification": {
|
||||
"type": "string"
|
||||
},
|
||||
"notificationUpdateTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"notificationUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -8287,6 +8318,9 @@ const docTemplate = `{
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8331,6 +8365,12 @@ const docTemplate = `{
|
||||
"handleUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"reqMsg": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -147,13 +147,6 @@
|
||||
"summary": "用户注册",
|
||||
"operationId": "UserRegister",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID \u003cbr\u003e ex为拓展字段 \u003cbr\u003e gender为性别, 0为女, 1为男",
|
||||
"name": "req",
|
||||
@@ -201,13 +194,6 @@
|
||||
"summary": "用户登录",
|
||||
"operationId": "UserToken",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID",
|
||||
"name": "req",
|
||||
@@ -4588,7 +4574,6 @@
|
||||
"Open_IM_internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@@ -5938,13 +5923,21 @@
|
||||
"base_info.GetGroupAllMemberReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"count",
|
||||
"groupID",
|
||||
"offset",
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -6513,7 +6506,11 @@
|
||||
],
|
||||
"properties": {
|
||||
"roleLevel": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
1,
|
||||
3
|
||||
]
|
||||
},
|
||||
"userID": {
|
||||
"type": "string"
|
||||
@@ -6644,6 +6641,12 @@
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -6743,6 +6746,9 @@
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -6752,6 +6758,9 @@
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@@ -6790,6 +6799,9 @@
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -6799,6 +6811,9 @@
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@@ -7055,7 +7070,6 @@
|
||||
"required": [
|
||||
"fromUserID",
|
||||
"operationID",
|
||||
"remark",
|
||||
"toUserID"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7121,6 +7135,9 @@
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ex": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -7136,6 +7153,9 @@
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"needVerification": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -7739,7 +7759,6 @@
|
||||
"internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@@ -8223,6 +8242,9 @@
|
||||
"server_api_params.GroupInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8247,6 +8269,9 @@
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"memberCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8256,6 +8281,12 @@
|
||||
"notification": {
|
||||
"type": "string"
|
||||
},
|
||||
"notificationUpdateTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"notificationUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -8279,6 +8310,9 @@
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -8323,6 +8357,12 @@
|
||||
"handleUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"reqMsg": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -38,7 +38,6 @@ definitions:
|
||||
videoElem:
|
||||
$ref: '#/definitions/Open_IM_internal_api_manage.VideoElem'
|
||||
required:
|
||||
- notificationFaceURL
|
||||
- notificationName
|
||||
- notificationType
|
||||
- text
|
||||
@@ -910,12 +909,18 @@ definitions:
|
||||
type: object
|
||||
base_info.GetGroupAllMemberReq:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
offset:
|
||||
type: integer
|
||||
operationID:
|
||||
type: string
|
||||
required:
|
||||
- count
|
||||
- groupID
|
||||
- offset
|
||||
- operationID
|
||||
type: object
|
||||
base_info.GetGroupAllMemberResp:
|
||||
@@ -1285,6 +1290,9 @@ definitions:
|
||||
base_info.GroupAddMemberInfo:
|
||||
properties:
|
||||
roleLevel:
|
||||
enum:
|
||||
- 1
|
||||
- 3
|
||||
type: integer
|
||||
userID:
|
||||
type: string
|
||||
@@ -1372,6 +1380,10 @@ definitions:
|
||||
properties:
|
||||
groupID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
operationID:
|
||||
type: string
|
||||
reqMessage:
|
||||
@@ -1436,12 +1448,16 @@ definitions:
|
||||
type: object
|
||||
base_info.ManagementBatchSendMsgReq:
|
||||
properties:
|
||||
businessOperationID:
|
||||
type: string
|
||||
contentType:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
isOnlineOnly:
|
||||
type: boolean
|
||||
notOfflinePush:
|
||||
type: boolean
|
||||
offlinePushInfo:
|
||||
$ref: '#/definitions/server_api_params.OfflinePushInfo'
|
||||
operationID:
|
||||
@@ -1468,12 +1484,16 @@ definitions:
|
||||
type: object
|
||||
base_info.ManagementSendMsgReq:
|
||||
properties:
|
||||
businessOperationID:
|
||||
type: string
|
||||
contentType:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
isOnlineOnly:
|
||||
type: boolean
|
||||
notOfflinePush:
|
||||
type: boolean
|
||||
offlinePushInfo:
|
||||
$ref: '#/definitions/server_api_params.OfflinePushInfo'
|
||||
operationID:
|
||||
@@ -1657,7 +1677,6 @@ definitions:
|
||||
required:
|
||||
- fromUserID
|
||||
- operationID
|
||||
- remark
|
||||
- toUserID
|
||||
type: object
|
||||
base_info.SetFriendRemarkResp:
|
||||
@@ -1689,6 +1708,8 @@ definitions:
|
||||
type: object
|
||||
base_info.SetGroupInfoReq:
|
||||
properties:
|
||||
applyMemberFriend:
|
||||
type: integer
|
||||
ex:
|
||||
type: string
|
||||
faceURL:
|
||||
@@ -1699,6 +1720,8 @@ definitions:
|
||||
type: string
|
||||
introduction:
|
||||
type: string
|
||||
lookMemberInfo:
|
||||
type: integer
|
||||
needVerification:
|
||||
type: integer
|
||||
notification:
|
||||
@@ -2134,7 +2157,6 @@ definitions:
|
||||
videoElem:
|
||||
$ref: '#/definitions/internal_api_manage.VideoElem'
|
||||
required:
|
||||
- notificationFaceURL
|
||||
- notificationName
|
||||
- notificationType
|
||||
- text
|
||||
@@ -2428,6 +2450,8 @@ definitions:
|
||||
type: object
|
||||
server_api_params.GroupInfo:
|
||||
properties:
|
||||
applyMemberFriend:
|
||||
type: integer
|
||||
createTime:
|
||||
type: integer
|
||||
creatorUserID:
|
||||
@@ -2444,12 +2468,18 @@ definitions:
|
||||
type: integer
|
||||
introduction:
|
||||
type: string
|
||||
lookMemberInfo:
|
||||
type: integer
|
||||
memberCount:
|
||||
type: integer
|
||||
needVerification:
|
||||
type: integer
|
||||
notification:
|
||||
type: string
|
||||
notificationUpdateTime:
|
||||
type: integer
|
||||
notificationUserID:
|
||||
type: string
|
||||
ownerUserID:
|
||||
type: string
|
||||
status:
|
||||
@@ -2465,6 +2495,8 @@ definitions:
|
||||
type: string
|
||||
groupID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
joinTime:
|
||||
@@ -2494,6 +2526,10 @@ definitions:
|
||||
type: integer
|
||||
handleUserID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
reqMsg:
|
||||
type: string
|
||||
reqTime:
|
||||
@@ -2702,11 +2738,6 @@ paths:
|
||||
description: 用户注册
|
||||
operationId: UserRegister
|
||||
parameters:
|
||||
- description: im token
|
||||
in: header
|
||||
name: token
|
||||
required: true
|
||||
type: string
|
||||
- description: secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID
|
||||
<br> ex为拓展字段 <br> gender为性别, 0为女, 1为男
|
||||
in: body
|
||||
@@ -2739,11 +2770,6 @@ paths:
|
||||
description: 获取用户的token
|
||||
operationId: UserToken
|
||||
parameters:
|
||||
- description: im token
|
||||
in: header
|
||||
name: token
|
||||
required: true
|
||||
type: string
|
||||
- description: secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID
|
||||
in: body
|
||||
name: req
|
||||
|
||||
+35
-13
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
_ "Open_IM/cmd/open_im_api/docs"
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
clientInit "Open_IM/internal/api/client_init"
|
||||
"Open_IM/internal/api/conversation"
|
||||
"Open_IM/internal/api/friend"
|
||||
"Open_IM/internal/api/group"
|
||||
@@ -17,16 +18,19 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
//_ "github.com/razeencheng/demo-go/swaggo-gin/docs"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
//"syscall"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
)
|
||||
|
||||
// @title open-IM-Server API
|
||||
@@ -41,18 +45,25 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
gin.SetMode(gin.DebugMode)
|
||||
r := gin.Default()
|
||||
// gin.SetMode(gin.DebugMode)
|
||||
r := gin.New()
|
||||
r.Use(gin.Recovery())
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
log.Info("load config: ", config.Config)
|
||||
log.Info("load config: ", config.Config)
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
if config.Config.Prometheus.Enable {
|
||||
promePkg.NewApiRequestCounter()
|
||||
promePkg.NewApiRequestFailedCounter()
|
||||
promePkg.NewApiRequestSuccessCounter()
|
||||
r.Use(promePkg.PromeTheusMiddleware)
|
||||
r.GET("/metrics", promePkg.PrometheusHandler())
|
||||
}
|
||||
// user routing group, which handles user registration and login services
|
||||
userRouterGroup := r.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //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)
|
||||
@@ -61,6 +72,7 @@ func main() {
|
||||
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
userRouterGroup.POST("/get_users", user.GetUsers)
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
@@ -92,9 +104,9 @@ func main() {
|
||||
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_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
|
||||
@@ -106,6 +118,8 @@ func main() {
|
||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||
groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo)
|
||||
groupRouterGroup.POST("/get_group_abstract_info", group.GetGroupAbstractInfo)
|
||||
//groupRouterGroup.POST("/get_group_all_member_list_by_split", group.GetGroupAllMemberListBySplit)
|
||||
}
|
||||
superGroupRouterGroup := r.Group("/super_group")
|
||||
{
|
||||
@@ -132,6 +146,8 @@ func main() {
|
||||
thirdGroup.POST("/get_rtc_invitation_info", apiThird.GetRTCInvitationInfo)
|
||||
thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp)
|
||||
thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken)
|
||||
thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential)
|
||||
thirdGroup.POST("/set_app_badge", apiThird.SetAppBadge)
|
||||
}
|
||||
//Message
|
||||
chatGroup := r.Group("/msg")
|
||||
@@ -201,6 +217,12 @@ func main() {
|
||||
|
||||
}
|
||||
|
||||
initGroup := r.Group("/init")
|
||||
{
|
||||
initGroup.POST("/set_client_config", clientInit.SetClientInitConfig)
|
||||
initGroup.POST("/get_client_config", clientInit.GetClientInitConfig)
|
||||
}
|
||||
|
||||
go apiThird.MinioInit()
|
||||
defaultPorts := config.Config.Api.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
||||
@@ -209,10 +231,10 @@ func main() {
|
||||
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)
|
||||
fmt.Println("start api server, address: ", address, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
err := r.Run(address)
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
log.Error("", "api run failed ", address, err.Error())
|
||||
panic("api start failed " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -23,6 +25,6 @@ func main() {
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
}
|
||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
fmt.Println("start cms api server, address: ", address)
|
||||
fmt.Println("start cms api server, address: ", address, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
router.Run(address)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_statistics
|
||||
BIN_DIR=../../../bin/
|
||||
BINARY_NAME=open_im_cron_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cron_task"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("start cronTask")
|
||||
cronTask.StartCronTask()
|
||||
}
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -20,10 +23,11 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
if config.Config.Prometheus.Enable {
|
||||
r.GET("/metrics", promePkg.PrometheusHandler())
|
||||
}
|
||||
authRouterGroup := r.Group("/demo")
|
||||
{
|
||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
@@ -31,6 +35,7 @@ func main() {
|
||||
authRouterGroup.POST("/password", register.SetPassword)
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
authRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||
}
|
||||
demoRouterGroup := r.Group("/auth")
|
||||
{
|
||||
@@ -39,18 +44,35 @@ func main() {
|
||||
demoRouterGroup.POST("/password", register.SetPassword)
|
||||
demoRouterGroup.POST("/login", register.Login)
|
||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
demoRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||
}
|
||||
|
||||
//deprecated
|
||||
cmsRouterGroup := r.Group("/cms_admin")
|
||||
{
|
||||
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||
cmsRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
cmsRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
cmsRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
cmsRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
cmsRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
cmsRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||
cmsRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||
cmsRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||
}
|
||||
defaultPorts := config.Config.Demo.Port
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 42233 as port")
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10004 as port")
|
||||
flag.Parse()
|
||||
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)
|
||||
fmt.Println("start demo api server address: ", address, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
go register.OnboardingProcessRoutine()
|
||||
go register.ImportFriendRoutine()
|
||||
err := r.Run(address)
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
|
||||
@@ -14,13 +14,15 @@ func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
defaultRpcPorts := config.Config.RpcPort.OpenImMessageGatewayPort
|
||||
defaultWsPorts := config.Config.LongConnSvr.WebsocketPort
|
||||
defaultPromePorts := config.Config.Prometheus.MessageGatewayPrometheusPort
|
||||
rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", defaultPromePorts[0], "PushrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort)
|
||||
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort, *prometheusPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
gate.Init(*rpcPort, *wsPort)
|
||||
gate.Run()
|
||||
gate.Run(*prometheusPort)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_transfer/logic"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
@@ -11,9 +13,11 @@ import (
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
logic.Init()
|
||||
fmt.Println("start msg_transfer server")
|
||||
logic.Run()
|
||||
fmt.Println("start msg_transfer server ", "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
logic.Run(*prometheusPort)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -13,12 +13,13 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImPushPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "PushrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
fmt.Println("start push rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start push rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
logic.Init(*rpcPort)
|
||||
logic.Run()
|
||||
logic.Run(*prometheusPort)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAdminCmsPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.AdminCmsPrometheusPort[0], "adminCMSPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
rpcAuth "Open_IM/internal/rpc/auth"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,9 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAuthPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.AuthPrometheusPort[0], "authPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package main
|
||||
import (
|
||||
rpcCache "Open_IM/internal/rpc/cache"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,9 +13,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImCachePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.CachePrometheusPort[0], "cachePrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start cache rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcCache.NewCacheServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,9 +12,16 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImConversationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.ConversationPrometheusPort[0], "conversationPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/rpc/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImFriendPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcFriendPort from cmd,default 12000 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.FriendPrometheusPort[0], "friendPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := friend.NewFriendServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/rpc/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImGroupPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.GroupPrometheusPort[0], "groupPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := group.NewGroupServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
.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
|
||||
@@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImMessageCmsPort[0]
|
||||
rpcPort := flag.Int("port", defaultPorts, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/rpc/msg"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImMessagePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessagePrometheusPort[0], "msgPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := msg.NewRpcChatServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
rpc "Open_IM/internal/rpc/office"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOfficePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.OfficePrometheusPort[0], "officePrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/rpc/organization"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOrganizationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.OrganizationPrometheusPort[0], "organizationPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := organization.NewServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/statistics"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImStatisticsPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/rpc/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
@@ -10,8 +12,15 @@ import (
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImUserPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.UserPrometheusPort[0], "userPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort)
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := user.NewUserServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
+64
-19
@@ -2,11 +2,13 @@
|
||||
# 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: 2.3.0-rc2
|
||||
serverversion: 2.3.1
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openim #默认即可
|
||||
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||
userName:
|
||||
password:
|
||||
|
||||
k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd
|
||||
|
||||
@@ -17,13 +19,16 @@ mysql:
|
||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||
dbTableName: eMsg #默认即可
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 20
|
||||
dbMaxOpenConns: 100
|
||||
dbMaxIdleConns: 10
|
||||
dbMaxLifeTime: 120
|
||||
dbMaxLifeTime: 5
|
||||
logLevel: 1 #1=slient 2=error 3=warn 4=info
|
||||
slowThreshold: 500
|
||||
|
||||
mongo:
|
||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||
dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
#dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbAddress: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbDirect: false
|
||||
dbTimeout: 60
|
||||
dbDatabase: openIM #mongo db 默认即可
|
||||
@@ -32,6 +37,7 @@ mongo:
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 100
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
|
||||
|
||||
redis:
|
||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||
@@ -43,18 +49,20 @@ redis:
|
||||
enableCluster: false #如果外部redis以集群方式启动,需要打开此开关
|
||||
|
||||
kafka:
|
||||
SASLUserName:
|
||||
SASLPassword:
|
||||
ws2mschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat"
|
||||
ws2mschatoffline:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat_offline"
|
||||
topic: "ws2ms_chat" #用于mongo和mysql保存消息
|
||||
# ws2mschatoffline:
|
||||
# addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
# topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用
|
||||
msgtomongo:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "msg_to_mongo"
|
||||
ms2pschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ms2ps_chat"
|
||||
topic: "ms2ps_chat" #消息push
|
||||
consumergroupid:
|
||||
msgToTransfer: mongo
|
||||
msgToMongo: mongo_ex
|
||||
@@ -72,7 +80,7 @@ kafka:
|
||||
serverip: 0.0.0.0
|
||||
|
||||
#作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到)
|
||||
rpcRegisterIP: 127.0.0.1
|
||||
rpcRegisterIP:
|
||||
#默认即可
|
||||
listenIP: 0.0.0.0
|
||||
|
||||
@@ -87,9 +95,7 @@ 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:
|
||||
@@ -101,6 +107,9 @@ cmsapi:
|
||||
sdk:
|
||||
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
dataDir: [ ../db/sdk/ ]
|
||||
openImWsAddress: ws://127.0.0.1:10001
|
||||
openImApiAddress: http://127.0.0.1:10002
|
||||
|
||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||
tencent:
|
||||
@@ -114,11 +123,12 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
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就可以填写
|
||||
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以
|
||||
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
storageTime: 50 #文件在minio中保存的时间
|
||||
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
|
||||
ali: # ali oss
|
||||
regionID: "oss-cn-beijing"
|
||||
accessKeyID: ""
|
||||
@@ -129,6 +139,15 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
|
||||
stsDurationSeconds: 3600
|
||||
OssRoleArn: "acs:ram::xxx:role/xxx"
|
||||
aws:
|
||||
accessKeyID: 1 #AssumeRole用户关联的accessKeyID
|
||||
accessKeySecret: 2 #AssumeRole用户关联的accessKeySecrect
|
||||
region: ap-southeast-1 #分区
|
||||
bucket: ouyang #桶
|
||||
finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host
|
||||
roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn
|
||||
externalId: AssumeRoleExtend #角色扩展Id
|
||||
roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称
|
||||
|
||||
dtm:
|
||||
serverURL: 127.0.0.1:10007
|
||||
@@ -141,13 +160,12 @@ rpcport: #rpc服务端口 默认即可
|
||||
openImGroupPort: [ 10150 ]
|
||||
openImAuthPort: [ 10160 ]
|
||||
openImPushPort: [ 10170 ]
|
||||
openImStatisticsPort: [ 10180 ]
|
||||
openImMessageCmsPort: [ 10190 ]
|
||||
openImAdminCmsPort: [ 10200 ]
|
||||
openImOfficePort: [ 10210 ]
|
||||
openImOrganizationPort: [ 10220 ]
|
||||
openImConversationPort: [ 10230 ]
|
||||
openImCachePort: [10240]
|
||||
openImCachePort: [ 10240 ]
|
||||
openImRealTimeCommPort: [ 11300 ]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@@ -166,8 +184,6 @@ rpcregistername: #rpc注册服务名,默认即可
|
||||
openImRelayName: Relay
|
||||
openImGroupName: Group
|
||||
openImAuthName: Auth
|
||||
openImStatisticsName: Statistics
|
||||
openImMessageCMSName: MessageCMS
|
||||
openImAdminCMSName: AdminCMS
|
||||
openImOfficeName: Office
|
||||
openImOrganizationName: Organization
|
||||
@@ -218,6 +234,8 @@ push:
|
||||
appKey: ""
|
||||
intent: ""
|
||||
enable: false
|
||||
channelID: ""
|
||||
channelName: ""
|
||||
fcm: #firebase cloud message 消息推送
|
||||
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
||||
enable: false
|
||||
@@ -250,7 +268,7 @@ singleMessageHasReadReceiptEnable: true
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||
# Token effective time day as a unit
|
||||
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||
accessExpire: 90 #token过期时间(天) 默认即可
|
||||
messageverify:
|
||||
friendVerify: false
|
||||
|
||||
@@ -297,6 +315,9 @@ callback:
|
||||
callbackUserOffline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackUserKickOff:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackOfflinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
@@ -719,6 +740,7 @@ demo:
|
||||
verificationCodeTemplateCode: 2902877
|
||||
enable: true
|
||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||
needInvitationCode: false
|
||||
# second
|
||||
codeTTL: 60
|
||||
useSuperCode: true
|
||||
@@ -730,6 +752,29 @@ demo:
|
||||
smtpPort: 25 #需开放此端口 出口方向
|
||||
testDepartMentID: 001
|
||||
imAPIURL: http://127.0.0.1:10002
|
||||
onboardProcess: false # 是否开启注册流程
|
||||
createOrganizationUserAndJoinDepartment: false
|
||||
joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机
|
||||
joinDepartmentGroups: false # 注册是否加部门群
|
||||
oaNotification: false # 注册是否发送OA通知
|
||||
|
||||
rtc:
|
||||
signalTimeout: 35
|
||||
|
||||
# prometheus每个服务监听的端口数量需要和rpc port保持一致
|
||||
prometheus:
|
||||
enable: false
|
||||
userPrometheusPort: [ 20110 ]
|
||||
friendPrometheusPort: [ 20120 ]
|
||||
messagePrometheusPort: [ 20130 ]
|
||||
messageGatewayPrometheusPort: [ 20140 ]
|
||||
groupPrometheusPort: [ 20150 ]
|
||||
authPrometheusPort: [ 20160 ]
|
||||
pushPrometheusPort: [ 20170 ]
|
||||
adminCmsPrometheusPort: [ 20200 ]
|
||||
officePrometheusPort: [ 20210 ]
|
||||
organizationPrometheusPort: [ 20220 ]
|
||||
conversationPrometheusPort: [ 20230 ]
|
||||
cachePrometheusPort: [ 20240 ]
|
||||
realTimeCommPrometheusPort: [ 21300 ]
|
||||
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # 端口数量和 script/path_info.cfg msg_transfer_service_num保持一致
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-cms
|
||||
image: openim/admin_cms:v2.2.0
|
||||
image: openim/admin_cms:v2.3.0release
|
||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
||||
ports:
|
||||
- containerPort: 10200
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: openim/api:v2.2.0
|
||||
image: openim/api:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10002
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: auth
|
||||
image: openim/auth:v2.2.0
|
||||
image: openim/auth:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10160
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
Vendored
+4
-1
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: cache
|
||||
image: openim/cache:v2.2.0
|
||||
image: openim/cache:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10240
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: cms-api
|
||||
image: openim/cms_api:v2.2.0
|
||||
image: openim/cms_api:v2.3.0release
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10006
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: conversation
|
||||
image: openim/conversation:v2.2.0
|
||||
image: openim/conversation:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10230
|
||||
@@ -23,6 +23,10 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: demo
|
||||
image: openim/demo:v2.2.0
|
||||
image: openim/demo:v2.3.0release
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10004
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: friend
|
||||
image: openim/friend:v2.2.0
|
||||
image: openim/friend:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10120
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: group
|
||||
image: openim/group:v2.2.0
|
||||
image: openim/group:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10150
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -10,8 +10,6 @@ service=(
|
||||
group
|
||||
auth
|
||||
admin-cms
|
||||
message-cms
|
||||
statistics
|
||||
office
|
||||
organization
|
||||
conversation
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: message-cms-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: message-cms # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: message-cms # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: message-cms
|
||||
image: openim/message_cms:v2.2.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10190
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_message_cms $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: msg
|
||||
image: openim/msg:v2.2.0
|
||||
image: openim/msg:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10130
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-gateway
|
||||
image: openim/msg_gateway:v2.2.0
|
||||
image: openim/msg_gateway:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- name: rpc-port
|
||||
@@ -26,6 +26,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,12 +15,15 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-transfer
|
||||
image: openim/msg_transfer:v2.2.0
|
||||
image: openim/msg_transfer:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: office
|
||||
image: openim/office:v2.2.0
|
||||
image: openim/office:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10210
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: organization
|
||||
image: openim/organization:v2.2.0
|
||||
image: openim/organization:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10220
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -9,8 +9,6 @@ service=(
|
||||
group
|
||||
auth
|
||||
admin_cms
|
||||
message_cms
|
||||
statistics
|
||||
office
|
||||
organization
|
||||
conversation
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: push
|
||||
image: openim/push:v2.2.0
|
||||
image: openim/push:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10170
|
||||
@@ -23,6 +23,9 @@ spec:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: sdk-server
|
||||
image: openim/sdk_server:v2.2.0
|
||||
image: openim/sdk_server:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10003
|
||||
@@ -25,8 +25,11 @@ spec:
|
||||
readOnly: true
|
||||
- name: local-db
|
||||
mountPath: /db/sdk
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
command: ["/Open-IM-Server/main"]
|
||||
args: ["-openIM_api_port", "10002", "-openIM_ws_port", "10001", "-sdk_ws_port", "10003", "-openIM_log_level", "6"]
|
||||
args: ["-openIM_ws_address", "ws_addr", "-sdk_ws_port", "10001", "-openIM_api_address", "api_address", "-openIM_log_level", "6"]
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: statistics-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: statistics # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: statistics # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: statistics
|
||||
image: openim/statistics:v2.2.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10180
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_statistics $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -15,12 +15,15 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: user
|
||||
image: openim/user:v2.2.0
|
||||
image: openim/user:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
||||
+41
-13
@@ -112,21 +112,10 @@ services:
|
||||
MINIO_ROOT_PASSWORD: key12345
|
||||
restart: always
|
||||
command: minio server /data --console-address ':9090'
|
||||
#
|
||||
# dtm:
|
||||
# image: yedf/dtm
|
||||
# ports:
|
||||
# - 36789:36789
|
||||
# - 36790:36790
|
||||
# environment:
|
||||
# STORE_DRIVER: mysql
|
||||
# STORE_HOST: localhost
|
||||
# STORE_USER: root
|
||||
# STORE_PASSWORD: ''
|
||||
# STORE_PORT: 3306
|
||||
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server:v2.3.0-rc2
|
||||
image: openim/open_im_server:v2.3.2
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
@@ -147,3 +136,42 @@ services:
|
||||
options:
|
||||
max-size: "1g"
|
||||
max-file: "2"
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
volumes:
|
||||
- ./docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
|
||||
# - ./components/prometheus_data:/prometheus
|
||||
container_name: prometheus
|
||||
ports:
|
||||
- 9091:9091
|
||||
depends_on:
|
||||
- open_im_server
|
||||
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
|
||||
network_mode: "host"
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana
|
||||
volumes:
|
||||
- ./docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
|
||||
- ./docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
|
||||
# - ./docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
|
||||
# - ./components/grafana:/var/lib/grafana
|
||||
- ./docker-compose_cfg/grafana.db:/var/lib/grafana/grafana.db
|
||||
container_name: grafana
|
||||
ports:
|
||||
- 10007:10007
|
||||
depends_on:
|
||||
- prometheus
|
||||
network_mode: "host"
|
||||
privileged: true
|
||||
user: root
|
||||
# -rw-r-----
|
||||
|
||||
node-exporter:
|
||||
image: quay.io/prometheus/node-exporter
|
||||
container_name: node-exporter
|
||||
restart: always
|
||||
ports:
|
||||
- "9100:9100"
|
||||
# command: --collector.ENTER-THE-NAME-OF-COLLECTOR
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#more datasource-compose.yaml
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:9091
|
||||
basicAuth: false
|
||||
isDefault: true
|
||||
version: 1
|
||||
editable: true
|
||||
Executable
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
||||
#more prometheus-compose.yml
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
monitor: 'openIM-monitor'
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9091']
|
||||
|
||||
- job_name: 'openIM-server'
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ['localhost:10002']
|
||||
labels:
|
||||
group: 'api'
|
||||
|
||||
- targets: ['localhost:10006']
|
||||
labels:
|
||||
group: 'cms-api'
|
||||
|
||||
|
||||
- targets: ['localhost:20110']
|
||||
labels:
|
||||
group: 'user'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
- targets: ['localhost:20130']
|
||||
labels:
|
||||
group: 'message'
|
||||
|
||||
- targets: ['localhost:20140']
|
||||
labels:
|
||||
group: 'msg-gateway'
|
||||
|
||||
- targets: ['localhost:20150']
|
||||
labels:
|
||||
group: 'group'
|
||||
|
||||
- targets: ['localhost:20160']
|
||||
labels:
|
||||
group: 'auth'
|
||||
|
||||
- targets: ['localhost:20170']
|
||||
labels:
|
||||
group: 'push'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
- targets: ['localhost:20200']
|
||||
labels:
|
||||
group: 'admin-cms'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'office'
|
||||
|
||||
- targets: ['localhost:20220']
|
||||
labels:
|
||||
group: 'organization'
|
||||
|
||||
- targets: ['localhost:20230']
|
||||
labels:
|
||||
group: 'conversation'
|
||||
|
||||
- targets: ['localhost:20240']
|
||||
labels:
|
||||
group: 'cache'
|
||||
|
||||
- targets: ['localhost:21400', 'localhost:21401', 'localhost:21402', 'localhost:21403']
|
||||
labels:
|
||||
group: 'msg-transfer'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- job_name: 'node'
|
||||
scrape_interval: 8s
|
||||
static_configs:
|
||||
- targets: ['localhost:9100']
|
||||
|
||||
@@ -11,6 +11,10 @@ require (
|
||||
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/aws/aws-sdk-go-v2 v1.16.7
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/dtm-labs/rockscache v0.0.11
|
||||
github.com/fatih/structs v1.1.0
|
||||
@@ -23,6 +27,7 @@ require (
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||
github.com/jinzhu/copier v0.3.4
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
@@ -34,7 +39,9 @@ require (
|
||||
github.com/olivere/elastic/v7 v7.0.23
|
||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe
|
||||
@@ -50,13 +57,13 @@ require (
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect
|
||||
golang.org/x/tools v0.1.11 // indirect
|
||||
google.golang.org/api v0.59.0
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
google.golang.org/protobuf v1.28.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
|
||||
|
||||
@@ -99,10 +99,33 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0 h1:8zixYquU1Odk+vzAaAQPAdRh1ZjmUXNQ1T+dUBvlhVo=
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA=
|
||||
github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7 h1:zfBwXus3u14OszRxGcqCDS4MfMCv10e8SMJ2r8Xm0Ns=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14 h1:+BqpqlydTq4c2et9Daury7gE+o67P4lbk7eybiCBNc4=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14/go.mod h1:CQBv+VVv8rR5z2xE+Chdh5m+rFfsqeY4k0veEZeq6QM=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9 h1:DloAJr0/jbvm0iVRFDFh8GlWxrOd9XKyX82U+dfVeZs=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9/go.mod h1:2Vavxl1qqQXJ8MUcQZTsIEW8cwenFCWYXtLRPba3L/o=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 h1:VfBdn2AxwMbFyJN/lF/xuT3SakomJ86PZu3rCxb5K0s=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8/go.mod h1:oL1Q3KuCq1D4NykQnIvtRiBGLUXhcpY5pl6QZB2XEPU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 h1:2C0pYHcUBmdzPj+EKNC4qj97oK6yjrUhc1KoSodglvk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14/go.mod h1:kdjrMwHwrC3+FsKhNcCMJ7tUVj/8uSD5CZXeQ4wV6fM=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 h1:2J+jdlBJWEmTyAwC82Ym68xCykIvnSnIN18b8xHGlcc=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8/go.mod h1:ZIV8GYoC6WLBW5KGs+o4rsc65/ozd+eQ0L31XF5VDwk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 h1:QquxR7NH3ULBsKC+NoTpilzbKKS+5AELfNREInbhvas=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15/go.mod h1:Tkrthp/0sNBShQQsamR7j/zY4p19tVTAs+nnqhH6R3c=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 h1:oKnAXxSF2FUvfgw8uzU/v9OTYorJJZ8eBmWhr9TWVVQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8/go.mod h1:rDVhIMAX9N2r8nWxDUlbubvvaFMnfsm+3jAV7q+rpM4=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 h1:760bUnTX/+d693FT6T6Oa7PZHfEQT9XMFZeM5IQIB0A=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12/go.mod h1:MO4qguFjs3wPGcCSpQ7kOFTwRvb+eu+fn+1vKleGHUk=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9 h1:yOfILxyjmtr2ubRkRJldlHDFBhf5vw4CzhbwWIBmimQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9/go.mod h1:O1IvkYxr+39hRf960Us6j0x1P8pDqhTX+oXM5kQNl/Y=
|
||||
github.com/aws/smithy-go v1.12.0 h1:gXpeZel/jPoWQ7OEmLIgCUnhkFftqNfwWUwAHSlp1v0=
|
||||
github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
@@ -133,6 +156,7 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
@@ -155,6 +179,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
@@ -180,9 +205,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
@@ -224,6 +251,7 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
@@ -273,8 +301,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
@@ -315,6 +344,7 @@ github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7Fsg
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
|
||||
@@ -393,6 +423,7 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkL
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||
github.com/lestrrat-go/strftime v1.0.4 h1:T1Rb9EPkAhgxKqbcMIPguPq8glqXTA1koF8n9BHElA8=
|
||||
github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
|
||||
@@ -404,7 +435,9 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
|
||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||
@@ -467,22 +500,35 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
|
||||
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||
github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE=
|
||||
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
|
||||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
@@ -616,8 +662,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -688,9 +734,12 @@ golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1
|
||||
golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
@@ -709,8 +758,9 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ
|
||||
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE=
|
||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b h1:clP8eMhB30EHdc0bd2Twtq6kgU7yl5ub2cQLSdrv1Dg=
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -721,8 +771,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -791,6 +842,7 @@ golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU=
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -1015,8 +1067,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
|
||||
+19
-11
@@ -3,6 +3,7 @@ package apiAuth
|
||||
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"
|
||||
@@ -10,10 +11,11 @@ import (
|
||||
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"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Summary 用户注册
|
||||
@@ -47,9 +49,9 @@ func UserRegister(c *gin.Context) {
|
||||
//copier.Copy(req.UserInfo, ¶ms)
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -65,7 +67,13 @@ func UserRegister(c *gin.Context) {
|
||||
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})
|
||||
if reply.CommonResp.ErrCode == constant.RegisterLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
||||
} else if reply.CommonResp.ErrCode == constant.InvitationError {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
} else {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -99,7 +107,7 @@ func UserToken(c *gin.Context) {
|
||||
params := api.UserTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
@@ -110,11 +118,11 @@ func UserToken(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.LoginIp}
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -206,9 +214,9 @@ func ForceLogout(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ForceLogout args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package clientInit
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
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/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
func SetClientInitConfig(c *gin.Context) {
|
||||
var req api.SetClientInitConfigReq
|
||||
var resp api.SetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
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
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.DiscoverPageURL != nil {
|
||||
m["discover_page_url"] = *req.DiscoverPageURL
|
||||
}
|
||||
if len(m) > 0 {
|
||||
err := imdb.SetClientInitConfig(m)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetClientInitConfig(c *gin.Context) {
|
||||
var req api.GetClientInitConfigReq
|
||||
var resp api.GetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
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
|
||||
}
|
||||
config, err := imdb.GetClientInitConfig()
|
||||
if err != nil {
|
||||
if !gorm.IsRecordNotFoundError(err) {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
resp.Data.DiscoverPageURL = config.DiscoverPageURL
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
@@ -26,15 +26,15 @@ func SetConversation(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Conversation = &pbUser.Conversation{}
|
||||
reqPb.Conversation = &pbConversation.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -69,9 +69,9 @@ func ModifyConversationField(c *gin.Context) {
|
||||
if 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.OpenImConversationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -104,9 +104,9 @@ func BatchSetConversations(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -154,9 +154,9 @@ func GetAllConversations(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -204,9 +204,9 @@ func GetConversation(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -254,9 +254,9 @@ func GetConversations(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -292,9 +292,9 @@ func SetRecvMsgOpt(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -48,7 +48,7 @@ func AddBlack(c *gin.Context) {
|
||||
}
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -93,9 +93,9 @@ func ImportFriend(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -156,9 +156,9 @@ func AddFriend(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -213,9 +213,9 @@ func AddFriendResponse(c *gin.Context) {
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -268,9 +268,9 @@ func DeleteFriend(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -322,9 +322,9 @@ func GetBlacklist(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -383,9 +383,9 @@ func SetFriendRemark(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -436,9 +436,9 @@ func RemoveBlack(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -490,9 +490,9 @@ func IsFriend(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -545,9 +545,9 @@ func GetFriendList(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -601,9 +601,9 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -657,9 +657,9 @@ func GetSelfFriendApplyList(c *gin.Context) {
|
||||
|
||||
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, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
+118
-58
@@ -11,7 +11,9 @@ import (
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -40,10 +42,14 @@ func KickGroupMember(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if len(params.KickedUserIDList) > constant.MaxNotificationNum {
|
||||
errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.KickedUserIDList)))
|
||||
log.Error(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.KickGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
@@ -56,9 +62,9 @@ func KickGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -119,9 +125,9 @@ func GetGroupMembersInfo(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -163,9 +169,9 @@ func GetGroupMemberList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -220,24 +226,25 @@ func GetGroupAllMemberList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * constant.GroupRPCRecvSize)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req, maxSizeOption)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed ", err.Error(), req.String())
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed err", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList))
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
@@ -275,9 +282,9 @@ func GetJoinedGroupList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -315,14 +322,15 @@ func InviteUserToGroup(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.InviteUserToGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
if len(req.InvitedUserIDList) > constant.MaxNotificationNum {
|
||||
errMsg := req.OperationID + " too many, Limit: " + utils.IntToString(constant.MaxNotificationNum)
|
||||
log.NewError(req.OperationID, errMsg, len(req.InvitedUserIDList))
|
||||
c.JSON(http.StatusRequestEntityTooLarge, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
if len(params.InvitedUserIDList) > constant.MaxNotificationNum {
|
||||
errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.InvitedUserIDList)))
|
||||
log.Error(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.InviteUserToGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
@@ -335,9 +343,9 @@ func InviteUserToGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -382,7 +390,13 @@ func CreateGroup(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
//
|
||||
|
||||
if len(params.MemberList) > constant.MaxNotificationNum {
|
||||
errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.MemberList)))
|
||||
log.Error(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
|
||||
@@ -405,9 +419,9 @@ func CreateGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -461,9 +475,9 @@ func GetRecvGroupApplicationList(c *gin.Context) {
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -513,9 +527,9 @@ func GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -567,9 +581,9 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -637,9 +651,9 @@ func ApplicationGroupResponse(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -690,9 +704,9 @@ func JoinGroup(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -744,9 +758,9 @@ func QuitGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -798,9 +812,9 @@ func SetGroupInfo(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -865,9 +879,9 @@ func TransferGroupOwner(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -919,9 +933,9 @@ func DismissGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -973,9 +987,9 @@ func MuteGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1027,9 +1041,9 @@ func CancelMuteGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1081,9 +1095,9 @@ func MuteGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1135,9 +1149,9 @@ func CancelMuteGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1179,9 +1193,9 @@ func SetGroupMemberNickname(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1249,10 +1263,10 @@ func SetGroupMemberInfo(c *gin.Context) {
|
||||
if req.RoleLevel != nil {
|
||||
reqPb.RoleLevel = &wrappers.Int32Value{Value: *req.RoleLevel}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", reqPb.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -1267,6 +1281,52 @@ func SetGroupMemberInfo(c *gin.Context) {
|
||||
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", resp)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupAbstractInfo(c *gin.Context) {
|
||||
var (
|
||||
req api.GetGroupAbstractInfoReq
|
||||
resp api.GetGroupAbstractInfoResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
ok, 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupAbstractInfo(context.Background(), &rpc.GetGroupAbstractInfoReq{
|
||||
GroupID: req.GroupID,
|
||||
OpUserID: opUserID,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", respPb.String())
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
resp.GroupMemberNumber = respPb.GroupMemberNumber
|
||||
resp.GroupMemberListHash = respPb.GroupMemberListHash
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ func GetJoinedSuperGroupList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetJoinedSuperGroupListReq{OperationID: req.OperationID, OpUserID: opUserID, UserID: req.FromUserID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -67,9 +67,9 @@ func GetSuperGroupsInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetSuperGroupsInfoReq{OperationID: req.OperationID, OpUserID: opUserID, GroupIDList: req.GroupIDList}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -10,20 +10,21 @@ 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"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validate *validator.Validate
|
||||
@@ -50,6 +51,8 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
case constant.Video:
|
||||
fallthrough
|
||||
case constant.File:
|
||||
fallthrough
|
||||
case constant.AdvancedRevoke:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
@@ -145,6 +148,8 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
case constant.AdvancedRevoke:
|
||||
data = MessageRevoked{}
|
||||
case constant.OANotification:
|
||||
data = OANotificationElem{}
|
||||
params.SessionType = constant.NotificationChatType
|
||||
@@ -189,7 +194,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType:
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
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": ""})
|
||||
@@ -202,32 +207,33 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
||||
var status int32
|
||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
if resp != nil && resp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||
}
|
||||
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
|
||||
}
|
||||
status = constant.MsgSendFailed
|
||||
} else {
|
||||
status = constant.MsgSendSuccessed
|
||||
}
|
||||
|
||||
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||
}
|
||||
if respSetSendMsgStatus != nil && respSetSendMsgStatus.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), respSetSendMsgStatus.ErrCode, respSetSendMsgStatus.ErrMsg)
|
||||
}
|
||||
|
||||
log.Info(params.OperationID, "", "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}}
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: open_im_sdk.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -314,24 +320,43 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
||||
}
|
||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||
var msgSendFailedFlag bool
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
//resp.Data.FailedIDList = params.RecvIDList
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
||||
return
|
||||
}
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
respSetSendMsgStatus, err := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: constant.MsgIsSending})
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if respSetSendMsgStatus.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", respSetSendMsgStatus)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": respSetSendMsgStatus.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
req := &api.ManagementSendMsgReq{
|
||||
ManagementSendMsg: params.ManagementSendMsg,
|
||||
}
|
||||
pbData := newUserSendMsgReq(req)
|
||||
for _, recvID := range params.RecvIDList {
|
||||
var recvList []string
|
||||
if params.IsSendAll {
|
||||
recvList, err = im_mysql_model.SelectAllUserID()
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
}
|
||||
} else {
|
||||
recvList = params.RecvIDList
|
||||
}
|
||||
for _, recvID := range recvList {
|
||||
pbData.MsgData.RecvID = recvID
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||
|
||||
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
@@ -352,14 +377,18 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
||||
RecvID: recvID,
|
||||
})
|
||||
}
|
||||
var status int32
|
||||
if msgSendFailedFlag {
|
||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||
}
|
||||
if resp != nil && resp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||
}
|
||||
status = constant.MsgSendFailed
|
||||
} else {
|
||||
status = constant.MsgSendSuccessed
|
||||
}
|
||||
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||
}
|
||||
if respSetSendMsgStatus != nil && resp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
@@ -374,9 +403,9 @@ func CheckMsgIsSendSuccess(c *gin.Context) {
|
||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -473,3 +502,10 @@ type OANotificationElem struct {
|
||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||
Ex string `mapstructure:"ex" json:"ex"`
|
||||
}
|
||||
type MessageRevoked struct {
|
||||
RevokerID string `mapstructure:"notificationName" json:"revokerID" validate:"required"`
|
||||
RevokerRole int32 `mapstructure:"notificationName" json:"revokerRole" validate:"required"`
|
||||
ClientMsgID string `mapstructure:"notificationName" json:"clientMsgID" validate:"required"`
|
||||
RevokerNickname string `mapstructure:"notificationName" json:"revokerNickname"`
|
||||
SessionType int32 `mapstructure:"notificationName" json:"sessionType" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -17,54 +17,12 @@ import (
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
params := api.DeleteUsersReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DeleteUsersReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
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, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
|
||||
if len(RpcResp.FailedUserIDList) == 0 {
|
||||
resp.FailedUserIDList = []string{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取所有用户uid列表
|
||||
// @Description 获取所有用户uid列表
|
||||
// @Tags 用户相关
|
||||
@@ -97,9 +55,9 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -152,9 +110,9 @@ func AccountCheck(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -198,7 +156,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
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.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), params.OperationID)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
|
||||
+12
-12
@@ -54,9 +54,9 @@ func DelMsg(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -79,11 +79,11 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
resp api.DelSuperGroupMsgResp
|
||||
)
|
||||
rpcReq := &rpc.DelSuperGroupMsgReq{}
|
||||
utils.CopyStructFields(req, &req)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(rpcReq, &req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
@@ -130,9 +130,9 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -140,8 +140,8 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
client := rpc.NewMsgClient(etcdConn)
|
||||
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
||||
if req.IsAllDelete {
|
||||
RpcResp, err := client.DelSuperGroupMsg(context.Background(),rpcReq)
|
||||
if req.IsAllDelete {
|
||||
RpcResp, err := client.DelSuperGroupMsg(context.Background(), rpcReq)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete DelSuperGroupMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call DelSuperGroupMsg rpc server failed"})
|
||||
@@ -152,7 +152,7 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
resp.ErrMsg = RpcResp.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}else{
|
||||
} else {
|
||||
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
@@ -203,9 +203,9 @@ func ClearMsg(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -251,9 +251,9 @@ func SetMsgMinSeq(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -35,9 +35,9 @@ func GetSeq(c *gin.Context) {
|
||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := pbData.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -51,9 +51,9 @@ func PullMsgBySeqList(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := pbData.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -71,9 +71,9 @@ func SendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info(params.OperationID, "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
+14
-14
@@ -54,9 +54,9 @@ func GetUserTags(c *gin.Context) {
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -119,9 +119,9 @@ func CreateTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -179,9 +179,9 @@ func DeleteTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -239,9 +239,9 @@ func SetTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -299,9 +299,9 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.SendID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -361,9 +361,9 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -428,9 +428,9 @@ func GetUserTagByID(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -56,9 +56,9 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -120,9 +120,9 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -183,9 +183,9 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -245,9 +245,9 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -305,9 +305,9 @@ func DeleteComment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -366,9 +366,9 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -436,9 +436,9 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
}
|
||||
reqPb.OpUserID = opUserID
|
||||
reqPb.UserID = req.UserID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -548,9 +548,9 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -649,9 +649,9 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -48,9 +48,9 @@ func CreateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -103,9 +103,9 @@ func UpdateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -156,9 +156,9 @@ func GetSubDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -212,9 +212,9 @@ func DeleteDepartment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -266,9 +266,9 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -319,9 +319,9 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -372,9 +372,9 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -425,9 +425,9 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -479,9 +479,9 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -532,9 +532,9 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -584,9 +584,9 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -637,9 +637,9 @@ func DeleteUserInDepartment(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
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"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sts"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AwsStorageCredential(c *gin.Context) {
|
||||
var (
|
||||
req api.AwsStorageCredentialReq
|
||||
resp api.AwsStorageCredentialResp
|
||||
)
|
||||
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
|
||||
}
|
||||
//原始帐号信息
|
||||
awsSourceConfig, err := awsConfig.LoadDefaultConfig(context.TODO(), awsConfig.WithRegion(config.Config.Credential.Aws.Region),
|
||||
awsConfig.WithCredentialsProvider(credentials.StaticCredentialsProvider{
|
||||
Value: aws.Credentials{
|
||||
AccessKeyID: config.Config.Credential.Aws.AccessKeyID,
|
||||
SecretAccessKey: config.Config.Credential.Aws.AccessKeySecret,
|
||||
Source: "Open IM OSS",
|
||||
},
|
||||
}))
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "Init AWS S3 Credential failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
//帐号转化
|
||||
awsStsClient := sts.NewFromConfig(awsSourceConfig)
|
||||
StsRole, err := awsStsClient.AssumeRole(context.Background(), &sts.AssumeRoleInput{
|
||||
RoleArn: aws.String(config.Config.Credential.Aws.RoleArn),
|
||||
DurationSeconds: aws.Int32(constant.AwsDurationTimes),
|
||||
RoleSessionName: aws.String(config.Config.Credential.Aws.RoleSessionName),
|
||||
ExternalId: aws.String(config.Config.Credential.Aws.ExternalId),
|
||||
})
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "AWS S3 AssumeRole failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
resp.CosData.AccessKeyId = string(*StsRole.Credentials.AccessKeyId)
|
||||
resp.CosData.SecretAccessKey = string(*StsRole.Credentials.SecretAccessKey)
|
||||
resp.CosData.SessionToken = string(*StsRole.Credentials.SessionToken)
|
||||
resp.CosData.Bucket = config.Config.Credential.Aws.Bucket
|
||||
resp.CosData.RegionID = config.Config.Credential.Aws.Region
|
||||
resp.CosData.FinalHost = config.Config.Credential.Aws.FinalHost
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@@ -10,18 +11,10 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/**
|
||||
* FCM第三方上报Token
|
||||
*/
|
||||
type FcmUpdateTokenReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
|
||||
FcmToken string `json:"fcmToken"`
|
||||
}
|
||||
|
||||
func FcmUpdateToken(c *gin.Context) {
|
||||
var (
|
||||
req FcmUpdateTokenReq
|
||||
req api.FcmUpdateTokenReq
|
||||
resp api.FcmUpdateTokenResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
@@ -34,7 +27,9 @@ func FcmUpdateToken(c *gin.Context) {
|
||||
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})
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, UserId)
|
||||
@@ -43,10 +38,12 @@ func FcmUpdateToken(c *gin.Context) {
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
//逻辑处理完毕
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ func MinioInit() {
|
||||
}
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
//Region: config.Config.Credential.Minio.Location,
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
@@ -46,8 +47,10 @@ func MinioInit() {
|
||||
return
|
||||
}
|
||||
opt := minio.MakeBucketOptions{
|
||||
Region: config.Config.Credential.Minio.Location,
|
||||
ObjectLocking: false,
|
||||
Region: config.Config.Credential.Minio.Location,
|
||||
}
|
||||
if config.Config.Credential.Minio.IsDistributedMod == true {
|
||||
opt.ObjectLocking = true
|
||||
}
|
||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
||||
if err != nil {
|
||||
@@ -78,6 +81,9 @@ func MinioInit() {
|
||||
return
|
||||
}
|
||||
}
|
||||
policy, err := MinioClient.GetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
log.NewInfo("", utils.GetSelfFuncName(), policy)
|
||||
|
||||
// 自动化桶public的代码
|
||||
policyJsonString := fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.Bucket)
|
||||
|
||||
@@ -15,6 +15,8 @@ import (
|
||||
_ "github.com/minio/minio-go/v7"
|
||||
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary minio上传文件(web api)
|
||||
@@ -145,13 +147,13 @@ func MinioStorageCredential(c *gin.Context) {
|
||||
}
|
||||
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
||||
log.NewError(req.OperationID, 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())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "li.Get error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
@@ -161,6 +163,7 @@ func MinioStorageCredential(c *gin.Context) {
|
||||
resp.BucketName = config.Config.Credential.Minio.Bucket
|
||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||
resp.StorageTime = config.Config.Credential.Minio.StorageTime
|
||||
resp.IsDistributedMod = config.Config.Credential.Minio.IsDistributedMod
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
@@ -175,6 +178,7 @@ func UploadUpdateApp(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var yamlName string
|
||||
if req.Yaml == nil {
|
||||
yamlName = ""
|
||||
@@ -217,6 +221,13 @@ func UploadUpdateApp(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func version2Int(version string) (int, error) {
|
||||
versions := strings.Split(version, ".")
|
||||
s := strings.Join(versions, "")
|
||||
versionInt, err := strconv.Atoi(s)
|
||||
return versionInt, err
|
||||
}
|
||||
|
||||
func GetDownloadURL(c *gin.Context) {
|
||||
var (
|
||||
req api.GetDownloadURLReq
|
||||
@@ -237,7 +248,13 @@ func GetDownloadURL(c *gin.Context) {
|
||||
}
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
|
||||
if app != nil {
|
||||
if app.Version != req.Version && app.Version != "" {
|
||||
appVersion, err := version2Int(app.Version)
|
||||
reqVersion, err := version2Int(req.Version)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), "req version", req.Version, "app version", app.Version)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "req version:", reqVersion, "app version:", appVersion)
|
||||
if appVersion > reqVersion && app.Version != "" {
|
||||
resp.Data.HasNewVersion = true
|
||||
if app.ForceUpdate == true {
|
||||
resp.Data.ForceUpdate = true
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func SetAppBadge(c *gin.Context) {
|
||||
var (
|
||||
req api.SetAppBadgeReq
|
||||
resp api.SetAppBadgeResp
|
||||
)
|
||||
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, 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.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
if !token_verify.CheckAccess(opUserID, req.FromUserID) {
|
||||
log.NewError(req.OperationID, "CheckAccess false ", opUserID, req.FromUserID)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "no permission"})
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, opUserID)
|
||||
err := db.DB.SetUserBadgeUnreadCountSum(req.FromUserID, int(req.AppUnreadCount))
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "SetUserBadgeUnreadCountSum failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
+81
-25
@@ -14,9 +14,10 @@ import (
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetUsersInfoFromCache(c *gin.Context) {
|
||||
@@ -38,9 +39,9 @@ func GetUsersInfoFromCache(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -86,9 +87,9 @@ func GetFriendIDListFromCache(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -128,9 +129,9 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -159,7 +160,7 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_users_info [post]
|
||||
func GetUsersInfo(c *gin.Context) {
|
||||
func GetUsersPublicInfo(c *gin.Context) {
|
||||
params := api.GetUsersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
@@ -181,9 +182,9 @@ func GetUsersInfo(c *gin.Context) {
|
||||
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -239,9 +240,9 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -290,9 +291,9 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "SetGlobalRecvMessageOpt args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -324,9 +325,9 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
func GetSelfUserInfo(c *gin.Context) {
|
||||
params := api.GetSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := "BindJSON failed " + err.Error()
|
||||
log.NewError("0", "BindJSON failed ", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
@@ -338,17 +339,17 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
||||
req.UserIDList = append(req.UserIDList, params.UserID)
|
||||
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, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -366,11 +367,10 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
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}}
|
||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Summary 获取用户在线状态
|
||||
@@ -415,7 +415,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
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.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), params.OperationID)
|
||||
for _, v := range grpcCons {
|
||||
log.Debug(params.OperationID, "get node ", *v, v.Target())
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
@@ -456,3 +456,59 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetUsers(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUsersReq
|
||||
resp api.GetUsersResp
|
||||
reqPb rpc.GetUsersReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "Bind failed ", err.Error(), req)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.UserID = req.UserID
|
||||
reqPb.UserName = req.UserName
|
||||
reqPb.Content = req.Content
|
||||
reqPb.Pagination = &open_im_sdk.RequestPagination{ShowNumber: req.ShowNumber, PageNumber: req.PageNumber}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.UserList {
|
||||
user := api.CMSUser{}
|
||||
utils.CopyStructFields(&user, v.User)
|
||||
user.IsBlock = v.IsBlock
|
||||
resp.Data.UserList = append(resp.Data.UserList, &user)
|
||||
}
|
||||
resp.CommResp.ErrCode = respPb.CommonResp.ErrCode
|
||||
resp.CommResp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.Data.TotalNum = respPb.TotalNums
|
||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
+107
-10
@@ -4,19 +4,21 @@ 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"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
|
||||
url2 "net/url"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,6 +26,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
operationID := utils.OperationIDGenerator()
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
|
||||
var initUrl string
|
||||
@@ -63,16 +66,16 @@ func AdminLogin(c *gin.Context) {
|
||||
reqPb pbAdmin.AdminLoginReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.Secret = req.Secret
|
||||
reqPb.AdminID = req.AdminName
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -81,9 +84,103 @@ func AdminLogin(c *gin.Context) {
|
||||
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)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.FaceURL = respPb.FaceURL
|
||||
resp.UserName = respPb.UserName
|
||||
resp.Token = respPb.Token
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
||||
// resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", respPb.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
||||
// resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.GetUserRegisterAddFriendIDListRequest
|
||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.GetUserRegisterAddFriendIDList(context.Background(), &pbAdmin.GetUserRegisterAddFriendIDListReq{OperationID: req.OperationID, Pagination: &pbCommon.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Users = respPb.UserInfoList
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetUserFriends(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetFriendsReq
|
||||
resp cms_api_struct.GetFriendsResp
|
||||
reqPb pbAdmin.GetUserFriendsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.UserID = req.UserID
|
||||
reqPb.FriendUserName = req.FriendUserName
|
||||
reqPb.FriendUserID = req.FriendUserID
|
||||
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.GetUserFriends(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.FriendInfoList {
|
||||
friend := &cms_api_struct.FriendInfo{}
|
||||
utils.CopyStructFields(friend, v)
|
||||
friend.Nickname = v.FriendUser.Nickname
|
||||
friend.UserID = v.FriendUser.UserID
|
||||
resp.FriendInfoList = append(resp.FriendInfoList, friend)
|
||||
}
|
||||
resp.FriendNums = respPb.FriendNums
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
+28
-498
@@ -3,8 +3,6 @@ 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"
|
||||
@@ -18,308 +16,49 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetGroupById(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupByIdRequest
|
||||
resp cms_api_struct.GetGroupByIdResponse
|
||||
reqPb pbGroup.GetGroupByIdReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb.GroupID = req.GroupID
|
||||
reqPb.GroupName = req.GroupName
|
||||
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)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
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,
|
||||
})
|
||||
groupResp := cms_api_struct.GroupResponse{}
|
||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
||||
resp.Groups = append(resp.Groups, groupResp)
|
||||
}
|
||||
resp.GroupNums = int(respPb.GroupNum)
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "CreateGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func BanGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanGroupChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BanGroupChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
|
||||
}
|
||||
|
||||
func BanPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OpenPrivateChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func GetGroupMembers(c *gin.Context) {
|
||||
@@ -328,9 +67,9 @@ func GetGroupMembers(c *gin.Context) {
|
||||
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)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
@@ -339,11 +78,11 @@ func GetGroupMembers(c *gin.Context) {
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -352,7 +91,7 @@ func GetGroupMembers(c *gin.Context) {
|
||||
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)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||
@@ -360,220 +99,11 @@ func GetGroupMembers(c *gin.Context) {
|
||||
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(),
|
||||
})
|
||||
for _, groupMember := range respPb.Members {
|
||||
memberResp := cms_api_struct.GroupMemberResponse{}
|
||||
utils.CopyStructFields(&memberResp, groupMember)
|
||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||
}
|
||||
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
|
||||
}
|
||||
reqPb.OperationId = utils.OperationIDGenerator()
|
||||
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, reqPb.OperationId)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationId + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationId, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func SetGroupMaster(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.SetGroupMasterRequest
|
||||
_ cms_api_struct.SetGroupMasterResponse
|
||||
reqPb pbGroup.OperateUserRoleReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func SetGroupOrdinaryUsers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.SetGroupMemberRequest
|
||||
_ cms_api_struct.AdminLoginResponse
|
||||
reqPb pbGroup.OperateUserRoleReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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.GroupInfoForSet = &commonPb.GroupInfoForSet{
|
||||
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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
@@ -3,96 +3,27 @@ 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"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"Open_IM/pkg/common/constant"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func BroadcastMessage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.BoradcastMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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
|
||||
req cms_api_struct.GetChatLogsReq
|
||||
resp cms_api_struct.GetChatLogsResp
|
||||
reqPb pbAdminCMS.GetChatLogsReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
@@ -101,39 +32,28 @@ func GetChatLogs(c *gin.Context) {
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
client := pbAdminCMS.NewAdminCMSClient(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)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
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,
|
||||
})
|
||||
for _, v := range respPb.ChatLogs {
|
||||
chatLog := cms_api_struct.ChatLog{}
|
||||
utils.CopyStructFields(&chatLog, v)
|
||||
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
||||
}
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
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"
|
||||
"net/http"
|
||||
|
||||
"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)
|
||||
// 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)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
|
||||
return
|
||||
} else {
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cms_api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func prometheusHandler() gin.HandlerFunc {
|
||||
h := promhttp.Handler()
|
||||
|
||||
return func(c *gin.Context) {
|
||||
h.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}
|
||||
+40
-55
@@ -2,94 +2,79 @@ package cms_api
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api/admin"
|
||||
"Open_IM/internal/cms_api/friend"
|
||||
"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"
|
||||
"Open_IM/internal/demo/register"
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func NewGinRouter() *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
baseRouter := gin.Default()
|
||||
baseRouter := gin.New()
|
||||
baseRouter.Use()
|
||||
if config.Config.Prometheus.Enable {
|
||||
baseRouter.GET("/metrics", promePkg.PrometheusHandler())
|
||||
}
|
||||
router := baseRouter.Group("/cms")
|
||||
router.Use(middleware.CorsHandler())
|
||||
adminRouterGroup := router.Group("/admin")
|
||||
{
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
adminRouterGroup.Use(middleware.JWTAuth())
|
||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
||||
|
||||
adminRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||
adminRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
adminRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
adminRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
adminRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
adminRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
adminRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||
adminRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||
adminRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||
}
|
||||
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)
|
||||
statisticsRouterGroup.POST("/get_messages_statistics", statistics.GetMessagesStatistics)
|
||||
statisticsRouterGroup.POST("/get_user_statistics", statistics.GetUserStatistics)
|
||||
statisticsRouterGroup.POST("/get_group_statistics", statistics.GetGroupStatistics)
|
||||
statisticsRouterGroup.POST("/get_active_user", statistics.GetActiveUser)
|
||||
statisticsRouterGroup.POST("/get_active_group", statistics.GetActiveGroup)
|
||||
}
|
||||
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)
|
||||
groupRouterGroup.POST("/get_groups", group.GetGroups)
|
||||
groupRouterGroup.POST("/get_group_members", group.GetGroupMembers)
|
||||
}
|
||||
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")
|
||||
userRouterGroup.POST("/get_block_users", user.GetBlockUsers)
|
||||
}
|
||||
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)
|
||||
messageCMSRouterGroup.POST("/get_chat_logs", messageCMS.GetChatLogs)
|
||||
}
|
||||
friendCMSRouterGroup := r2.Group("/friend")
|
||||
{
|
||||
friendCMSRouterGroup.POST("/get_friends", friend.GetUserFriends)
|
||||
}
|
||||
|
||||
return baseRouter
|
||||
}
|
||||
|
||||
@@ -3,15 +3,14 @@ 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"
|
||||
admin "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -20,38 +19,40 @@ func GetMessagesStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetMessageStatisticsRequest
|
||||
resp cms_api_struct.GetMessageStatisticsResponse
|
||||
reqPb pb.GetMessageStatisticsReq
|
||||
reqPb admin.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)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
if err := c.BindJSON(&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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
||||
client := admin.NewAdminCMSClient(etcdConn)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||
defer cancel()
|
||||
respPb, err := client.GetMessageStatistics(ctx, &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
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\""
|
||||
MessageNum int "json:\"messageNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
MessageNum: int(v.Num),
|
||||
@@ -60,53 +61,54 @@ func GetMessagesStatistics(c *gin.Context) {
|
||||
for _, v := range respPb.GroupMessageNumList {
|
||||
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
MessageNum int "json:\"message_num\""
|
||||
MessageNum int "json:\"messageNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
MessageNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func GetUserStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUserStatisticsRequest
|
||||
resp cms_api_struct.GetUserStatisticsResponse
|
||||
reqPb pb.GetUserStatisticsReq
|
||||
reqPb admin.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)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
if err := c.BindJSON(&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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
||||
client := admin.NewAdminCMSClient(etcdConn)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||
defer cancel()
|
||||
respPb, err := client.GetUserStatistics(ctx, &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
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\""
|
||||
ActiveUserNum int "json:\"activeUserNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
ActiveUserNum: int(v.Num),
|
||||
@@ -115,7 +117,7 @@ func GetUserStatistics(c *gin.Context) {
|
||||
for _, v := range respPb.IncreaseUserNumList {
|
||||
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
IncreaseUserNum int "json:\"increase_user_num\""
|
||||
IncreaseUserNum int "json:\"increaseUserNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
IncreaseUserNum: int(v.Num),
|
||||
@@ -124,43 +126,45 @@ func GetUserStatistics(c *gin.Context) {
|
||||
for _, v := range respPb.TotalUserNumList {
|
||||
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
TotalUserNum int "json:\"total_user_num\""
|
||||
TotalUserNum int "json:\"totalUserNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
TotalUserNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func GetGroupStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupStatisticsRequest
|
||||
resp cms_api_struct.GetGroupStatisticsResponse
|
||||
reqPb pb.GetGroupStatisticsReq
|
||||
reqPb admin.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)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
||||
client := admin.NewAdminCMSClient(etcdConn)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||
defer cancel()
|
||||
respPb, err := client.GetGroupStatistics(ctx, &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
// utils.CopyStructFields(&resp, respPb)
|
||||
@@ -170,7 +174,7 @@ func GetGroupStatistics(c *gin.Context) {
|
||||
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
||||
struct {
|
||||
Date string "json:\"date\""
|
||||
IncreaseGroupNum int "json:\"increase_group_num\""
|
||||
IncreaseGroupNum int "json:\"increaseGroupNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
IncreaseGroupNum: int(v.Num),
|
||||
@@ -180,7 +184,7 @@ func GetGroupStatistics(c *gin.Context) {
|
||||
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
||||
struct {
|
||||
Date string "json:\"date\""
|
||||
TotalGroupNum int "json:\"total_group_num\""
|
||||
TotalGroupNum int "json:\"totalGroupNum\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
TotalGroupNum: int(v.Num),
|
||||
@@ -188,77 +192,81 @@ func GetGroupStatistics(c *gin.Context) {
|
||||
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func GetActiveUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveUserRequest
|
||||
resp cms_api_struct.GetActiveUserResponse
|
||||
reqPb pb.GetActiveUserReq
|
||||
reqPb admin.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)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
||||
client := admin.NewAdminCMSClient(etcdConn)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||
defer cancel()
|
||||
respPb, err := client.GetActiveUser(ctx, &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func GetActiveGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveGroupRequest
|
||||
resp cms_api_struct.GetActiveGroupResponse
|
||||
reqPb pb.GetActiveGroupReq
|
||||
reqPb admin.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)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
if err := c.BindJSON(&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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
||||
client := admin.NewAdminCMSClient(etcdConn)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||
defer cancel()
|
||||
respPb, err := client.GetActiveGroup(ctx, &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
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 string "json:\"groupName\""
|
||||
GroupId string "json:\"groupID\""
|
||||
MessageNum int "json:\"messageNum\""
|
||||
}{
|
||||
GroupName: group.GroupName,
|
||||
GroupId: group.GroupId,
|
||||
@@ -266,5 +274,5 @@ func GetActiveGroup(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
+35
-277
@@ -3,196 +3,18 @@ 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
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(reqPb.OperationID, 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
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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(reqPb.OperationID, 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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(reqPb.OperationID, 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, "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
|
||||
@@ -200,13 +22,13 @@ func AddUser(c *gin.Context) {
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
@@ -214,44 +36,43 @@ func AddUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.AddUser(context.Background(), &reqPb)
|
||||
respPb, err := client.AddUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
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)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
fmt.Println(reqPb)
|
||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
||||
respPb, err := client.BlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func UnblockUser(c *gin.Context) {
|
||||
@@ -260,29 +81,30 @@ func UnblockUser(c *gin.Context) {
|
||||
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)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||
respPb, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func GetBlockUsers(c *gin.Context) {
|
||||
@@ -293,18 +115,18 @@ func GetBlockUsers(c *gin.Context) {
|
||||
respPb *pb.GetBlockUsersResp
|
||||
)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@@ -313,17 +135,18 @@ func GetBlockUsers(c *gin.Context) {
|
||||
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)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
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,
|
||||
UserID: v.UserInfo.UserID,
|
||||
FaceURL: v.UserInfo.FaceURL,
|
||||
Nickname: v.UserInfo.Nickname,
|
||||
PhoneNumber: v.UserInfo.PhoneNumber,
|
||||
Email: v.UserInfo.Email,
|
||||
Gender: int(v.UserInfo.Gender),
|
||||
},
|
||||
BeginDisableTime: v.BeginDisableTime,
|
||||
EndDisableTime: v.EndDisableTime,
|
||||
@@ -333,70 +156,5 @@ func GetBlockUsers(c *gin.Context) {
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.UserNums = respPb.UserNums
|
||||
log.NewInfo(reqPb.OperationID, 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, "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(reqPb.OperationID, 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
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, 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, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, "DeleteUser rpc failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package cronTask
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
goRedis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"math"
|
||||
)
|
||||
|
||||
const oldestList = 0
|
||||
const newestList = -1
|
||||
|
||||
func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, groupID, oldestList, &delMsgIDList)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, "deleteMongoMsg failed")
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDList:", delMsgIDList, "minSeq", minSeq)
|
||||
for _, userID := range userIDList {
|
||||
userMinSeq, err := db.DB.GetGroupUserMinSeq(groupID, userID)
|
||||
if err != nil && err != goRedis.Nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error())
|
||||
continue
|
||||
}
|
||||
if userMinSeq > uint64(minSeq) {
|
||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, userMinSeq)
|
||||
} else {
|
||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq))
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userID, userMinSeq, minSeq)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, userID, oldestList, &delMsgIDList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDMap: ", delMsgIDList, "minSeq", minSeq)
|
||||
err = db.DB.SetUserMinSeq(userID, minSeq)
|
||||
return err
|
||||
}
|
||||
|
||||
func delMongoMsgs(operationID string, delMsgIDList *[][2]interface{}) error {
|
||||
if len(*delMsgIDList) > 0 {
|
||||
var IDList []string
|
||||
for _, v := range *delMsgIDList {
|
||||
IDList = append(IDList, v[0].(string))
|
||||
}
|
||||
err := db.DB.DelMongoMsgs(IDList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "DelMongoMsgs failed")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// recursion
|
||||
func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[][2]interface{}) (uint32, error) {
|
||||
// 从最旧的列表开始找
|
||||
msgs, err := db.DB.GetUserMsgListByIndex(ID, index)
|
||||
if err != nil || msgs.UID == "" {
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||
}
|
||||
return getDelMaxSeqByIDList(*delMsgIDList), delMongoMsgs(operationID, delMsgIDList)
|
||||
}
|
||||
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID)
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "get msgs: ", msgs.UID)
|
||||
for i, msg := range msgs.Msg {
|
||||
// 找到列表中不需要删除的消息了
|
||||
if utils.GetCurrentTimestampByMill() < msg.SendTime+int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000 {
|
||||
if err := delMongoMsgs(operationID, delMsgIDList); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
minSeq := getDelMaxSeqByIDList(*delMsgIDList)
|
||||
if i > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), ID, index)
|
||||
} else {
|
||||
err = db.DB.ReplaceMsgToBlankByIndex(msgs.UID, i-1)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), msgs.UID, i)
|
||||
return minSeq, nil
|
||||
}
|
||||
minSeq = msgPb.Seq
|
||||
}
|
||||
}
|
||||
return minSeq, nil
|
||||
}
|
||||
}
|
||||
if len(msgs.Msg) > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
||||
}
|
||||
*delMsgIDList = append(*delMsgIDList, [2]interface{}{msgs.UID, msgPb.Seq})
|
||||
}
|
||||
// 没有找到 代表需要全部删除掉 继续递归查找下一个比较旧的列表
|
||||
seq, err := deleteMongoMsg(operationID, utils.GetSelfFuncName(), index+1, delMsgIDList)
|
||||
if err != nil {
|
||||
return 0, utils.Wrap(err, "deleteMongoMsg failed")
|
||||
}
|
||||
return seq, nil
|
||||
}
|
||||
|
||||
func getDelMaxSeqByIDList(delMsgIDList [][2]interface{}) uint32 {
|
||||
if len(delMsgIDList) == 0 {
|
||||
return 0
|
||||
}
|
||||
return delMsgIDList[len(delMsgIDList)-1][1].(uint32)
|
||||
}
|
||||
|
||||
func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
var maxSeq uint64
|
||||
var err error
|
||||
if diffusionType == constant.WriteDiffusion {
|
||||
maxSeq, err = db.DB.GetUserMaxSeq(ID)
|
||||
} else {
|
||||
maxSeq, err = db.DB.GetGroupMaxSeq(ID)
|
||||
}
|
||||
if err != nil {
|
||||
if err == goRedis.Nil {
|
||||
return nil
|
||||
}
|
||||
return utils.Wrap(err, "GetUserMaxSeq failed")
|
||||
}
|
||||
msg, err := db.DB.GetNewestMsg(ID)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "GetNewestMsg failed")
|
||||
}
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if math.Abs(float64(msgPb.Seq-uint32(maxSeq))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), maxSeq, msgPb.Seq, "redis maxSeq is different with msg.Seq")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cronTask
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"fmt"
|
||||
"github.com/robfig/cron/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
const cronTaskOperationID = "cronTaskOperationID-"
|
||||
|
||||
func StartCronTask() {
|
||||
log.NewPrivateLog("cron")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
|
||||
c := cron.New()
|
||||
fmt.Println("config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, func() {
|
||||
operationID := getCronTaskOperationID()
|
||||
log.NewInfo(operationID, "====================== start del cron task ======================")
|
||||
userIDList, err := im_mysql_model.SelectAllUserID()
|
||||
if err == nil {
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "userIDList: ", userIDList)
|
||||
for _, userID := range userIDList {
|
||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
|
||||
workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup)
|
||||
if err == nil {
|
||||
for _, groupID := range workingGroupIDList {
|
||||
userIDList, err = rocksCache.GetGroupMemberIDListFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID)
|
||||
continue
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", userIDList)
|
||||
if err := ResetUserGroupMinSeq(operationID, groupID, userIDList); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userIDList)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(operationID, "====================== start del cron finished ======================")
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("start cron failed", err.Error())
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c.Start()
|
||||
fmt.Println("start cron task success")
|
||||
for {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func getCronTaskOperationID() string {
|
||||
return cronTaskOperationID + utils.OperationIDGenerator()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
//
|
||||
//func main() {
|
||||
// db.DB.BatchInsertChat()
|
||||
//}
|
||||
@@ -0,0 +1,89 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type CheckLoginLimitReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
UserID string `json:"userID"`
|
||||
}
|
||||
|
||||
type CheckLoginLimitResp struct {
|
||||
}
|
||||
|
||||
func CheckLoginLimit(c *gin.Context) {
|
||||
req := CheckLoginLimitReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
ip := c.Request.Header.Get("X-Forward-For")
|
||||
if ip == "" {
|
||||
ip = c.ClientIP()
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "IP: ", ip)
|
||||
user, err := imdb.GetUserIPLimit(req.UserID)
|
||||
if err != nil && !errors.Is(gorm.ErrRecordNotFound, err) {
|
||||
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.UserID
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
if err := imdb.UpdateIpReocord(req.UserID, ip); err != nil {
|
||||
log.NewError(req.OperationID, err.Error(), req.UserID, ip)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var Limited bool
|
||||
var LimitError error
|
||||
// 指定账户指定ip才能登录
|
||||
Limited, LimitError = imdb.IsLimitUserLoginIp(user.UserID, ip)
|
||||
if LimitError != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||
return
|
||||
}
|
||||
if Limited {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user ip limited Login"})
|
||||
return
|
||||
}
|
||||
|
||||
// 该ip不能登录
|
||||
Limited, LimitError = imdb.IsLimitLoginIp(ip)
|
||||
if LimitError != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||
return
|
||||
}
|
||||
if Limited {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "ip limited Login"})
|
||||
return
|
||||
}
|
||||
|
||||
Limited, LimitError = imdb.UserIsBlock(user.UserID)
|
||||
if LimitError != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, user.UserID)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||
return
|
||||
}
|
||||
if Limited {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user is block"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type InvitationCode struct {
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
UserID string `json:"userID"`
|
||||
LastTime time.Time `json:"lastTime"`
|
||||
Status int32 `json:"status"`
|
||||
}
|
||||
|
||||
type GenerateInvitationCodeReq struct {
|
||||
CodesNum int `json:"codesNum" binding:"required"`
|
||||
CodeLen int `json:"codeLen" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GenerateInvitationCodeResp struct {
|
||||
Codes []string `json:"codes"`
|
||||
}
|
||||
|
||||
func GenerateInvitationCode(c *gin.Context) {
|
||||
req := GenerateInvitationCodeReq{}
|
||||
resp := GenerateInvitationCodeResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
var err error
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
resp.Codes, err = imdb.BatchCreateInvitationCodes(req.CodesNum, req.CodeLen)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "BatchCreateInvitationCodes failed", req.CodesNum, req.CodeLen)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type QueryInvitationCodeReq struct {
|
||||
Code string `json:"code" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type QueryInvitationCodeResp struct {
|
||||
InvitationCode
|
||||
}
|
||||
|
||||
func QueryInvitationCode(c *gin.Context) {
|
||||
req := QueryInvitationCodeReq{}
|
||||
resp := QueryInvitationCodeResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
invitation, err := imdb.GetInvitationCode(req.Code)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.Code)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
resp.UserID = invitation.UserID
|
||||
resp.CreateTime = invitation.CreateTime
|
||||
resp.Status = invitation.Status
|
||||
resp.LastTime = invitation.LastTime
|
||||
resp.InvitationCode.InvitationCode = invitation.InvitationCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type GetInvitationCodesReq struct {
|
||||
Status int32 `json:"status"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
apiStruct.Pagination
|
||||
}
|
||||
|
||||
type GetInvitationCodesResp struct {
|
||||
apiStruct.Pagination
|
||||
Codes []InvitationCode `json:"codes"`
|
||||
CodeNums int64 `json:"codeNums"`
|
||||
}
|
||||
|
||||
func GetInvitationCodes(c *gin.Context) {
|
||||
req := GetInvitationCodesReq{}
|
||||
resp := GetInvitationCodesResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
codes, count, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
resp.Pagination.PageNumber = req.PageNumber
|
||||
resp.Pagination.ShowNumber = req.ShowNumber
|
||||
for _, v := range codes {
|
||||
resp.Codes = append(resp.Codes, InvitationCode{
|
||||
InvitationCode: v.InvitationCode,
|
||||
CreateTime: v.CreateTime,
|
||||
UserID: v.UserID,
|
||||
LastTime: v.LastTime,
|
||||
Status: v.Status,
|
||||
})
|
||||
}
|
||||
resp.CodeNums = count
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
//api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
//"github.com/jinzhu/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type QueryIPRegisterReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type QueryIPRegisterResp struct {
|
||||
IP string `json:"ip"`
|
||||
RegisterNum int `json:"num"`
|
||||
Status int `json:"status"`
|
||||
UserIDList []string `json:"userIDList"`
|
||||
}
|
||||
|
||||
func QueryIPRegister(c *gin.Context) {
|
||||
req := QueryIPRegisterReq{}
|
||||
resp := QueryIPRegisterResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
userIDList, err := imdb.GetRegisterUserNum(req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.IP)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetRegisterUserNum error!"})
|
||||
return
|
||||
}
|
||||
resp.IP = req.IP
|
||||
resp.RegisterNum = len(userIDList)
|
||||
resp.UserIDList = userIDList
|
||||
ipLimit, err := imdb.QueryIPLimits(req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||
} else {
|
||||
if ipLimit != nil {
|
||||
if ipLimit.Ip != "" {
|
||||
resp.Status = 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type AddIPLimitReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
LimitTime int32 `json:"limitTime"`
|
||||
}
|
||||
|
||||
type AddIPLimitResp struct {
|
||||
}
|
||||
|
||||
func AddIPLimit(c *gin.Context) {
|
||||
req := AddIPLimitReq{}
|
||||
//resp := AddIPLimitResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := imdb.InsertOneIntoIpLimits(db.IpLimit{
|
||||
Ip: req.IP,
|
||||
LimitRegister: 1,
|
||||
LimitLogin: 1,
|
||||
CreateTime: time.Now(),
|
||||
LimitTime: utils.UnixSecondToTime(int64(req.LimitTime)),
|
||||
}); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
type RemoveIPLimitReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type RemoveIPLimitResp struct {
|
||||
}
|
||||
|
||||
func RemoveIPLimit(c *gin.Context) {
|
||||
req := RemoveIPLimitReq{}
|
||||
//resp := AddIPLimitResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrArgs, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := imdb.DeleteOneFromIpLimits(req.IP); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
// ===========================================sk ==========================
|
||||
|
||||
type QueryUserIDIPLimitLoginReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
//type QueryUserIDIPLimitLoginResp struct {
|
||||
// UserIpLimit []db.UserIpLimit `json:"userIpLimit"`
|
||||
//}
|
||||
|
||||
func QueryUserIDLimitLogin(c *gin.Context) {
|
||||
req := QueryUserIDIPLimitLoginReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
resp, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetIpLimitsByUserID error!"})
|
||||
return
|
||||
}
|
||||
if len(resp) > 0 {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": gin.H{"limit": resp}})
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginResp struct {
|
||||
}
|
||||
|
||||
// 添加ip 特定用户才能登录 user_ip_limits 表
|
||||
func AddUserIPLimitLogin(c *gin.Context) {
|
||||
req := AddUserIPLimitLoginReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
||||
err := imdb.UpdateUserInfo(db.User{
|
||||
UserID: req.UserID,
|
||||
// LoginLimit: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "InsertUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
err = imdb.InsertUserIpLimitsLogin(&userIp)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "InsertUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
type RemoveUserIPLimitReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type RemoveUserIPLimitResp struct {
|
||||
}
|
||||
|
||||
// 删除ip 特定用户才能登录 user_ip_limits 表
|
||||
func RemoveUserIPLimitLogin(c *gin.Context) {
|
||||
req := RemoveUserIPLimitReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
err := imdb.DeleteUserIpLimitsLogin(req.UserID, req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "DeleteUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
ips, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "GetIpLimitsLoginByUserID error!"})
|
||||
return
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
err := imdb.UpdateUserInfoByMap(db.User{
|
||||
UserID: req.UserID,
|
||||
}, map[string]interface{}{"login_limit": 0})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "UpdateUserInfo error!"})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
@@ -10,8 +10,9 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ParamsLogin struct {
|
||||
@@ -56,12 +57,22 @@ func Login(c *gin.Context) {
|
||||
} else {
|
||||
userID = r.Account
|
||||
}
|
||||
ip := c.Request.Header.Get("X-Forward-For")
|
||||
if ip == "" {
|
||||
ip = c.ClientIP()
|
||||
}
|
||||
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 = userID
|
||||
openIMGetUserToken.LoginIp = ip
|
||||
loginIp := c.Request.Header.Get("X-Forward-For")
|
||||
if loginIp == "" {
|
||||
loginIp = c.ClientIP()
|
||||
}
|
||||
openIMGetUserToken.LoginIp = loginIp
|
||||
openIMGetUserTokenResp := api.UserTokenResp{}
|
||||
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
||||
if err != nil {
|
||||
@@ -72,7 +83,11 @@ func Login(c *gin.Context) {
|
||||
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": ""})
|
||||
if openIMGetUserTokenResp.ErrCode == constant.LoginLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LoginLimit, "errMsg": "用户登录被限制"})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": ""})
|
||||
}
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMGetUserTokenResp.UserToken})
|
||||
|
||||
@@ -9,16 +9,18 @@ import (
|
||||
"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"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type OnboardingProcessReq struct {
|
||||
@@ -47,26 +49,44 @@ func OnboardingProcessRoutine() {
|
||||
|
||||
func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, email string) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userName, userID, faceURL)
|
||||
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
||||
}
|
||||
departmentID, err := imdb.GetRandomDepartmentID()
|
||||
|
||||
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
|
||||
var joinDepartmentIDList []string
|
||||
if len(config.Config.Demo.JoinDepartmentIDList) == 0 {
|
||||
departmentID, err := imdb.GetRandomDepartmentID()
|
||||
if err != nil {
|
||||
log.NewError(utils.GetSelfFuncName(), "GetRandomDepartmentID failed", err.Error())
|
||||
return
|
||||
}
|
||||
joinDepartmentIDList = []string{departmentID}
|
||||
} else {
|
||||
joinDepartmentIDList = config.Config.Demo.JoinDepartmentIDList
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "random departmentID", departmentID)
|
||||
if err != nil {
|
||||
log.NewError(utils.GetSelfFuncName(), "GetRandomDepartmentID failed", err.Error())
|
||||
return
|
||||
if config.Config.Demo.CreateOrganizationUserAndJoinDepartment && len(joinDepartmentIDList) > 0 {
|
||||
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
||||
}
|
||||
for _, departmentID := range joinDepartmentIDList {
|
||||
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())
|
||||
|
||||
if config.Config.Demo.JoinDepartmentGroups {
|
||||
for _, departmentID := range joinDepartmentIDList {
|
||||
groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
log.Debug(operationID, utils.GetSelfFuncName(), "getjoinGroupIDListdepartmentID", groupIDList)
|
||||
joinGroups(operationID, userID, userName, faceURL, groupIDList)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
|
||||
}
|
||||
}
|
||||
|
||||
if config.Config.Demo.OaNotification {
|
||||
oaNotification(operationID, userID)
|
||||
}
|
||||
joinGroups(operationID, userID, userName, faceURL, groupIDList)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
|
||||
oaNotification(operationID, userID)
|
||||
}
|
||||
|
||||
func createOrganizationUser(operationID, userID, userName, phoneNumber, email string) error {
|
||||
@@ -74,9 +94,9 @@ func createOrganizationUser(operationID, userID, userName, phoneNumber, email st
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
|
||||
}()
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "start createOrganizationUser")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
@@ -113,9 +133,9 @@ 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, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
@@ -145,9 +165,9 @@ func GetDepartmentGroupIDList(operationID, departmentID string) ([]string, error
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), departmentID)
|
||||
}()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return nil, errors.New(errMsg)
|
||||
}
|
||||
@@ -184,9 +204,9 @@ func joinGroups(operationID, userID, userName, faceURL string, groupIDList []str
|
||||
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, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ChImportFriend chan *pbFriend.ImportFriendReq
|
||||
|
||||
func init() {
|
||||
ChImportFriend = make(chan *pbFriend.ImportFriendReq, 1000)
|
||||
}
|
||||
|
||||
func ImportFriendRoutine() {
|
||||
for {
|
||||
req := <-ChImportFriend
|
||||
go func() {
|
||||
friendUserIDList, err := imdb.GetRegisterAddFriendList(0, 0)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req, err.Error())
|
||||
return
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "ImportFriendRoutine IDList", friendUserIDList)
|
||||
if len(friendUserIDList) == 0 {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "len==0")
|
||||
return
|
||||
}
|
||||
req.FriendUserIDList = friendUserIDList
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
rpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
return
|
||||
}
|
||||
if rpcResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", rpcResp)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
)
|
||||
|
||||
var sms SMS
|
||||
@@ -34,11 +34,12 @@ func init() {
|
||||
}
|
||||
|
||||
type paramsVerificationCode struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
@@ -72,6 +73,15 @@ func SendVerificationCode(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
//需要邀请码
|
||||
if config.Config.Demo.NeedInvitationCode {
|
||||
err = im_mysql_model.CheckInvitationCode(params.InvitationCode)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "邀请码错误", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
return
|
||||
}
|
||||
}
|
||||
accountKey = accountKey + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
ok, err := db.DB.JudgeAccountEXISTS(accountKey)
|
||||
if ok || err != nil {
|
||||
|
||||
@@ -5,16 +5,19 @@ 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"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ParamsSetPassword struct {
|
||||
@@ -29,6 +32,9 @@ type ParamsSetPassword struct {
|
||||
FaceURL string `json:"faceURL"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
Gender int32 `json:"gender"`
|
||||
Birth int32 `json:"birth"`
|
||||
}
|
||||
|
||||
func SetPassword(c *gin.Context) {
|
||||
@@ -38,11 +44,34 @@ func SetPassword(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
ip := c.Request.Header.Get("X-Forward-For")
|
||||
if ip == "" {
|
||||
ip = c.ClientIP()
|
||||
}
|
||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
||||
|
||||
ok, opUserID, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), params.OperationID)
|
||||
if !ok || !utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) {
|
||||
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
||||
if LimitError != nil {
|
||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError.Error()})
|
||||
return
|
||||
}
|
||||
if Limited {
|
||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "is limited", ip, "params:", params)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
||||
return
|
||||
}
|
||||
}
|
||||
openIMRegisterReq := api.UserRegisterReq{}
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
openIMRegisterReq.Email = params.Email
|
||||
} else if params.PhoneNumber != "" {
|
||||
account = params.PhoneNumber
|
||||
openIMRegisterReq.PhoneNumber = params.PhoneNumber
|
||||
} else {
|
||||
account = params.UserID
|
||||
}
|
||||
@@ -61,6 +90,13 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||
err := imdb.CheckInvitationCode(params.InvitationCode)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "InvitationCode error"})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
//userID := utils.Base64Encode(account)
|
||||
var userID string
|
||||
@@ -72,15 +108,15 @@ func SetPassword(c *gin.Context) {
|
||||
} else {
|
||||
userID = params.UserID
|
||||
}
|
||||
|
||||
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
||||
openIMRegisterReq := api.UserRegisterReq{}
|
||||
openIMRegisterReq.OperationID = params.OperationID
|
||||
openIMRegisterReq.Platform = params.Platform
|
||||
openIMRegisterReq.UserID = userID
|
||||
openIMRegisterReq.Nickname = params.Nickname
|
||||
openIMRegisterReq.Secret = config.Config.Secret
|
||||
openIMRegisterReq.FaceURL = params.FaceURL
|
||||
openIMRegisterReq.Gender = params.Gender
|
||||
openIMRegisterReq.Birth = uint32(params.Birth)
|
||||
openIMRegisterResp := api.UserRegisterResp{}
|
||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||
@@ -94,20 +130,35 @@ func SetPassword(c *gin.Context) {
|
||||
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 limit"})
|
||||
return
|
||||
}
|
||||
if openIMRegisterResp.ErrCode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password, "info", params.FaceURL, params.Nickname)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode)
|
||||
err = imdb.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode, ip)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||
//判断一下验证码的使用情况
|
||||
LockSucc := imdb.TryLockInvitationCode(params.InvitationCode, userID)
|
||||
if LockSucc {
|
||||
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
||||
}
|
||||
}
|
||||
if err := imdb.InsertIpRecord(userID, ip); err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), userID, ip, err.Error())
|
||||
}
|
||||
|
||||
log.Info(params.OperationID, "end setuserInfo", account, params.Password)
|
||||
// demo onboarding
|
||||
if params.UserID == "" {
|
||||
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
||||
select {
|
||||
case Ch <- OnboardingProcessReq{
|
||||
OperationID: params.OperationID,
|
||||
@@ -121,6 +172,18 @@ func SetPassword(c *gin.Context) {
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ch timeOut")
|
||||
}
|
||||
}
|
||||
|
||||
// register add friend
|
||||
select {
|
||||
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
||||
OperationID: params.OperationID,
|
||||
FromUserID: userID,
|
||||
OpUserID: config.Config.Manager.AppManagerUid[0],
|
||||
}:
|
||||
case <-time.After(time.Second * 2):
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ChImportFriend timeOut")
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
rpcReq.SeqList = seqList
|
||||
rpcReq.UserID = userID
|
||||
rpcReq.OperationID = operationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := "getcdv3.GetConn == nil"
|
||||
errMsg := "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(rpcReq.OperationID, errMsg)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -59,3 +59,28 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
||||
func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackUserKickOff.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
callbackUserKickOffReq := cbApi.CallbackUserKickOffReq{
|
||||
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
|
||||
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||
CallbackCommand: constant.CallbackUserKickOffCommand,
|
||||
OperationID: operationID,
|
||||
PlatformID: int32(platformID),
|
||||
Platform: constant.PlatformIDToName(platformID),
|
||||
},
|
||||
UserID: userID,
|
||||
},
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
}
|
||||
callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
callbackResp.ErrMsg = err.Error()
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user