mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-29 14:59:19 +08:00
Compare commits
843 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d29d49ada | |||
| e7b95892ff | |||
| 4bf5c77374 | |||
| df4a75f4b0 | |||
| 4bdb4cbbb5 | |||
| 4cdcdee8e4 | |||
| e6c36411cb | |||
| b5de638c0b | |||
| 1d09ffa529 | |||
| eef9d15aaa | |||
| 8034ddc413 | |||
| e75adb165a | |||
| 09ce0d5285 | |||
| cc1ad41e94 | |||
| 8a38646bc5 | |||
| 25adfe5b28 | |||
| 6b3d984ca6 | |||
| da5bfe32af | |||
| f93d22ae22 | |||
| 1b457b0be6 | |||
| d77894c8fe | |||
| 366f7621fa | |||
| 984bc37e29 | |||
| 604de144b9 | |||
| 5dddaeb6e5 | |||
| 7790686a84 | |||
| 60950f056b | |||
| ef07634e09 | |||
| f70a20f740 | |||
| c1cda2d536 | |||
| 2b03e7aea8 | |||
| 58cea3e947 | |||
| f02fb7ba15 | |||
| fbafcd0cbc | |||
| bf09c88e6e | |||
| cb8f7e0ddb | |||
| f63aa33082 | |||
| 7bdf6717e1 | |||
| 2fc2801ad4 | |||
| 2bb6061a44 | |||
| a0e3488af0 | |||
| 8fef1f975a | |||
| 17fad47ca1 | |||
| b0aa168c9a | |||
| 367888968b | |||
| 11c65e6b90 | |||
| e9699ed8cc | |||
| 812362338e | |||
| b7ff0cf2a2 | |||
| fa21ae6161 | |||
| fb815c0be0 | |||
| 27c6a187a2 | |||
| 852d3b9f48 | |||
| 10884b8175 | |||
| 5f37414fee | |||
| e95644ada2 | |||
| ab4aee93c1 | |||
| 5df94a03fe | |||
| ab9f3a1635 | |||
| 110c43b97a | |||
| e0a86a8016 | |||
| 9e7f3b83c4 | |||
| 011960b159 | |||
| d23a3cedef | |||
| b782b539a5 | |||
| 2930e49d61 | |||
| 45777e6047 | |||
| 204b27ca5d | |||
| dde8f427af | |||
| 1db0966675 | |||
| b4c16002ff | |||
| ca23c76426 | |||
| 0c50815944 | |||
| 185f3c05fb | |||
| bde88ecc79 | |||
| 38e5b1f853 | |||
| 83fffe717e | |||
| 8757faf965 | |||
| 9b61fb1f85 | |||
| 16a6465453 | |||
| 1d3f05c22b | |||
| 470bdb6efb | |||
| fa53530055 | |||
| 02d0b4c99b | |||
| ca9ac35eb5 | |||
| cb68f83451 | |||
| 972675d4da | |||
| 347b1dd31c | |||
| d34e729e32 | |||
| 4954dcead8 | |||
| a2f3677784 | |||
| fb22b8bba5 | |||
| c0ca3569fd | |||
| bae5042eea | |||
| a5f831e81e | |||
| 6cb6c60eba | |||
| d4098180b6 | |||
| 9bec4b2713 | |||
| 82b899f883 | |||
| 69daec4f86 | |||
| e5d348140c | |||
| 8ba136e0a3 | |||
| 63f48a3c4c | |||
| e9d10bc012 | |||
| 96be2e6262 | |||
| 91fa230016 | |||
| d4b33a1342 | |||
| 8d08bc7fd1 | |||
| 7c08249e08 | |||
| 4f5fff96e0 | |||
| cf6379283b | |||
| 9659638f0c | |||
| 433fef9992 | |||
| d60039454a | |||
| d90b31c5df | |||
| 965dac5ff9 | |||
| 564f77bcdc | |||
| 6136ac4116 | |||
| bba84b4d11 | |||
| b52317f56b | |||
| 98f2806be6 | |||
| 0ce164079e | |||
| 3693d2e93d | |||
| 9ab9ae0408 | |||
| 0abb4a82b1 | |||
| 94a579e7d3 | |||
| 9d132d7f92 | |||
| 0315abc0df | |||
| 24e04f1303 | |||
| 51c2f845d8 | |||
| edc81534c4 | |||
| b10ba999cd | |||
| 12d10ce8b5 | |||
| c4554cb4e9 | |||
| 0e575a9366 | |||
| 13efbf5f98 | |||
| c8be20e9f2 | |||
| 15aabb3859 | |||
| b2a9867297 | |||
| e734b000de | |||
| 127e5af6f3 | |||
| 319f46406c | |||
| ddf79d06d0 | |||
| fafad9217d | |||
| 08022497e6 | |||
| 29f849c184 | |||
| 1572d9df89 | |||
| 4c297164a5 | |||
| a7c8eda290 | |||
| 1bcd2d4531 | |||
| eb1e596cde | |||
| 9bbcf0c5d7 | |||
| 341ec6e9a0 | |||
| 7e9234e712 | |||
| fec33c0b96 | |||
| af2917adb9 | |||
| 2e1459e29c | |||
| 95f6035aa8 | |||
| d6e7cfb044 | |||
| 8dc04667b0 | |||
| c108115c83 | |||
| bcae7720e1 | |||
| 399d0b94d5 | |||
| a5712e1216 | |||
| 3805db1263 | |||
| 88b8a5323a | |||
| 02510528d1 | |||
| 7deffeffd8 | |||
| 4d4520226d | |||
| 9f80e0a0e6 | |||
| 2ed3fd3cba | |||
| 3698f1dab8 | |||
| fb4c02ca9b | |||
| 9cec4b0c8e | |||
| 6cef26f893 | |||
| e2b5b7016c | |||
| 2d55e2edd5 | |||
| 85dbf4f98f | |||
| d13a6b0c36 | |||
| 48f03f306a | |||
| f1c11ac114 | |||
| 97ec9602f7 | |||
| 53cdf884ef | |||
| d8a729c961 | |||
| 25f24801d6 | |||
| e6b302abf9 | |||
| c0c08fe373 | |||
| 60e29cc894 | |||
| dcfd802757 | |||
| 84a01569d6 | |||
| 72ed38156a | |||
| 0e9e02de0b | |||
| 58163cefa0 | |||
| c4ec54f6e4 | |||
| de7dae4455 | |||
| 6362500741 | |||
| 9b3d1f5734 | |||
| 123aad2707 | |||
| 0bed7ee669 | |||
| 7d8d314962 | |||
| f01a6e82dc | |||
| 67d7ee2751 | |||
| 04f8a7247d | |||
| 7b6ef76d54 | |||
| ed65ad842f | |||
| a33fe330f7 | |||
| b30da3eea4 | |||
| 05fbbfcf39 | |||
| 09aec06790 | |||
| 00a52475de | |||
| 6c03211ac4 | |||
| ca18958669 | |||
| e1f58f07fe | |||
| 9d28736849 | |||
| 739096a9c0 | |||
| 2775d9b78a | |||
| 4f01b0b2ad | |||
| 2427671093 | |||
| 8c9d1b7dec | |||
| 55c8399084 | |||
| a1067492b7 | |||
| 961beb3e85 | |||
| 23e86f1067 | |||
| a1333dcace | |||
| 82690b5f2f | |||
| 70b97aa856 | |||
| 05210e2a8b | |||
| 751c278052 | |||
| 9a1620d51f | |||
| 157cd9a035 | |||
| 010736839a | |||
| 2c26efb5a9 | |||
| fe9e2aa287 | |||
| 2585014ace | |||
| 0410003ceb | |||
| e1a0c2fc48 | |||
| b0a8c0a35a | |||
| 0fca91ca37 | |||
| 65ba2d2e27 | |||
| 188ca8fc58 | |||
| 3b80b74730 | |||
| d9f5f960a5 | |||
| e31da8bbd0 | |||
| 1e602975f3 | |||
| 541ccda754 | |||
| 1b68363b80 | |||
| fc11b3c463 | |||
| f9f36cd1d6 | |||
| 566c05bcef | |||
| effb21bc6c | |||
| 4c92ee4a8a | |||
| 8f5b5ab0f9 | |||
| 5dacbfc17e | |||
| 5defc18a64 | |||
| d2ba299f42 | |||
| e78e5d6f32 | |||
| ebbdcbe5a5 | |||
| 1d0ca5f11e | |||
| d22935703d | |||
| d66a567b8f | |||
| 34695f2aa3 | |||
| dcacd88f11 | |||
| 2bbf794501 | |||
| e3937c5ef2 | |||
| a93775bb64 | |||
| eddcac2343 | |||
| 95c125a5af | |||
| 927380741c | |||
| 861dfc43a8 | |||
| a1cbf8724f | |||
| cae88e7946 | |||
| 952ad0e162 | |||
| b751156b5c | |||
| aad27f40cf | |||
| 55d7c6e672 | |||
| 75590eb765 | |||
| dfdb952e2b | |||
| c09ebc146b | |||
| 139ef08af3 | |||
| 2d13a5fd35 | |||
| a3fb32dfc6 | |||
| 079efe5de6 | |||
| 4d28ccebad | |||
| 2171acc909 | |||
| 1e05811c13 | |||
| ec023ec13e | |||
| 996570cc57 | |||
| 7cf712daff | |||
| 9a35af9fb2 | |||
| ede3b07963 | |||
| 53a4b90d96 | |||
| bf948789ea | |||
| db116f39fd | |||
| c962a19eb7 | |||
| 571c83314a | |||
| d906d49930 | |||
| 344bafff45 | |||
| 4858390346 | |||
| f16f0e3069 | |||
| 3ee12221a4 | |||
| 8915848a52 | |||
| a2cd7c8007 | |||
| 6e9b9341d4 | |||
| e90d8a87ee | |||
| 45c43888e7 | |||
| 68e7dfb1cc | |||
| f086f33097 | |||
| 737ce2c2e7 | |||
| 3c7c7cde3c | |||
| 3913d9e48e | |||
| 84d4645efa | |||
| 8a7442648c | |||
| f1616461f7 | |||
| ed2a5af5ed | |||
| 3b73a4c69a | |||
| 17954dfdc9 | |||
| 3aadf61fde | |||
| 5e65e394a6 | |||
| 8c357ec213 | |||
| a599a334a3 | |||
| 36d39669e4 | |||
| 028171a91a | |||
| 2647e1cdac | |||
| 994cebea82 | |||
| a533a3e0ef | |||
| caa915b31d | |||
| 2996d8537d | |||
| 65be1263b9 | |||
| d81ae835aa | |||
| c405cedc41 | |||
| 2a7f366cbf | |||
| ea580e4c64 | |||
| 445100f32d | |||
| 648a852ba7 | |||
| 9f136fb150 | |||
| 6d5b38fc8a | |||
| 2e7fd5fe93 | |||
| 626895166a | |||
| 1ca8d2b2db | |||
| aa57f25b2c | |||
| a321676b99 | |||
| 5b49b105f6 | |||
| d610b19f4e | |||
| b9241288c4 | |||
| a7470dc284 | |||
| 154624a767 | |||
| 6f1a5eb79c | |||
| a8334a22f8 | |||
| 8cdea2bfeb | |||
| c413eda330 | |||
| 22bfb6be4b | |||
| 6bfbf37749 | |||
| 7797e47561 | |||
| 52579c5fab | |||
| a5ed6d897c | |||
| 439605bafc | |||
| 9f6fd3ee6a | |||
| 1539c0b2f2 | |||
| 109e8b53a1 | |||
| 216697d4b5 | |||
| 77bb88ed59 | |||
| 7e52477908 | |||
| 45816fa84f | |||
| 18babef78b | |||
| df8970f59b | |||
| 3103c33dda | |||
| a9fa7ee26a | |||
| e605560e5c | |||
| af330d7f8a | |||
| 563d466374 | |||
| fd59cc6226 | |||
| 6a8a0f2249 | |||
| 8c43b0953b | |||
| a885d7f003 | |||
| 63af591938 | |||
| bf6efc3530 | |||
| 609ec24c6a | |||
| c99cbec3df | |||
| 6eb44cb9d8 | |||
| f67f2a31ee | |||
| 3d5b8287ce | |||
| 548a27fe48 | |||
| 7970a0b3b4 | |||
| 2c67845dd6 | |||
| e02ca2f7e3 | |||
| 84a2197027 | |||
| 41dd808c9a | |||
| 6a7a76dce3 | |||
| b7a8f6c2a1 | |||
| f574017b66 | |||
| b35d5ded77 | |||
| a3f712306e | |||
| e455b3ff00 | |||
| 17dd73834f | |||
| 189020298e | |||
| 375b400b1e | |||
| 192ac0e013 | |||
| b80c8013c0 | |||
| 0606428cd9 | |||
| 8cd7b85711 | |||
| e91f2b89df | |||
| 93706c94af | |||
| 6de61cb214 | |||
| a21e7adeb5 | |||
| 11aecf43ba | |||
| ee3490a520 | |||
| 178c1afdea | |||
| 3a2cd0276a | |||
| a81e5aa6e4 | |||
| 927cde3777 | |||
| bed2bfb6db | |||
| 72f87b449b | |||
| 02b95b16f9 | |||
| 3e16519793 | |||
| a4b6cb3232 | |||
| 8883701297 | |||
| 225c0a9b03 | |||
| 43a9bba96f | |||
| 2c670b3b21 | |||
| 02aad295f9 | |||
| 163da78bc6 | |||
| a549f86624 | |||
| 27262436d1 | |||
| fa2b691dc1 | |||
| 03a010406f | |||
| 1e5245efd0 | |||
| abd8369dd9 | |||
| d0dbffebe1 | |||
| c202cee81f | |||
| 95153a6609 | |||
| e157bc195b | |||
| ac09da9efc | |||
| dc1ad8fb2d | |||
| ba5d178ba0 | |||
| 9ceebacfb1 | |||
| 2a872eb995 | |||
| 9077b56df1 | |||
| 3380cab2c3 | |||
| 1355fa0636 | |||
| 70fb869852 | |||
| 73da15586b | |||
| b3024a6f7c | |||
| 4c42f5a2f5 | |||
| 14cf30cd98 | |||
| e94dbe4965 | |||
| a7f9faf868 | |||
| 6cbdc958cd | |||
| fb396d9cf0 | |||
| fca092d392 | |||
| 0ed393b1a5 | |||
| b992faa468 | |||
| 3f911ab437 | |||
| 84586b675a | |||
| f952f715c8 | |||
| 79d097c903 | |||
| cdc2428aca | |||
| 82c8ace8df | |||
| 8525dcb376 | |||
| 1607853393 | |||
| 27d402104e | |||
| d58bcd136a | |||
| 1944b24fba | |||
| 8e10533681 | |||
| 5a9f3f1f5e | |||
| 64f2fb9e73 | |||
| cbed698a1c | |||
| cd7efee49c | |||
| f7ab90724e | |||
| aa7b891150 | |||
| 911100923f | |||
| 3c64d84980 | |||
| e4f87b53b4 | |||
| ff779fcc7c | |||
| e7c7784fec | |||
| 184f0900fb | |||
| 9ca83b7349 | |||
| 8b3df83e7e | |||
| da24249850 | |||
| 04e509fc49 | |||
| 99a8eaea91 | |||
| 4c3474a9f7 | |||
| 14ccbf335d | |||
| 14841a44ad | |||
| d2b411ecbb | |||
| 544e60eb6d | |||
| db80d8f56f | |||
| ae09d73257 | |||
| ca0f095d6b | |||
| 1a0f626a80 | |||
| c23426425e | |||
| de52439276 | |||
| 757b296fd0 | |||
| 83e842d121 | |||
| 7f00a3075f | |||
| 1c362e4871 | |||
| 0dc5c9dbac | |||
| 28d9304ec6 | |||
| d132e53c06 | |||
| e28a8db3b4 | |||
| b6380a17ce | |||
| f4ceef485b | |||
| f3507569b5 | |||
| da5e60a009 | |||
| 896a69086b | |||
| b375877a6d | |||
| 0ed5f8081a | |||
| 7416fa3a4c | |||
| b90bb10a3f | |||
| 69643c37c1 | |||
| bf208485f8 | |||
| d12d571c2b | |||
| a456936853 | |||
| 655f7ff7d0 | |||
| 5d8e972ac7 | |||
| 31a6797fc3 | |||
| b9b0e9cf43 | |||
| 7f4eb5624b | |||
| 766a05236a | |||
| 92a6c7b89e | |||
| a583a31220 | |||
| 87f14be30c | |||
| 7e13cc84c8 | |||
| a2440a2e80 | |||
| 17b96dd7c1 | |||
| b2c2c1247b | |||
| e4b6b18712 | |||
| 4601633605 | |||
| 839123408b | |||
| 2a3cf5f002 | |||
| 4d172ec4f5 | |||
| 6f411e96ed | |||
| 7f7664eb4f | |||
| 3d994cc2cf | |||
| 6bc69d5a75 | |||
| 0db2c271a0 | |||
| 02b09c58a1 | |||
| b0a8ad1ac1 | |||
| 3e6302e44a | |||
| 1f493c427a | |||
| 89eb39ca3e | |||
| b495761283 | |||
| 29e92015d5 | |||
| c71f2f7fae | |||
| 548c92dc0d | |||
| 59a5f675f6 | |||
| d80a669515 | |||
| bc0c5d4fcb | |||
| 1a69fdf1e0 | |||
| df6643f1c5 | |||
| 03fc008dfc | |||
| fa330c766f | |||
| cb80742eaa | |||
| 0ae46455af | |||
| d6133c325a | |||
| edfb89a8d9 | |||
| aafbee2a28 | |||
| 5c9dc62015 | |||
| 5fef41e132 | |||
| a677d4da5f | |||
| 136e0cde06 | |||
| 06af2b6aa3 | |||
| 29e2a00109 | |||
| d5b5929e9b | |||
| fea89ad451 | |||
| 3d6f1e42d2 | |||
| 1ad80e1870 | |||
| ea0b8df5d4 | |||
| 0e39aac5cd | |||
| 7e88621aa1 | |||
| 9b76407193 | |||
| b6bd2687d2 | |||
| 82c0f8a863 | |||
| 9782802bd8 | |||
| 87659b56a4 | |||
| cd62d7f0d9 | |||
| 1290bc8cc9 | |||
| fe285ecd6b | |||
| da7d187612 | |||
| 9b2fde6ea2 | |||
| da1a563a3c | |||
| 9bee5c79c8 | |||
| aab6ad96eb | |||
| c8d803b559 | |||
| ab5faec68c | |||
| dcba4fef48 | |||
| a654073c71 | |||
| eb417c7e22 | |||
| 0fce4c6177 | |||
| e964ff0b70 | |||
| a5765fc25a | |||
| 18600bcd11 | |||
| 7a3bb59d3e | |||
| 29e1535c64 | |||
| 7b41ce1f24 | |||
| 1e6a170c3c | |||
| 887028a1b4 | |||
| 816ceab057 | |||
| 324152e363 | |||
| 1b11cd571e | |||
| 627419aa5f | |||
| aa99e710d1 | |||
| f3a9857747 | |||
| fdf1c0448b | |||
| a09b39dd69 | |||
| e4989d8b9f | |||
| b135de80c0 | |||
| 79a39b39d9 | |||
| 0c02afa54e | |||
| 1e9ef321f0 | |||
| 7301bc30b1 | |||
| ccecd8f4f0 | |||
| 93e669d7d3 | |||
| a0f28c07f2 | |||
| bd14e5019f | |||
| 6d0f454e6a | |||
| a031311ab5 | |||
| 492915567b | |||
| 8b1a7def38 | |||
| 2f62339f0c | |||
| 288f25c827 | |||
| 1392a8ecf1 | |||
| 1eee8f439b | |||
| 0db7aca1cd | |||
| 89d69a8fb6 | |||
| 7574d06718 | |||
| 4336a1a13e | |||
| 9409d6e05e | |||
| 0971445289 | |||
| 32fe763c0c | |||
| 6790d2be44 | |||
| f579c6b56d | |||
| 81aaa95170 | |||
| e0c91f7fda | |||
| bd0596dd86 | |||
| cc5125d51d | |||
| e90be1bb88 | |||
| b32567681f | |||
| 9f5897e06c | |||
| e8ffcb0630 | |||
| 88aaa38676 | |||
| 6692867db5 | |||
| 42c898d5aa | |||
| 2936f886a9 | |||
| f582967711 | |||
| 68985e9eda | |||
| 7c3e429f22 | |||
| cb79b1aea5 | |||
| b687eb09b4 | |||
| 83874ad466 | |||
| c0172b0a49 | |||
| f59208b9cf | |||
| 6d9ee74360 | |||
| 5ae6e98572 | |||
| 3f639e2ffe | |||
| 43a690c8cf | |||
| 2725a1cd8d | |||
| ac3159193f | |||
| f2c0a3994a | |||
| d7dbe986f1 | |||
| f93090596a | |||
| 8b7e62e819 | |||
| 28ef79f371 | |||
| e39312828c | |||
| 3bbf9d2e0f | |||
| be4ba6cc69 | |||
| 51126ca941 | |||
| faae2d7a1e | |||
| ca92bc899b | |||
| ace5fd61bd | |||
| 31fabb4624 | |||
| b4935fef76 | |||
| d1fba4c125 | |||
| de8ac68466 | |||
| 0392eab129 | |||
| 479ce592fa | |||
| 9eaa180c10 | |||
| 4b38f0bc6b | |||
| 40ed7258d4 | |||
| b0c05fd80d | |||
| 1537330b61 | |||
| abd91260ab | |||
| 5dcb321a6f | |||
| 38cc72a3f9 | |||
| 6f03c470ae | |||
| 4cb02bd3a5 | |||
| 9f55418bfb | |||
| 8faf1140fb | |||
| 6e14375b86 | |||
| 7138d7ac59 | |||
| a02b810412 | |||
| bd5480b264 | |||
| 7c04bcae26 | |||
| efa61dcb39 | |||
| 6c137d9098 | |||
| 3ca92c7a03 | |||
| bb2d5e570a | |||
| 1ce2a86f37 | |||
| c6ee7c5082 | |||
| a52d674a14 | |||
| 69b1ee2ec7 | |||
| 95a771c2fb | |||
| cf59f57ab8 | |||
| 8cd38693dd | |||
| ef67aa9e48 | |||
| 4623b5d5db | |||
| 65456d331b | |||
| 20f51092ad | |||
| 0b0173f155 | |||
| 4e4bab2bf0 | |||
| 679c907b78 | |||
| cd6bb1b98f | |||
| 667ceb2115 | |||
| 03f491ab5a | |||
| fb7c4114c1 | |||
| 669ea69357 | |||
| 5b32e0db6f | |||
| 20aa2bdc6e | |||
| c7b7847a82 | |||
| d99f3e1522 | |||
| 903b53033d | |||
| f2fa08ea82 | |||
| c049cde8cf | |||
| d58dc29550 | |||
| e75e36e999 | |||
| 7903dc7c2e | |||
| a8e13d86e2 | |||
| 8e173d8273 | |||
| 7b67dc03f7 | |||
| c4fca3b23d | |||
| c42e70686d | |||
| df861b59c1 | |||
| 447ccdf042 | |||
| db37d0197a | |||
| e6f21d166a | |||
| 2e0923a26a | |||
| bd1af2223d | |||
| ec395acae0 | |||
| 5ff69b86db | |||
| ce6cd8070f | |||
| ddf985b445 | |||
| 6a37072b9a | |||
| d2ea06ef4a | |||
| 943f58f2c0 | |||
| 0891e2d432 | |||
| 740dd0e0a6 | |||
| 2fcd21ae94 | |||
| c312f079fb | |||
| a480dfe59e | |||
| 453eddc089 | |||
| 51cb558317 | |||
| f0c5b1e544 | |||
| 348ce56776 | |||
| d8ab13e249 | |||
| 376f61e213 | |||
| b30cb5254e | |||
| 3737e889ea | |||
| ec144da8ce | |||
| e61b37b6bf | |||
| 47a3c3c253 | |||
| 23c5f4040e | |||
| 39ceb20332 | |||
| e80c5c89e0 | |||
| 8cfc5925da | |||
| da73347231 | |||
| e26c3d9462 | |||
| f4c3c86dd1 | |||
| 5c509ee85a | |||
| 12ebf232d5 | |||
| 05ee76b0a9 | |||
| 12df670681 | |||
| 6d589a1204 | |||
| 1e50556f64 | |||
| 7ee703f077 | |||
| 141936e609 | |||
| 188a90f97d | |||
| ec95f0a7af | |||
| 848510d4ca | |||
| 16e276d08e | |||
| 62d0a7e6ff | |||
| eeee9a54d7 | |||
| 3ec1d1a965 | |||
| 2b60430c55 | |||
| dbd3ed49ed | |||
| eb640157f2 | |||
| 166ec71a28 | |||
| 8e4f3b4f06 | |||
| f43e1a1018 | |||
| 508ccf4f9c | |||
| 6f92fa0069 | |||
| 2293253d52 | |||
| 1cb7b6a67e | |||
| 817a5e4b64 | |||
| 8286c10406 | |||
| 12c2d18325 | |||
| 28cfc2a9c1 | |||
| 1e3cad4b20 | |||
| b6944c4308 | |||
| 38542f9888 | |||
| 4223b2d0f0 | |||
| c0db257e9b | |||
| 6b1f4e1686 | |||
| 6e8080b87d | |||
| 292a8620e0 | |||
| f0f1c54244 | |||
| 30024c9814 | |||
| 3446442eca | |||
| e439ef4ddd | |||
| 774e348f95 | |||
| 3d4e0a0479 | |||
| 30b9ca7f37 | |||
| 04e064e86e | |||
| 6a88d64a90 | |||
| e64bc40ca9 | |||
| 33ae9dae0a | |||
| ba249d294e | |||
| d40e1e47fd | |||
| 1be993801f | |||
| b76aa03d3a | |||
| 743715fa73 | |||
| 5f09d6a26f | |||
| 27fd4f444b | |||
| 2d56dacd0e | |||
| 333453df79 | |||
| cfddc75ccb | |||
| 3a01ee9973 | |||
| 1efe753a04 | |||
| a8e80a44e6 | |||
| cf94122406 | |||
| a5518eb492 | |||
| 6bdfc570a8 | |||
| 26640b3b07 | |||
| 777805fc1a | |||
| 57e08e282c | |||
| fb5ea3be84 | |||
| 05c15a104f | |||
| 5f18723e2c | |||
| 7db98e55c5 | |||
| 75e1e2e678 | |||
| 2876e77a08 | |||
| 3ba881f641 | |||
| 264451d923 | |||
| b84dbbc3b8 | |||
| 7adde6a0a9 |
@@ -5,6 +5,7 @@ components
|
||||
logs
|
||||
out-test
|
||||
.github
|
||||
.idea
|
||||
|
||||
deploy/open_im_demo
|
||||
deploy/open_im_api
|
||||
|
||||
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: d6372d6fe5...a06dfeeda5
+60
-47
@@ -19,88 +19,101 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
// user routing group, which handles user registration and login services
|
||||
userRouterGroup := r.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo)
|
||||
userRouterGroup.POST("/get_user_info", user.GetUserInfo)
|
||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus)
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
{
|
||||
friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
|
||||
friendRouterGroup.POST("/add_friend", friend.AddFriend)
|
||||
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList)
|
||||
friendRouterGroup.POST("/get_self_apply_list", friend.GetSelfApplyList)
|
||||
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList)
|
||||
friendRouterGroup.POST("/add_blacklist", friend.AddBlacklist)
|
||||
friendRouterGroup.POST("/get_blacklist", friend.GetBlacklist)
|
||||
friendRouterGroup.POST("/remove_blacklist", friend.RemoveBlacklist)
|
||||
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend)
|
||||
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse)
|
||||
friendRouterGroup.POST("/set_friend_comment", friend.SetFriendComment)
|
||||
friendRouterGroup.POST("/is_friend", friend.IsFriend)
|
||||
friendRouterGroup.POST("/import_friend", friend.ImportFriend)
|
||||
// friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
|
||||
friendRouterGroup.POST("/add_friend", friend.AddFriend) //1
|
||||
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1
|
||||
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1
|
||||
friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1
|
||||
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1
|
||||
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1
|
||||
friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1
|
||||
|
||||
friendRouterGroup.POST("/add_black", friend.AddBlack) //1
|
||||
friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1
|
||||
friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1
|
||||
|
||||
friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1
|
||||
friendRouterGroup.POST("/is_friend", friend.IsFriend) //1
|
||||
}
|
||||
//group related routing group
|
||||
groupRouterGroup := r.Group("/group")
|
||||
{
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo)
|
||||
groupRouterGroup.POST("join_group", group.JoinGroup)
|
||||
groupRouterGroup.POST("/quit_group", group.QuitGroup)
|
||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
||||
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo)
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember)
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList)
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMember)
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo)
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup)
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
||||
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup)
|
||||
}
|
||||
//certificate
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister)
|
||||
authRouterGroup.POST("/user_token", apiAuth.UserToken)
|
||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||
}
|
||||
//Third service
|
||||
thirdGroup := r.Group("/third")
|
||||
{
|
||||
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
|
||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
||||
}
|
||||
//Message
|
||||
chatGroup := r.Group("/chat")
|
||||
chatGroup := r.Group("/msg")
|
||||
{
|
||||
chatGroup.POST("/newest_seq", apiChat.UserGetSeq)
|
||||
chatGroup.POST("/pull_msg", apiChat.UserPullMsg)
|
||||
chatGroup.POST("/send_msg", apiChat.UserSendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.UserPullMsgBySeqList)
|
||||
chatGroup.POST("/newest_seq", apiChat.GetSeq)
|
||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||
}
|
||||
//Manager
|
||||
managementGroup := r.Group("/manager")
|
||||
{
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser)
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid)
|
||||
managementGroup.POST("/account_check", manage.AccountCheck)
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
{
|
||||
conversationGroup.POST("/set_receive_message_opt", conversation.SetReceiveMessageOpt)
|
||||
conversationGroup.POST("/get_receive_message_opt", conversation.GetReceiveMessageOpt)
|
||||
conversationGroup.POST("/get_all_conversation_message_opt", conversation.GetAllConversationMessageOpt)
|
||||
{ //1
|
||||
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
||||
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
||||
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||
}
|
||||
|
||||
apiThird.MinioInit()
|
||||
log.NewPrivateLog("api")
|
||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||
flag.Parse()
|
||||
r.Run(":" + strconv.Itoa(*ginPort))
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "start gin failed", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cms_api
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api"
|
||||
"Open_IM/pkg/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := cms_api.NewGinRouter()
|
||||
router.Use(utils.CorsHandler())
|
||||
router.Run(":" + "8000")
|
||||
}
|
||||
@@ -21,6 +21,7 @@ func main() {
|
||||
authRouterGroup.POST("/verify", register.Verify)
|
||||
authRouterGroup.POST("/password", register.SetPassword)
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
}
|
||||
log.NewPrivateLog("demo")
|
||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||
|
||||
@@ -40,7 +40,7 @@ func main() {
|
||||
// }
|
||||
//}
|
||||
for {
|
||||
uidList, err := im_mysql_model.SelectAllUID()
|
||||
uidList, err := im_mysql_model.SelectAllUserID()
|
||||
if err != nil {
|
||||
//log.NewError("999999", err.Error())
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_admin_cms
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"flag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||
flag.Parse()
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ func main() {
|
||||
flag.Parse()
|
||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_message_cms
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||
"flag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10900, "rpc listening port")
|
||||
flag.Parse()
|
||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcChat "Open_IM/internal/rpc/chat"
|
||||
rpcChat "Open_IM/internal/rpc/msg"
|
||||
"flag"
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_statistics
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/statistics"
|
||||
"flag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10800, "rpc listening port")
|
||||
flag.Parse()
|
||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MongoMsg struct {
|
||||
UID string
|
||||
Msg []string
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
//"mongodb://%s:%s@%s/%s/?maxPoolSize=%d"
|
||||
uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
DBAddress := "127.0.0.1:37017"
|
||||
DBDatabase := "new-test-db"
|
||||
Collection := "new-test-collection"
|
||||
DBMaxPoolSize := 100
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
DBAddress,DBDatabase,
|
||||
DBMaxPoolSize)
|
||||
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
filter := bson.M{"uid":"my_uid"}
|
||||
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
for i:=0; i < 2; i++{
|
||||
|
||||
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOneAndUpdate(ctx, filter,
|
||||
bson.M{"$push": bson.M{"msg": utils.Int32ToString(int32(i))}}).Err(); err != nil{
|
||||
fmt.Println("FindOneAndUpdate failed ", i, )
|
||||
var mmsg MongoMsg
|
||||
mmsg.UID = "my_uid"
|
||||
mmsg.Msg = append(mmsg.Msg, utils.Int32ToString(int32(i)))
|
||||
_, err := mongoClient.Database(DBDatabase).Collection(Collection).InsertOne(ctx, &mmsg)
|
||||
if err != nil {
|
||||
fmt.Println("insertone failed ", err.Error(), i)
|
||||
} else{
|
||||
fmt.Println("insertone ok ", i)
|
||||
}
|
||||
|
||||
}else {
|
||||
fmt.Println("FindOneAndUpdate ok ", i)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var mmsg MongoMsg
|
||||
|
||||
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOne(ctx, filter).Decode(&mmsg); err != nil {
|
||||
fmt.Println("findone failed ", err.Error())
|
||||
}else{
|
||||
fmt.Println("findone ok ", mmsg.UID)
|
||||
for i, v:=range mmsg.Msg{
|
||||
fmt.Println("find value: ", i, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+377
-55
@@ -1,47 +1,47 @@
|
||||
# The class cannot be named by Pascal or camel case.
|
||||
# If it is not used, the corresponding structure will not be set,
|
||||
# and it will not be read naturally.
|
||||
serverversion: 1.0.3
|
||||
serverversion: 2.0.0
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openIM
|
||||
etcdAddr: [ 127.0.0.1:2379 ]
|
||||
etcdSchema: openIM #默认即可
|
||||
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||
|
||||
mysql:
|
||||
dbMysqlAddress: [ 127.0.0.1:13306 ]
|
||||
dbMysqlUserName: root
|
||||
dbMysqlPassword: openIM
|
||||
dbMysqlDatabaseName: openIM
|
||||
dbTableName: eMsg
|
||||
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
||||
dbMysqlUserName: root #mysql用户名,建议修改
|
||||
dbMysqlPassword: openIM # mysql密码,建议修改
|
||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||
dbTableName: eMsg #默认即可
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 20
|
||||
dbMaxIdleConns: 10
|
||||
dbMaxLifeTime: 120
|
||||
|
||||
mongo:
|
||||
dbAddress: [ 127.0.0.1:37017 ]
|
||||
dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可
|
||||
dbDirect: false
|
||||
dbTimeout: 10
|
||||
dbDatabase: openIM
|
||||
dbDatabase: openIM #mongo db 默认即可
|
||||
dbSource: admin
|
||||
dbUserName:
|
||||
dbPassword:
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 20
|
||||
dbRetainChatRecords: 7
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
|
||||
redis:
|
||||
dbAddress: 127.0.0.1:16379
|
||||
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
dbPassWord: openIM
|
||||
dbPassWord: openIM #redis密码 建议修改
|
||||
|
||||
kafka:
|
||||
ws2mschat:
|
||||
addr: [ 127.0.0.1:9092 ]
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat"
|
||||
ms2pschat:
|
||||
addr: [ 127.0.0.1:9092 ]
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ms2ps_chat"
|
||||
consumergroupid:
|
||||
msgToMongo: mongo
|
||||
@@ -55,11 +55,13 @@ kafka:
|
||||
# The service ip default is empty,
|
||||
# automatically obtain the machine's valid network card ip as the service ip,
|
||||
# otherwise the configuration ip is preferred
|
||||
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||
serverip: 0.0.0.0
|
||||
|
||||
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
||||
endpoints:
|
||||
api: openim_api
|
||||
cmsapi: openim_cms_api
|
||||
push: openim_push
|
||||
msg_gateway: openim_msg_gateway
|
||||
rpc_auth: openim_rpc_auth
|
||||
@@ -67,29 +69,43 @@ 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
|
||||
|
||||
api:
|
||||
openImApiPort: [ 10000 ]
|
||||
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
cmsapi:
|
||||
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
sdk:
|
||||
openImSdkWsPort: [ 30000 ]
|
||||
|
||||
credential:
|
||||
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||
tencent:
|
||||
appID: 1302656840
|
||||
region: ap-chengdu
|
||||
bucket: echat-1302656840
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||
bucket: openim
|
||||
location: us-east-1
|
||||
endpoint: http://43.128.5.63:9000
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
|
||||
|
||||
rpcport:
|
||||
rpcport: #rpc服务端口 默认即可
|
||||
openImUserPort: [ 10100 ]
|
||||
openImFriendPort: [ 10200 ]
|
||||
openImOfflineMessagePort: [ 10300]
|
||||
openImOfflineMessagePort: [ 10300 ]
|
||||
openImOnlineRelayPort: [ 10400 ]
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
openImStatisticsPort: [ 10800 ]
|
||||
openImMessageCmsPort: [ 10900 ]
|
||||
openImAdminCmsPort: [ 11000 ]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@@ -100,7 +116,7 @@ rpcport:
|
||||
stateChange:
|
||||
switch: false
|
||||
|
||||
rpcregistername:
|
||||
rpcregistername: #rpc注册服务名,默认即可
|
||||
openImUserName: User
|
||||
openImFriendName: Friend
|
||||
openImOfflineMessageName: OfflineMessage
|
||||
@@ -108,85 +124,391 @@ rpcregistername:
|
||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||
openImGroupName: Group
|
||||
openImAuthName: Auth
|
||||
OpenImStatisticsName: Statistics
|
||||
OpenImMessageCMSName: MessageCMS
|
||||
openImAdminCMSName: AdminCMS
|
||||
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
rotationTime: 24
|
||||
remainRotationCount: 5
|
||||
remainRotationCount: 3 #日志数量
|
||||
#日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainLogLevel: 6
|
||||
elasticSearchSwitch: false
|
||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||
elasticSearchUser: ""
|
||||
elasticSearchPassword: ""
|
||||
|
||||
modulename:
|
||||
modulename: #日志文件按模块命名,默认即可
|
||||
longConnSvrName: msg_gateway
|
||||
msgTransferName: msg_transfer
|
||||
pushName: push
|
||||
|
||||
longconnsvr:
|
||||
openImWsPort: [ 17778 ]
|
||||
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||
websocketMaxConnNum: 10000
|
||||
websocketMaxMsgLen: 4096
|
||||
websocketTimeOut: 10
|
||||
|
||||
push:
|
||||
tpns:
|
||||
tpns: #腾讯推送,暂未测试 暂不要使用
|
||||
ios:
|
||||
accessID: 1600018281
|
||||
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
||||
android:
|
||||
accessID: 111
|
||||
secretKey: 111
|
||||
jpns:
|
||||
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
||||
appKey: cf47465a368f24c659608e7e
|
||||
masterSecret: 02204efe3f3832947a236ee5
|
||||
pushUrl: "https://api.jpush.cn/v3/push"
|
||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||
manager:
|
||||
appManagerUid: ["openIM123456","openIM654321"]
|
||||
secrets: ["openIM1","openIM2"]
|
||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
||||
|
||||
secret: tuoyun
|
||||
|
||||
# 多端互踢策略
|
||||
# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线
|
||||
multiloginpolicy: 1
|
||||
|
||||
#token config
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server"
|
||||
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||
# Token effective time day as a unit
|
||||
accessExpire: 7
|
||||
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||
messageverify:
|
||||
friendVerify: false
|
||||
|
||||
messagecallback:
|
||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
||||
#TimeOut use second as unit
|
||||
callbackTimeOut: 10
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
# c2c:
|
||||
# callbackBeforeSendMsg:
|
||||
# switch: false
|
||||
# timeoutStrategy: 1 #1:send
|
||||
# callbackAfterSendMsg:
|
||||
# switch: false
|
||||
# state:
|
||||
# stateChange:
|
||||
# switch: false
|
||||
#ios系统推送声音以及标记计数
|
||||
iospush:
|
||||
pushSound: "xxx"
|
||||
badgeCount: true
|
||||
|
||||
callback:
|
||||
# callback url 需要自行更换callback url
|
||||
callbackUrl : "http://127.0.0.1:8080/callback"
|
||||
# 开启关闭操作前后回调的配置
|
||||
callbackbeforeSendSingleMsg:
|
||||
enable: false # 回调是否启用
|
||||
callbackTimeOut: 2 # 回调超时时间
|
||||
callbackFailedContinue: true # 回调超时是否继续执行代码
|
||||
callbackAfterSendSingleMsg:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackBeforeSendGroupMsg:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true
|
||||
callbackAfterSendGroupMsg:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackWordFilter:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true
|
||||
|
||||
|
||||
notification:
|
||||
groupCreated:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "create group title" # xx create the group
|
||||
desc: "create group desc"
|
||||
ext: "create group ext"
|
||||
defaultTips:
|
||||
tips: "create the group" # xx create the group
|
||||
|
||||
groupInfoSet:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
timeoutStrategy: 1 #1:send
|
||||
callbackAfterSendMsg:
|
||||
title: "groupInfoSet title"
|
||||
desc: "groupInfoSet desc"
|
||||
ext: "groupInfoSet ext"
|
||||
defaultTips:
|
||||
tips: "modified the group profile" # group info changed by xx
|
||||
|
||||
joinGroupApplication:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: false
|
||||
state:
|
||||
stateChange:
|
||||
title: "joinGroupApplication title"
|
||||
desc: "joinGroupApplication desc"
|
||||
ext: "joinGroupApplication ext"
|
||||
defaultTips:
|
||||
tips: "apply to join the group" # group info changed by xx
|
||||
|
||||
memberQuit:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "memberQuit title"
|
||||
desc: "memberQuit desc"
|
||||
ext: "memberQuit ext"
|
||||
defaultTips:
|
||||
tips: "quit group chat" # group info changed by xx
|
||||
|
||||
groupApplicationAccepted:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "groupApplicationAccepted title"
|
||||
desc: "groupApplicationAccepted desc"
|
||||
ext: "groupApplicationAccepted ext"
|
||||
defaultTips:
|
||||
tips: "was allowed to join the group" # group info changed by xx
|
||||
|
||||
groupApplicationRejected:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: " title"
|
||||
desc: " desc"
|
||||
ext: " ext"
|
||||
defaultTips:
|
||||
tips: "was rejected into the group" # group info changed by xx
|
||||
|
||||
groupOwnerTransferred:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "groupOwnerTransferred title"
|
||||
desc: "groupOwnerTransferred desc"
|
||||
ext: "groupOwnerTransferred ext"
|
||||
defaultTips:
|
||||
tips: "become a new group owner" # group info changed by xx
|
||||
|
||||
memberKicked:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "memberKicked title"
|
||||
desc: "memberKicked desc"
|
||||
ext: "memberKicked ext"
|
||||
defaultTips:
|
||||
tips: "was kicked out of the group" # group info changed by xx
|
||||
|
||||
memberInvited:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "memberInvited title"
|
||||
desc: "memberInvited desc"
|
||||
ext: "memberInvited ext"
|
||||
defaultTips:
|
||||
tips: "was invited into the group" # group info changed by xx
|
||||
|
||||
memberEnter:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "memberEnter title"
|
||||
desc: "memberEnter desc"
|
||||
ext: "memberEnter ext"
|
||||
defaultTips:
|
||||
tips: "entered the group" # group info changed by xx
|
||||
|
||||
groupDismissed:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "groupDismissed title"
|
||||
desc: "groupDismissed desc"
|
||||
ext: "groupDismissed ext"
|
||||
defaultTips:
|
||||
tips: "group dismissed"
|
||||
#############################friend#################################
|
||||
|
||||
friendApplicationAdded:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Somebody applies to add you as a friend"
|
||||
desc: "Somebody applies to add you as a friend"
|
||||
ext: "Somebody applies to add you as a friend"
|
||||
defaultTips:
|
||||
tips: "I applies to add you as a friend" #
|
||||
|
||||
friendApplicationApproved:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Someone applies to add your friend application"
|
||||
desc: "Someone applies to add your friend application"
|
||||
ext: "Someone applies to add your friend application"
|
||||
defaultTips:
|
||||
tips: "I applies to add your friend application" #
|
||||
|
||||
|
||||
friendApplicationRejected:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Someone rejected your friend application"
|
||||
desc: "Someone rejected your friend application"
|
||||
ext: "Someone rejected your friend application"
|
||||
defaultTips:
|
||||
tips: "I rejected your friend application" #
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
friendAdded:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "We have become friends"
|
||||
desc: "We have become friends"
|
||||
ext: "We have become friends"
|
||||
defaultTips:
|
||||
tips: "We have become friends" #
|
||||
|
||||
|
||||
|
||||
friendDeleted:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "deleted a friend"
|
||||
desc: "deleted a friend"
|
||||
ext: "deleted a friend"
|
||||
defaultTips:
|
||||
tips: "deleted a friend" #
|
||||
|
||||
|
||||
friendRemarkSet:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Your friend's profile has been changed"
|
||||
desc: "Your friend's profile has been changed"
|
||||
ext: "Your friend's profile has been changed"
|
||||
defaultTips:
|
||||
tips: "Your friend's profile has been changed" #
|
||||
|
||||
|
||||
|
||||
blackAdded:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "blocked a user"
|
||||
desc: "blocked a user"
|
||||
ext: "blocked a user"
|
||||
defaultTips:
|
||||
tips: "blocked a user" #
|
||||
|
||||
|
||||
blackDeleted:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Remove a blocked user"
|
||||
desc: "Remove a blocked user"
|
||||
ext: "Remove a blocked user"
|
||||
defaultTips:
|
||||
tips: "Remove a blocked user"
|
||||
|
||||
#####################user#########################
|
||||
userInfoUpdated:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "Remove a blocked user"
|
||||
desc: "Remove a blocked user"
|
||||
ext: "Remove a blocked user"
|
||||
defaultTips:
|
||||
tips: "remove a blocked user"
|
||||
|
||||
#####################conversation#########################
|
||||
conversationOptUpdate:
|
||||
conversation:
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
title: "conversation opt update"
|
||||
desc: "conversation opt update"
|
||||
ext: "conversation opt update"
|
||||
defaultTips:
|
||||
tips: "conversation opt update"
|
||||
|
||||
|
||||
|
||||
#---------------demo configuration---------------------#
|
||||
#The following configuration items are applied to openIM Demo configuration
|
||||
#是否启动demo,如果自身没有账号体系,设置为true
|
||||
demoswitch: true
|
||||
demo:
|
||||
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
openImDemoPort: [ 42233 ]
|
||||
alismsverify:
|
||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
|
||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
|
||||
signName: OpenIM Corporation
|
||||
verificationCodeTemplateCode: SMS_2268101641
|
||||
superCode: 666666
|
||||
mail:
|
||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
||||
signName: 托云信息技术
|
||||
verificationCodeTemplateCode: SMS_226810164
|
||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||
# second
|
||||
codeTTL: 300
|
||||
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
||||
title: "openIM"
|
||||
senderMail: "1765567899@qq.com"
|
||||
senderAuthorizationCode: "1gxyausfoevlzbfag"
|
||||
senderMail: "765567899@qq.com"
|
||||
senderAuthorizationCode: "gxyausfoevlzbfag"
|
||||
smtpAddr: "smtp.qq.com"
|
||||
smtpPort: 25
|
||||
smtpPort: 25 #需开放此端口 出口方向
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ api:
|
||||
openImApiPort: [ 10000 ]
|
||||
sdk:
|
||||
openImSdkWsPort: [ 30000 ]
|
||||
cmsapi:
|
||||
openImCmsApiPort: [ 8000 ]
|
||||
|
||||
credential:
|
||||
tencent:
|
||||
@@ -91,7 +93,9 @@ rpcport:
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
|
||||
openImStatisticsPort: [ 10800 ]
|
||||
openImMessageCmsPort: [ 10900 ]
|
||||
openImAdminCmsPort: [ 11000 ]
|
||||
|
||||
rpcregistername:
|
||||
openImUserName: User
|
||||
|
||||
+5
-1
@@ -24,6 +24,10 @@ services:
|
||||
- ./components/mongodb/data/db:/data/db
|
||||
- ./components/mongodb/data/logs:/data/logs
|
||||
- ./components/mongodb/data/conf:/etc/mongo
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
@@ -89,7 +93,7 @@ services:
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server
|
||||
image: openim/open_im_server:v2.0.2
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
|
||||
@@ -10,28 +10,38 @@ require (
|
||||
github.com/alibabacloud-go/tea v1.1.17
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/coreos/etcd v3.3.27+incompatible // indirect
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
|
||||
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/frankban/quicktest v1.14.0 // indirect
|
||||
github.com/garyburd/redigo v1.6.2
|
||||
github.com/gin-gonic/gin v1.7.0
|
||||
github.com/go-playground/validator/v10 v10.4.1
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/jinzhu/copier v0.3.4
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/jinzhu/now v1.1.3 // indirect
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||
github.com/lestrrat-go/strftime v1.0.4 // indirect
|
||||
github.com/lib/pq v1.2.0 // indirect
|
||||
//github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect
|
||||
//github.com/livekit/server-sdk-go v0.9.1
|
||||
github.com/mattn/go-sqlite3 v1.14.6 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.22
|
||||
github.com/mitchellh/mapstructure v1.4.2
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/olivere/elastic/v7 v7.0.23
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
@@ -39,10 +49,14 @@ require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||
//go.etcd.io/etcd v3.3.27+incompatible
|
||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
||||
go.mongodb.org/mongo-driver v1.8.3
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
|
||||
google.golang.org/grpc v1.40.0
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
@@ -50,4 +64,4 @@ require (
|
||||
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||
)
|
||||
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.29.0
|
||||
|
||||
@@ -49,7 +49,10 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11 h1:w59gtSA0s87p0U5NNG/N/PIHsRP3rtj7qCP9hx9+GL8=
|
||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU=
|
||||
github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA=
|
||||
@@ -85,22 +88,38 @@ github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zK
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
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/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
|
||||
github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/coreos/etcd v0.5.0-alpha.5 h1:0Qi6Jzjk2CDuuGlIeecpu+em2nrjhOgz2wsIwCmQHmc=
|
||||
github.com/coreos/etcd v3.3.27+incompatible h1:QIudLb9KeBsE5zyYxd1mjzRSkzLg9Wf9QlRwFgd6oTA=
|
||||
github.com/coreos/etcd v3.3.27+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -110,9 +129,13 @@ github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6RO
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
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=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/channels v1.1.0 h1:F1taHcn7/F0i8DYqKXJnyhJcVpp2kgFcNePxXtnyu4k=
|
||||
github.com/eapache/channels v1.1.0/go.mod h1:jMm2qB5Ubtg9zLd+inMZd2/NUvXgzmWXsDaLyQIGfH0=
|
||||
github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q=
|
||||
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=
|
||||
@@ -120,15 +143,21 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
|
||||
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
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/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
|
||||
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
|
||||
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
|
||||
github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM=
|
||||
@@ -142,7 +171,16 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
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-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-logr/logr v1.0.0-rc1/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v1.1.0 h1:nAbevmWlS2Ic4m4+/An5NXkaGqlqpbBgdcuThZxnZyI=
|
||||
github.com/go-logr/logr v1.1.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.0.0 h1:y5pcs7gk8uL+w55/cmuTqhhg5Vjsn8NhlZgr8atE60c=
|
||||
github.com/go-logr/stdr v1.0.0/go.mod h1:ALK2+RP34e8Kg4N/jgsMDWyZb/T282UsFmhyUqyzpmc=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
@@ -151,9 +189,14 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-redis/redis/v8 v8.11.3 h1:GCjoYp8c+yQTJfc0n69iwSiHjvuAdruxl7elnZCxgt8=
|
||||
github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
@@ -197,6 +240,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
|
||||
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
@@ -236,8 +280,14 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
|
||||
@@ -275,15 +325,19 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
|
||||
github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY=
|
||||
github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
|
||||
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jinzhu/copier v0.3.4 h1:mfU6jI9PtCeUjkjQ322dlff9ELjGDu975C2p/nrubVI=
|
||||
github.com/jinzhu/copier v0.3.4/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
|
||||
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
|
||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
|
||||
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
@@ -291,6 +345,7 @@ github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9q
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
@@ -301,10 +356,20 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b h1:XUr8tvMEILhphQPp3TFcIudb5KTOzFeD0pJyDn5+5QI=
|
||||
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b/go.mod h1:a5Mn24iYVJRUQSkFupGByqykzD+k+wFI8J91zGHuPf8=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=
|
||||
github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -326,6 +391,17 @@ github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR7
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||
github.com/livekit/protocol v0.11.13 h1:5iWXKTeFMfERpE/0ocoLUOQtPV1BKwas151nZm0YVt0=
|
||||
github.com/livekit/protocol v0.11.13/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
|
||||
github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 h1:2bSLRW/t4sosQkqoxI9b6PN296FBw4Xiy9cT9tZPi3w=
|
||||
github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231/go.mod h1:3pHsWUtQmWaH8mG0cXrQWpbf3Vo+kj0U+In77CEXu90=
|
||||
github.com/livekit/server-sdk-go v0.9.1 h1:AhshcG4o1Domyo0rfB5lYKnczOZT5nOQQPIkG9jFfE0=
|
||||
github.com/livekit/server-sdk-go v0.9.1/go.mod h1:I31XJ1SmfUW7DFX3sltpVf9GwvuTO0jr05zscP1nrwA=
|
||||
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
@@ -346,9 +422,17 @@ github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRU
|
||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
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/maxbrunsfeld/counterfeiter/v6 v6.3.0/go.mod h1:fcEyUyXZXoV4Abw8DX0t7wyL8mCDxXyU4iAFZfT3IHw=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
|
||||
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||
github.com/minio/minio-go/v7 v7.0.22 h1:iXhsiRyYh1ozm/+jN2qGgEIahYjEkvcpuu6NcdpSxcA=
|
||||
github.com/minio/minio-go/v7 v7.0.22/go.mod h1:ei5JjmxwHaMrgsMrn4U/+Nmg+d8MKS1U2DAn1ou4+Do=
|
||||
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
|
||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
@@ -361,20 +445,79 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8=
|
||||
github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||
github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU=
|
||||
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
|
||||
github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
|
||||
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6E=
|
||||
github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ=
|
||||
github.com/pion/dtls/v2 v2.1.2/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
|
||||
github.com/pion/dtls/v2 v2.1.3 h1:3UF7udADqous+M2R5Uo2q/YaP4EzUoWKdfX2oscCUio=
|
||||
github.com/pion/dtls/v2 v2.1.3/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
|
||||
github.com/pion/ice/v2 v2.2.1 h1:R3MeuJZpU1ty3diPqpD5OxaxcZ15eprAc+EtUiSoFxg=
|
||||
github.com/pion/ice/v2 v2.2.1/go.mod h1:Op8jlPtjeiycsXh93Cs4jK82C9j/kh7vef6ztIOvtIQ=
|
||||
github.com/pion/interceptor v0.1.7/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
||||
github.com/pion/interceptor v0.1.8 h1:5K27KMw8enTB1jVDFrjadK8sZjI5JbPJ91OVfiih5fE=
|
||||
github.com/pion/interceptor v0.1.8/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||
github.com/pion/mdns v0.0.5 h1:Q2oj/JB3NqfzY9xGZ1fPzZzK7sDSD8rZPOvcIQ10BCw=
|
||||
github.com/pion/mdns v0.0.5/go.mod h1:UgssrvdD3mxpi8tMxAXbsppL3vJ4Jipw1mTCW+al01g=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.6/go.mod h1:52rMNPWFsjr39z9B9MhnkqhPLoeHTv1aN63o/42bWE0=
|
||||
github.com/pion/rtcp v1.2.9 h1:1ujStwg++IOLIEoOiIQ2s+qBuJ1VN81KW+9pMPsif+U=
|
||||
github.com/pion/rtcp v1.2.9/go.mod h1:qVPhiCzAm4D/rxb6XzKeyZiQK69yJpbUDJSF7TgrqNo=
|
||||
github.com/pion/rtp v1.7.0/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko=
|
||||
github.com/pion/rtp v1.7.4 h1:4dMbjb1SuynU5OpA3kz1zHK+u+eOCQjW3MAeVHf1ODA=
|
||||
github.com/pion/rtp v1.7.4/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko=
|
||||
github.com/pion/sctp v1.8.0/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s=
|
||||
github.com/pion/sctp v1.8.2 h1:yBBCIrUMJ4yFICL3RIvR4eh/H2BTTvlligmSTy+3kiA=
|
||||
github.com/pion/sctp v1.8.2/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s=
|
||||
github.com/pion/sdp/v3 v3.0.4 h1:2Kf+dgrzJflNCSw3TV5v2VLeI0s/qkzy2r5jlR0wzf8=
|
||||
github.com/pion/sdp/v3 v3.0.4/go.mod h1:bNiSknmJE0HYBprTHXKPQ3+JjacTv5uap92ueJZKsRk=
|
||||
github.com/pion/srtp/v2 v2.0.5 h1:ks3wcTvIUE/GHndO3FAvROQ9opy0uLELpwHJaQ1yqhQ=
|
||||
github.com/pion/srtp/v2 v2.0.5/go.mod h1:8k6AJlal740mrZ6WYxc4Dg6qDqqhxoRG2GSjlUhDF0A=
|
||||
github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg=
|
||||
github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA=
|
||||
github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q=
|
||||
github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A=
|
||||
github.com/pion/transport v0.13.0 h1:KWTA5ZrQogizzYwPEciGtHPLwpAjE91FgXnyu+Hv2uY=
|
||||
github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g=
|
||||
github.com/pion/turn/v2 v2.0.8 h1:KEstL92OUN3k5k8qxsXHpr7WWfrdp7iJZHx99ud8muw=
|
||||
github.com/pion/turn/v2 v2.0.8/go.mod h1:+y7xl719J8bAEVpSXBXvTxStjJv3hbz9YFflvkpcGPw=
|
||||
github.com/pion/udp v0.1.1 h1:8UAPvyqmsxK8oOjloDk4wUt63TzFe9WEJkg5lChlj7o=
|
||||
github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M=
|
||||
github.com/pion/webrtc/v3 v3.1.25-0.20220225075517-37e16a3b15a3 h1:TzOKzLajJt/Le720iy7bFry5HBBLWB3v6n9jEO4WJDs=
|
||||
github.com/pion/webrtc/v3 v3.1.25-0.20220225075517-37e16a3b15a3/go.mod h1:mO/yv7fBN3Lp7YNlnYcTj1jtpvNvssJG+7eh6itZ4xM=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@@ -387,15 +530,26 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
|
||||
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 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
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 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=
|
||||
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 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw=
|
||||
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 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
|
||||
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 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
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=
|
||||
@@ -405,11 +559,16 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE=
|
||||
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
|
||||
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
@@ -446,18 +605,32 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs=
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
||||
github.com/thoas/go-funk v0.9.0 h1:Yzu8aTjTb1sqHZzSZLBt4qaZrFfjNizhA7IfnefjEzo=
|
||||
github.com/thoas/go-funk v0.9.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM=
|
||||
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/twitchtv/twirp v8.1.0+incompatible h1:KGXanpa9LXdVE/V5P/tA27rkKFmXRGCtSNT7zdeeVOY=
|
||||
github.com/twitchtv/twirp v8.1.0+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
|
||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
||||
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc=
|
||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
@@ -468,9 +641,14 @@ go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EXkI7MJAF2HjHAE/x/I=
|
||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM=
|
||||
go.etcd.io/etcd v0.5.0-alpha.5 h1:VOolFSo3XgsmnYDLozjvZ6JL6AAwIDu1Yx1y+4EYLDo=
|
||||
go.etcd.io/etcd v3.3.27+incompatible h1:5hMrpf6REqTHV2LW2OclNpRtxI0k9ZplMemJsMSWju0=
|
||||
go.etcd.io/etcd v3.3.27+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
|
||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
||||
go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4=
|
||||
go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
@@ -478,6 +656,7 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
@@ -502,8 +681,12 @@ golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=
|
||||
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -542,6 +725,7 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -552,6 +736,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -567,21 +752,30 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201026091529-146b70c837a4/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
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-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ=
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -597,6 +791,7 @@ 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/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=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -606,9 +801,11 @@ 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/sys v0.0.0-20180823144017-11551d06cbcc/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=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -622,13 +819,17 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -644,13 +845,17 @@ golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -660,6 +865,7 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -667,7 +873,11 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf h1:2ucpDCmfkl8Bd/FsLtiD653Wf96cW37s+iGx93zsu4k=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -677,6 +887,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -692,6 +904,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
@@ -729,9 +942,11 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
@@ -807,6 +1022,7 @@ google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEY
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
@@ -831,9 +1047,21 @@ google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwy
|
||||
google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs=
|
||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/grpc v1.29.0 h1:2pJjwYOdkZ9HlN4sWRYBg9ttH5bCOlsueaM+b/oYjwo=
|
||||
google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0=
|
||||
google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.34.0 h1:raiipEjMOIC/TO2AvyTxP25XFdLxNIBwzDh3FM3XztI=
|
||||
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
|
||||
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 h1:rLsBNkV6Gc/K6J87wfvo/BSg/TQGd28++7sS+hs8qDw=
|
||||
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737/go.mod h1:wKDg0brwMZpaizQ1i7IzYcJjH1TmbJudYdnQC9+J+LE=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
@@ -856,21 +1084,34 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
|
||||
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
|
||||
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/auth"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func UserRegister(c *gin.Context) {
|
||||
params := api.UserRegisterReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||
utils.CopyStructFields(req.UserInfo, ¶ms)
|
||||
//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)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserRegister(context.Background(), req)
|
||||
if err != nil || reply.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "UserRegister failed ", err, reply.CommonResp.ErrCode)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), pbDataToken)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
||||
UserToken: api.UserTokenInfo{UserID: req.UserInfo.UserID, Token: replyToken.Token, ExpiredTime: replyToken.ExpiredTime}}
|
||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
func UserToken(c *gin.Context) {
|
||||
params := api.UserTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserToken(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsUserRegister struct {
|
||||
Secret string `json:"secret" binding:"required,max=32"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=7"`
|
||||
UID string `json:"uid" binding:"required,min=1,max=64"`
|
||||
Name string `json:"name" binding:"required,min=1,max=64"`
|
||||
Icon string `json:"icon" binding:"omitempty,max=1024"`
|
||||
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
|
||||
Mobile string `json:"mobile" binding:"omitempty,max=32"`
|
||||
Birth string `json:"birth" binding:"omitempty,max=16"`
|
||||
Email string `json:"email" binding:"omitempty,max=64"`
|
||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||
}
|
||||
|
||||
func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq {
|
||||
pbData := pbAuth.UserRegisterReq{
|
||||
UID: params.UID,
|
||||
Name: params.Name,
|
||||
Icon: params.Icon,
|
||||
Gender: params.Gender,
|
||||
Mobile: params.Mobile,
|
||||
Birth: params.Birth,
|
||||
Email: params.Email,
|
||||
Ex: params.Ex,
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func UserRegister(c *gin.Context) {
|
||||
log.Info("", "", "api user_register init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsUserRegister{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if params.Secret != config.Config.Secret {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
pbData := newUserRegisterReq(¶ms)
|
||||
|
||||
log.Info("", "", "api user_register is server, [data: %s]", pbData.String())
|
||||
reply, err := client.UserRegister(context.Background(), pbData)
|
||||
if err != nil || !reply.Success {
|
||||
log.Error("", "", "api user_register call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api user_register call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
pbDataToken := &pbAuth.UserTokenReq{
|
||||
Platform: params.Platform,
|
||||
UID: params.UID,
|
||||
}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
log.Error("", "", "api user_register call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api user_register call success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
if replyToken.ErrCode == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": replyToken.ErrCode,
|
||||
"errMsg": replyToken.ErrMsg,
|
||||
"data": gin.H{
|
||||
"uid": pbData.UID,
|
||||
"token": replyToken.Token,
|
||||
"expiredTime": replyToken.ExpiredTime,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": replyToken.ErrCode,
|
||||
"errMsg": replyToken.ErrMsg,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsUserToken struct {
|
||||
Secret string `json:"secret" binding:"required,max=32"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=8"`
|
||||
UID string `json:"uid" binding:"required,min=1,max=64"`
|
||||
}
|
||||
|
||||
func newUserTokenReq(params *paramsUserToken) *pbAuth.UserTokenReq {
|
||||
pbData := pbAuth.UserTokenReq{
|
||||
Platform: params.Platform,
|
||||
UID: params.UID,
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func UserToken(c *gin.Context) {
|
||||
log.Info("", "", "api user_token init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsUserToken{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.Error("", "", params.UID, params.Platform, params.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if params.Secret != config.Config.Secret {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
pbData := newUserTokenReq(¶ms)
|
||||
|
||||
log.Info("", "", "api user_token is server, [data: %s]", pbData.String())
|
||||
reply, err := client.UserToken(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.Error("", "", "api user_token call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api user_token call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
if reply.ErrCode == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"data": gin.H{
|
||||
"uid": pbData.UID,
|
||||
"token": reply.Token,
|
||||
"expiredTime": reply.ExpiredTime,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func DelMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelMsgReq
|
||||
resp api.DelMsgResp
|
||||
reqPb pbCommon.DelMsgListReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrCode = respPb.ErrCode
|
||||
resp.ErrMsg = respPb.ErrMsg
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ type paramsUserNewestSeq struct {
|
||||
MsgIncr int `json:"msgIncr" binding:"required"`
|
||||
}
|
||||
|
||||
func UserGetSeq(c *gin.Context) {
|
||||
func GetSeq(c *gin.Context) {
|
||||
params := paramsUserNewestSeq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -22,64 +24,14 @@ type paramsUserPullMsg struct {
|
||||
}
|
||||
}
|
||||
|
||||
func UserPullMsg(c *gin.Context) {
|
||||
params := paramsUserPullMsg{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := pbChat.PullMessageReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqBegin = *params.Data.SeqBegin
|
||||
pbData.SeqEnd = *params.Data.SeqEnd
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "UserPullMsg rpc failed, ", params, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserPullMsg rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
|
||||
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
|
||||
|
||||
msg := make(map[string]interface{})
|
||||
if v := reply.GetSingleUserMsg(); v != nil {
|
||||
msg["single"] = v
|
||||
} else {
|
||||
msg["single"] = []pbChat.GatherFormat{}
|
||||
}
|
||||
if v := reply.GetGroupUserMsg(); v != nil {
|
||||
msg["group"] = v
|
||||
} else {
|
||||
msg["group"] = []pbChat.GatherFormat{}
|
||||
}
|
||||
msg["maxSeq"] = reply.GetMaxSeq()
|
||||
msg["minSeq"] = reply.GetMinSeq()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"reqIdentifier": *params.ReqIdentifier,
|
||||
"data": msg,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
type paramsUserPullMsgBySeqList struct {
|
||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SeqList []int64 `json:"seqList"`
|
||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SeqList []uint32 `json:"seqList"`
|
||||
}
|
||||
|
||||
func UserPullMsgBySeqList(c *gin.Context) {
|
||||
func PullMsgBySeqList(c *gin.Context) {
|
||||
params := paramsUserPullMsgBySeqList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
@@ -88,10 +40,13 @@ func UserPullMsgBySeqList(c *gin.Context) {
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error(), token, params.SendID)
|
||||
}
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
}
|
||||
pbData := pbChat.PullMessageBySeqListReq{}
|
||||
pbData := open_im_sdk.PullMessageBySeqListReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
@@ -103,26 +58,11 @@ func UserPullMsgBySeqList(c *gin.Context) {
|
||||
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
|
||||
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
|
||||
|
||||
msg := make(map[string]interface{})
|
||||
if v := reply.GetSingleUserMsg(); v != nil {
|
||||
msg["single"] = v
|
||||
} else {
|
||||
msg["single"] = []pbChat.GatherFormat{}
|
||||
}
|
||||
if v := reply.GetGroupUserMsg(); v != nil {
|
||||
msg["group"] = v
|
||||
} else {
|
||||
msg["group"] = []pbChat.GatherFormat{}
|
||||
}
|
||||
msg["maxSeq"] = reply.GetMaxSeq()
|
||||
msg["minSeq"] = reply.GetMinSeq()
|
||||
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"reqIdentifier": params.ReqIdentifier,
|
||||
"data": msg,
|
||||
"data": reply.List,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@@ -14,50 +14,51 @@ import (
|
||||
)
|
||||
|
||||
type paramsUserSendMsg struct {
|
||||
ReqIdentifier int32 `json:"reqIdentifier" binding:"required"`
|
||||
PlatformID int32 `json:"platformID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName"`
|
||||
SenderFaceURL string `json:"senderFaceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Data struct {
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
MsgFrom int32 `json:"msgFrom" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
RecvID string `json:"recvID" binding:"required"`
|
||||
ForceList []string `json:"forceList"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
Options map[string]int32 `json:"options" `
|
||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
||||
OffLineInfo map[string]interface{} `json:"offlineInfo" `
|
||||
Ex map[string]interface{} `json:"ext"`
|
||||
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName"`
|
||||
SenderFaceURL string `json:"senderFaceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Data struct {
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
MsgFrom int32 `json:"msgFrom" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
ForceList []string `json:"forceList"`
|
||||
Content []byte `json:"content" binding:"required"`
|
||||
Options map[string]bool `json:"options" `
|
||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
||||
CreateTime int64 `json:"createTime" binding:"required"`
|
||||
OffLineInfo *open_im_sdk.OfflinePushInfo `json:"offlineInfo" `
|
||||
}
|
||||
}
|
||||
|
||||
func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.UserSendMsgReq {
|
||||
pbData := pbChat.UserSendMsgReq{
|
||||
ReqIdentifier: params.ReqIdentifier,
|
||||
Token: token,
|
||||
SendID: params.SendID,
|
||||
SenderNickName: params.SenderNickName,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
OperationID: params.OperationID,
|
||||
PlatformID: params.PlatformID,
|
||||
SessionType: params.Data.SessionType,
|
||||
MsgFrom: params.Data.MsgFrom,
|
||||
ContentType: params.Data.ContentType,
|
||||
RecvID: params.Data.RecvID,
|
||||
ForceList: params.Data.ForceList,
|
||||
Content: params.Data.Content,
|
||||
Options: utils.MapIntToJsonString(params.Data.Options),
|
||||
ClientMsgID: params.Data.ClientMsgID,
|
||||
OffLineInfo: utils.MapToJsonString(params.Data.OffLineInfo),
|
||||
Ex: utils.MapToJsonString(params.Data.Ex),
|
||||
func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.SendMsgReq {
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: token,
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.Data.RecvID,
|
||||
GroupID: params.Data.GroupID,
|
||||
ClientMsgID: params.Data.ClientMsgID,
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
SenderNickname: params.SenderNickName,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
SessionType: params.Data.SessionType,
|
||||
MsgFrom: params.Data.MsgFrom,
|
||||
ContentType: params.Data.ContentType,
|
||||
Content: params.Data.Content,
|
||||
CreateTime: params.Data.CreateTime,
|
||||
Options: params.Data.Options,
|
||||
OfflinePushInfo: params.Data.OffLineInfo,
|
||||
},
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func UserSendMsg(c *gin.Context) {
|
||||
func SendMsg(c *gin.Context) {
|
||||
params := paramsUserSendMsg{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
@@ -70,25 +71,24 @@ func UserSendMsg(c *gin.Context) {
|
||||
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())
|
||||
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api UserSendMsg call, api call rpc...")
|
||||
log.Info("", "", "api SendMsg call, api call rpc...")
|
||||
|
||||
reply, err := client.UserSendMsg(context.Background(), pbData)
|
||||
reply, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "UserSendMsg rpc failed, ", params, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserSendMsg rpc failed, " + err.Error()})
|
||||
log.NewError(params.OperationID, "SendMsg rpc failed, ", params, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api UserSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
log.Info("", "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"reqIdentifier": reply.ReqIdentifier,
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"data": gin.H{
|
||||
"clientMsgID": reply.ClientMsgID,
|
||||
"serverMsgID": reply.ServerMsgID,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package conversation
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/user"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -13,182 +13,191 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsSetReceiveMessageOpt struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Option *int32 `json:"option" binding:"required"`
|
||||
ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
}
|
||||
|
||||
type OptResult struct {
|
||||
ConversationId string `json:"conversationId" binding:"required"`
|
||||
Result int32 `json:"result" binding:"required"`
|
||||
}
|
||||
|
||||
type SetReceiveMessageOptResp struct {
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
Data []OptResult `json:"data"`
|
||||
}
|
||||
|
||||
type paramGetReceiveMessageOpt struct {
|
||||
ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetReceiveMessageOptResp struct {
|
||||
SetReceiveMessageOptResp
|
||||
}
|
||||
|
||||
type paramGetAllConversationMessageOpt struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetAllConversationMessageOptResp struct {
|
||||
SetReceiveMessageOptResp
|
||||
}
|
||||
|
||||
//CopyStructFields
|
||||
|
||||
func GetAllConversationMessageOpt(c *gin.Context) {
|
||||
params := paramGetAllConversationMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
func SetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.SetConversationReq
|
||||
resp api.SetConversationResp
|
||||
reqPb pbUser.SetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
reqPb.Conversation = &pbUser.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
req := &user.GetAllConversationMsgOptReq{
|
||||
UId: claims.UID,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt req: ", req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.GetAllConversationMsgOpt(context.Background(), req)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetAllConversationMsgOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
var ginResp GetAllConversationMessageOptResp
|
||||
ginResp.ErrCode = resp.ErrCode
|
||||
ginResp.ErrMsg = resp.ErrMsg
|
||||
for _, v := range resp.ConversationOptResult {
|
||||
var opt OptResult
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt resp: ", ginResp, req)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetReceiveMessageOpt(c *gin.Context) {
|
||||
params := paramGetReceiveMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
func BatchSetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.BatchSetConversationsReq
|
||||
resp api.BatchSetConversationsResp
|
||||
reqPb pbUser.BatchSetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
req := &user.GetReceiveMessageOptReq{
|
||||
UId: claims.UID,
|
||||
ConversationId: params.ConversationIdList,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.GetReceiveMessageOpt(context.Background(), req)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req, resp)
|
||||
var ginResp GetReceiveMessageOptResp
|
||||
ginResp.ErrCode = resp.ErrCode
|
||||
ginResp.ErrMsg = resp.ErrMsg
|
||||
|
||||
for _, v := range resp.ConversationOptResult {
|
||||
var opt OptResult
|
||||
log.NewInfo("CopyStructFields begin ", v, req.OperationID)
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
log.NewInfo("CopyStructFields end ", v, req.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
if err := utils.CopyStructFields(&resp.Data, respPb); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOpt resp: ", ginResp)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetReceiveMessageOpt(c *gin.Context) {
|
||||
params := paramsSetReceiveMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
func GetAllConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetAllConversationsReq
|
||||
resp api.GetAllConversationsResp
|
||||
reqPb pbUser.GetAllConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
req := &user.SetReceiveMessageOptReq{
|
||||
UId: claims.UID,
|
||||
Opt: *params.Option,
|
||||
ConversationId: params.ConversationIdList,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.SetReceiveMessageOpt(context.Background(), req)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "SetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req, resp)
|
||||
ginResp := SetReceiveMessageOptResp{
|
||||
ErrCode: resp.ErrCode,
|
||||
ErrMsg: resp.ErrMsg,
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed, ", err.Error())
|
||||
}
|
||||
|
||||
for _, v := range resp.OptResult {
|
||||
var opt OptResult
|
||||
log.NewDebug("CopyStructFields begin ", v, req.OperationID)
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
log.NewDebug("CopyStructFields end ", v, req.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt resp: ", ginResp)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationReq
|
||||
resp api.GetConversationResp
|
||||
reqPb pbUser.GetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversation, respPb.Conversation); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationsReq
|
||||
resp api.GetConversationsResp
|
||||
reqPb pbUser.GetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetRecvMsgOpt(c *gin.Context) {
|
||||
var (
|
||||
req api.SetRecvMsgOptReq
|
||||
resp api.SetRecvMsgOptResp
|
||||
reqPb pbUser.SetRecvMsgOptReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
type paramsAddBlackList struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
}*/
|
||||
|
||||
func AddBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api add blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSearchFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.AddBlacklistReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
OwnerUid: params.OwnerUid,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api add blacklist is server:userID=%s", req.Uid)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call add blacklist rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call add blacklist rpc server success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("api add blacklist success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsImportFriendReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UIDList []string `json:"uidList" binding:"required"`
|
||||
OwnerUid string `json:"ownerUid" binding:"required"`
|
||||
}
|
||||
|
||||
type paramsAddFriend struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
ReqMessage string `json:"reqMessage"`
|
||||
}
|
||||
|
||||
//
|
||||
func ImportFriend(c *gin.Context) {
|
||||
log.Info("", "", "ImportFriend init ....")
|
||||
log.NewDebug("", "api importFriend start")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
|
||||
params := paramsImportFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.ImportFriendReq{
|
||||
UidList: params.UIDList,
|
||||
OperationID: params.OperationID,
|
||||
OwnerUid: params.OwnerUid,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.NewDebug(req.OperationID, "args is ", req.String())
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "rpc importFriend failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
failedUidList := make([]string, 0)
|
||||
for _, v := range RpcResp.FailedUidList {
|
||||
failedUidList = append(failedUidList, v)
|
||||
}
|
||||
log.NewDebug(req.OperationID, "rpc importFriend success", RpcResp.CommonResp.ErrorMsg, RpcResp.CommonResp.ErrorCode, RpcResp.FailedUidList)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": failedUidList})
|
||||
}
|
||||
|
||||
func AddFriend(c *gin.Context) {
|
||||
log.Info("", "", "api add friend init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
|
||||
params := paramsAddFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.AddFriendReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
ReqMessage: params.ReqMessage,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api add friend is server")
|
||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call add friend rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call add friend rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
})
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsAddFriendResponse struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
Flag int32 `json:"flag" binding:"required"`
|
||||
}
|
||||
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api add friend response init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsAddFriendResponse{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.AddFriendResponseReq{
|
||||
Uid: params.UID,
|
||||
Flag: params.Flag,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api add friend response is server:userID=%s", req.Uid)
|
||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call add_friend_response rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add_friend_response rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call add friend response rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
log.InfoByArgs("api add friend response success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsDeleteFriend struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
}
|
||||
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api delete_friend init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsDeleteFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.DeleteFriendReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api delete_friend is server:%s", req.Uid)
|
||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call delete_friend rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete_friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call delete_friend rpc server,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("api delete_friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
jsonData "Open_IM/internal/utils"
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/friend"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AddBlack(c *gin.Context) {
|
||||
params := api.AddBlacklistReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddBlacklist failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.AddBlacklistResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func ImportFriend(c *gin.Context) {
|
||||
params := api.ImportFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.ImportFriendReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "ImportFriend failed "})
|
||||
return
|
||||
}
|
||||
resp := api.ImportFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
if resp.ErrCode == 0 {
|
||||
for _, v := range RpcResp.UserIDResultList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
}
|
||||
if len(resp.UserIDResultList) == 0 {
|
||||
resp.UserIDResultList = []api.UserIDResult{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ImportFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func AddFriend(c *gin.Context) {
|
||||
params := api.AddFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.ReqMsg = params.ReqMsg
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AddFriend rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.AddFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
params := api.AddFriendResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddFriendResponseReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.HandleMsg = params.HandleMsg
|
||||
req.HandleResult = params.Flag
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(req, ¶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)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddFriendResponse failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add_friend_response rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.AddFriendResponseResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
params := api.DeleteFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "DeleteFriend failed ", err, req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete_friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.DeleteFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
params := api.GetBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetBlacklist failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
for _, v := range RpcResp.BlackUserInfoList {
|
||||
black := open_im_sdk.PublicUserInfo{}
|
||||
utils.CopyStructFields(&black, v)
|
||||
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
||||
}
|
||||
resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetFriendRemark(c *gin.Context) {
|
||||
params := api.SetFriendRemarkReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.Remark = params.Remark
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "SetFriendComment failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call set friend comment rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.SetFriendRemarkResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func RemoveBlack(c *gin.Context) {
|
||||
params := api.RemoveBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "RemoveBlacklist failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call remove blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.RemoveBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func IsFriend(c *gin.Context) {
|
||||
params := api.IsFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "IsFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.IsFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
resp.Response.Friend = RpcResp.Response
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//
|
||||
//func GetFriendsInfo(c *gin.Context) {
|
||||
// params := api.GetFriendsInfoReq{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// req := &rpc.GetFriendsInfoReq{}
|
||||
// utils.CopyStructFields(req.CommID, params)
|
||||
// var ok bool
|
||||
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
// if !ok {
|
||||
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||
//
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
// client := rpc.NewFriendClient(etcdConn)
|
||||
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
// utils.CopyStructFields(&resp, RpcResp)
|
||||
// c.JSON(http.StatusOK, resp)
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
|
||||
//}
|
||||
|
||||
func GetFriendList(c *gin.Context) {
|
||||
params := api.GetFriendListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetFriendList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend list rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
//c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
params := api.GetFriendApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetFriendApplyList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetSelfFriendApplyList(c *gin.Context) {
|
||||
params := api.GetSelfApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetSelfApplyList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get self apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGetBlackList struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type blackListUserInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api get blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetBlackList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.GetBlacklistReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, fmt.Sprintf("api get blacklist is server"))
|
||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get_friend_list rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get blacklist rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
userBlackList := make([]blackListUserInfo, 0)
|
||||
for _, friend := range RpcResp.Data {
|
||||
var fi blackListUserInfo
|
||||
fi.UID = friend.Uid
|
||||
fi.Name = friend.Name
|
||||
fi.Icon = friend.Icon
|
||||
fi.Gender = friend.Gender
|
||||
fi.Mobile = friend.Mobile
|
||||
fi.Birth = friend.Birth
|
||||
fi.Email = friend.Email
|
||||
fi.Ex = friend.Ex
|
||||
userBlackList = append(userBlackList, fi)
|
||||
}
|
||||
resp := gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
"data": userBlackList,
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByArgs("api get black list success return,get args=%s,return=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGetApplyList struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
type UserInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
Ex string `json:"ex"`
|
||||
ReqMessage string `json:"reqMessage"`
|
||||
ApplyTime string `json:"applyTime"`
|
||||
Flag int32 `json:"flag"`
|
||||
}
|
||||
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
log.Info("", "", "api get_friend_apply_list init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetApplyList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.GetFriendApplyReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api get friend apply list is server")
|
||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get friend apply list rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get friend apply list rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
userInfoList := make([]UserInfo, 0)
|
||||
for _, applyUserinfo := range RpcResp.Data {
|
||||
var un UserInfo
|
||||
un.UID = applyUserinfo.Uid
|
||||
un.Name = applyUserinfo.Name
|
||||
un.Icon = applyUserinfo.Icon
|
||||
un.Gender = applyUserinfo.Gender
|
||||
un.Mobile = applyUserinfo.Mobile
|
||||
un.Birth = applyUserinfo.Birth
|
||||
un.Email = applyUserinfo.Email
|
||||
un.Ex = applyUserinfo.Ex
|
||||
un.Flag = applyUserinfo.Flag
|
||||
un.ApplyTime = applyUserinfo.ApplyTime
|
||||
un.ReqMessage = applyUserinfo.ReqMessage
|
||||
userInfoList = append(userInfoList, un)
|
||||
}
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByArgs("api get friend apply list success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
|
||||
func GetSelfApplyList(c *gin.Context) {
|
||||
log.Info("", "", "api get self friend apply list init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetApplyList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.GetFriendApplyReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api get self apply list is server")
|
||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get self apply list rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get self apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get self apply list rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
userInfoList := make([]UserInfo, 0)
|
||||
for _, selfApplyOtherUserinfo := range RpcResp.Data {
|
||||
var un UserInfo
|
||||
un.UID = selfApplyOtherUserinfo.Uid
|
||||
un.Name = selfApplyOtherUserinfo.Name
|
||||
un.Icon = selfApplyOtherUserinfo.Icon
|
||||
un.Gender = selfApplyOtherUserinfo.Gender
|
||||
un.Mobile = selfApplyOtherUserinfo.Mobile
|
||||
un.Birth = selfApplyOtherUserinfo.Birth
|
||||
un.Email = selfApplyOtherUserinfo.Email
|
||||
un.Ex = selfApplyOtherUserinfo.Ex
|
||||
un.Flag = selfApplyOtherUserinfo.Flag
|
||||
un.ApplyTime = selfApplyOtherUserinfo.ApplyTime
|
||||
un.ReqMessage = selfApplyOtherUserinfo.ReqMessage
|
||||
userInfoList = append(userInfoList, un)
|
||||
}
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByArgs("api get self apply list success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGetFriendLIst struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type friendInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
Ex string `json:"ex"`
|
||||
Comment string `json:"comment"`
|
||||
IsInBlackList int32 `json:"isInBlackList"`
|
||||
}
|
||||
|
||||
func GetFriendList(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api get_friendlist init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetFriendLIst{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.GetFriendListReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api get friend list is server")
|
||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get friend list rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend list rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get friend list rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
friendsInfo := make([]friendInfo, 0)
|
||||
for _, friend := range RpcResp.Data {
|
||||
var fi friendInfo
|
||||
fi.UID = friend.Uid
|
||||
fi.Name = friend.Name
|
||||
fi.Icon = friend.Icon
|
||||
fi.Gender = friend.Gender
|
||||
fi.Mobile = friend.Mobile
|
||||
fi.Birth = friend.Birth
|
||||
fi.Email = friend.Email
|
||||
fi.Ex = friend.Ex
|
||||
fi.Comment = friend.Comment
|
||||
fi.IsInBlackList = friend.IsInBlackList
|
||||
friendsInfo = append(friendsInfo, fi)
|
||||
}
|
||||
resp := gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
"data": friendsInfo,
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByArgs("api get friend list success return,get args=%s,return=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsSearchFriend struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
OwnerUid string `json:"ownerUid"`
|
||||
}
|
||||
|
||||
func GetFriendsInfo(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api search friend init ...."))
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSearchFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.GetFriendsInfoReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api search_friend is server")
|
||||
RpcResp, err := client.GetFriendsInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call search friend rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call search friend rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
resp := gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
"data": gin.H{
|
||||
"uid": RpcResp.Data.Uid,
|
||||
"icon": RpcResp.Data.Icon,
|
||||
"name": RpcResp.Data.Name,
|
||||
"gender": RpcResp.Data.Gender,
|
||||
"mobile": RpcResp.Data.Mobile,
|
||||
"birth": RpcResp.Data.Birth,
|
||||
"email": RpcResp.Data.Email,
|
||||
"ex": RpcResp.Data.Ex,
|
||||
"comment": RpcResp.Data.Comment,
|
||||
},
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByArgs("api search_friend success return,get args=%s,return=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsIsFriend struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
ReceiveUid string `json:"receive_uid"`
|
||||
}
|
||||
|
||||
func IsFriend(c *gin.Context) {
|
||||
log.Info("", "", "api is friend init....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsIsFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.IsFriendReq{
|
||||
OperationID: params.OperationID,
|
||||
ReceiveUid: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api is friend is server")
|
||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call add friend rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call is friend rpc server success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "isFriend": RpcResp.ShipType}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("api is friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsRemoveBlackList struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
}
|
||||
|
||||
func RemoveBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api remove_blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsRemoveBlackList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.RemoveBlacklistReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api remove blacklist is server:userID=%s", req.Uid)
|
||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call remove blacklist rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call remove blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call remove blacklist rpc server success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("api remove blacklist success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsSetFriendComment struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
|
||||
func SetFriendComment(c *gin.Context) {
|
||||
log.Info("", "", "api set friend comment init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSetFriendComment{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbFriend.SetFriendCommentReq{
|
||||
Uid: params.UID,
|
||||
OperationID: params.OperationID,
|
||||
Comment: params.Comment,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api set friend comment is server")
|
||||
RpcResp, err := client.SetFriendComment(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call set friend comment rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call set friend comment rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "call set friend comment rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
log.Info("", "", "api set friend comment success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsCreateGroupStruct struct {
|
||||
MemberList []*pb.GroupAddMemberInfo `json:"memberList"`
|
||||
GroupName string `json:"groupName"`
|
||||
Introduction string `json:"introduction"`
|
||||
Notification string `json:"notification"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
func CreateGroup(c *gin.Context) {
|
||||
log.Info("", "", "api create group init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsCreateGroupStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.CreateGroupReq{
|
||||
MemberList: params.MemberList,
|
||||
GroupName: params.GroupName,
|
||||
Introduction: params.Introduction,
|
||||
Notification: params.Notification,
|
||||
FaceUrl: params.FaceUrl,
|
||||
OperationID: params.OperationID,
|
||||
Ex: params.Ex,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api create group is server,params=%s", req.String())
|
||||
RpcResp, err := client.CreateGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call create group rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call create group rpc server success,args=%s", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": gin.H{"groupID": RpcResp.GroupID}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
}
|
||||
log.InfoByArgs("api create group success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGroupApplicationList struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func newUserRegisterReq(params *paramsGroupApplicationList) *group.GetGroupApplicationListReq {
|
||||
pbData := group.GetGroupApplicationListReq{
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
type paramsGroupApplicationListRet struct {
|
||||
ID string `json:"id"`
|
||||
GroupID string `json:"groupID"`
|
||||
FromUserID string `json:"fromUserID"`
|
||||
ToUserID string `json:"toUserID"`
|
||||
Flag int32 `json:"flag"`
|
||||
RequestMsg string `json:"reqMsg"`
|
||||
HandledMsg string `json:"handledMsg"`
|
||||
AddTime int64 `json:"createTime"`
|
||||
FromUserNickname string `json:"fromUserNickName"`
|
||||
ToUserNickname string `json:"toUserNickName"`
|
||||
FromUserFaceUrl string `json:"fromUserFaceURL"`
|
||||
ToUserFaceUrl string `json:"toUserFaceURL"`
|
||||
HandledUser string `json:"handledUser"`
|
||||
Type int32 `json:"type"`
|
||||
HandleStatus int32 `json:"handleStatus"`
|
||||
HandleResult int32 `json:"handleResult"`
|
||||
}
|
||||
|
||||
func GetGroupApplicationList(c *gin.Context) {
|
||||
log.Info("", "", "api GetGroupApplicationList init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGroupApplicationList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := newUserRegisterReq(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
pbData.UID = claims.UID
|
||||
}
|
||||
|
||||
log.Info("", "", "api GetGroupApplicationList is server, [data: %s]", pbData.String())
|
||||
reply, err := client.GetGroupApplicationList(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.Error("", "", "api GetGroupApplicationList call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api GetGroupApplicationList call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
unProcessCount := 0
|
||||
userReq := make([]paramsGroupApplicationListRet, 0)
|
||||
if reply != nil && reply.Data != nil && reply.Data.User != nil {
|
||||
for i := 0; i < len(reply.Data.User); i++ {
|
||||
req := paramsGroupApplicationListRet{}
|
||||
req.ID = reply.Data.User[i].ID
|
||||
req.GroupID = reply.Data.User[i].GroupID
|
||||
req.FromUserID = reply.Data.User[i].FromUserID
|
||||
req.ToUserID = reply.Data.User[i].ToUserID
|
||||
req.Flag = reply.Data.User[i].Flag
|
||||
req.RequestMsg = reply.Data.User[i].RequestMsg
|
||||
req.HandledMsg = reply.Data.User[i].HandledMsg
|
||||
req.AddTime = reply.Data.User[i].AddTime
|
||||
req.FromUserNickname = reply.Data.User[i].FromUserNickname
|
||||
req.ToUserNickname = reply.Data.User[i].ToUserNickname
|
||||
req.FromUserFaceUrl = reply.Data.User[i].FromUserFaceUrl
|
||||
req.ToUserFaceUrl = reply.Data.User[i].ToUserFaceUrl
|
||||
req.HandledUser = reply.Data.User[i].HandledUser
|
||||
req.Type = reply.Data.User[i].Type
|
||||
req.HandleStatus = reply.Data.User[i].HandleStatus
|
||||
req.HandleResult = reply.Data.User[i].HandleResult
|
||||
userReq = append(userReq, req)
|
||||
|
||||
if req.Flag == 0 {
|
||||
unProcessCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"data": gin.H{
|
||||
"count": unProcessCount,
|
||||
"user": userReq,
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGetGroupInfo struct {
|
||||
GroupIDList []string `json:"groupIDList" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func GetGroupsInfo(c *gin.Context) {
|
||||
log.Info("", "", "api get groups info init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetGroupInfo{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.GetGroupsInfoReq{
|
||||
GroupIDList: params.GroupIDList,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "get groups info is server,params=%s", req.String())
|
||||
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "call get groups info rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get groups info rpc server success", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
groupsInfo := make([]pb.GroupInfo, 0)
|
||||
for _, v := range RpcResp.Data {
|
||||
var groupInfo pb.GroupInfo
|
||||
groupInfo.GroupId = v.GroupId
|
||||
groupInfo.GroupName = v.GroupName
|
||||
groupInfo.Notification = v.Notification
|
||||
groupInfo.Introduction = v.Introduction
|
||||
groupInfo.FaceUrl = v.FaceUrl
|
||||
groupInfo.CreateTime = v.CreateTime
|
||||
groupInfo.OwnerId = v.OwnerId
|
||||
groupInfo.MemberCount = v.MemberCount
|
||||
|
||||
groupsInfo = append(groupsInfo, groupInfo)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
"data": groupsInfo,
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
}
|
||||
}
|
||||
+459
-240
@@ -1,351 +1,570 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
rpc "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
jsonData "Open_IM/internal/utils"
|
||||
)
|
||||
|
||||
type InviteUserToGroupReq struct {
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
UidList []string `json:"uidList" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetJoinedGroupListReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type KickGroupMemberReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
UidListInfo []*pb.GroupMemberFullInfo `json:"uidListInfo" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func KickGroupMember(c *gin.Context) {
|
||||
log.Info("", "", "KickGroupMember start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := KickGroupMemberReq{}
|
||||
params := api.KickGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &pb.KickGroupMemberReq{
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
|
||||
UidListInfo: params.UidListInfo,
|
||||
req := &rpc.KickGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
|
||||
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.KickGroupMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "GetGroupMemberList failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
type KickGroupMemberResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
Data []Id2Result `json:"data"`
|
||||
var memberListResp api.KickGroupMemberResp
|
||||
memberListResp.ErrMsg = RpcResp.ErrMsg
|
||||
memberListResp.ErrCode = RpcResp.ErrCode
|
||||
for _, v := range RpcResp.Id2ResultList {
|
||||
memberListResp.UserIDResultList = append(memberListResp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
if len(memberListResp.UserIDResultList) == 0 {
|
||||
memberListResp.UserIDResultList = []*api.UserIDResult{}
|
||||
}
|
||||
|
||||
var memberListResp KickGroupMemberResp
|
||||
memberListResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
memberListResp.ErrorCode = RpcResp.ErrorCode
|
||||
for _, v := range RpcResp.Id2Result {
|
||||
memberListResp.Data = append(memberListResp.Data,
|
||||
Id2Result{UId: v.UId,
|
||||
Result: v.Result})
|
||||
}
|
||||
log.NewInfo(req.OperationID, "KickGroupMember api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
type GetGroupMembersInfoReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
MemberList []string `json:"memberList"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
type GetGroupMembersInfoResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
Data []MemberResult `json:"data"`
|
||||
}
|
||||
|
||||
func GetGroupMembersInfo(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupMembersInfo start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := GetGroupMembersInfoReq{}
|
||||
params := api.GetGroupMembersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &pb.GetGroupMembersInfoReq{
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
MemberList: params.MemberList,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.GetGroupMembersInfoReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
//c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
api.SetErrCodeMsg(c, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", len(params.MemberList))
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "GetGroupMemberList failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var memberListResp GetGroupMembersInfoResp
|
||||
memberListResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
memberListResp.ErrorCode = RpcResp.ErrorCode
|
||||
for _, v := range RpcResp.MemberList {
|
||||
memberListResp.Data = append(memberListResp.Data,
|
||||
MemberResult{GroupId: req.GroupID,
|
||||
UserId: v.UserId,
|
||||
Role: v.Role,
|
||||
JoinTime: uint64(v.JoinTime),
|
||||
Nickname: v.NickName,
|
||||
FaceUrl: v.FaceUrl})
|
||||
}
|
||||
memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(RpcResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
type GetGroupMemberListReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
Filter int32 `json:"filter"`
|
||||
NextSeq int32 `json:"nextSeq"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
type getGroupAllMemberReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
type MemberResult struct {
|
||||
GroupId string `json:"groupID"`
|
||||
UserId string `json:"userId"`
|
||||
Role int32 `json:"role"`
|
||||
JoinTime uint64 `json:"joinTime"`
|
||||
Nickname string `json:"nickName"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
}
|
||||
|
||||
func GetGroupMemberList(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupMemberList start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := GetGroupMemberListReq{}
|
||||
params := api.GetGroupMemberListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.GetGroupMemberListReq{
|
||||
OperationID: params.OperationID,
|
||||
Filter: params.Filter,
|
||||
NextSeq: params.NextSeq,
|
||||
GroupID: params.GroupID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.GetGroupMemberListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetGroupMemberList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "GetGroupMemberList failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed, ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
type GetGroupMemberListResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
NextSeq int32 `json:"nextSeq"`
|
||||
Data []MemberResult `json:"data"`
|
||||
}
|
||||
memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
|
||||
var memberListResp GetGroupMemberListResp
|
||||
memberListResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
memberListResp.ErrorCode = RpcResp.ErrorCode
|
||||
memberListResp.NextSeq = RpcResp.NextSeq
|
||||
for _, v := range RpcResp.MemberList {
|
||||
memberListResp.Data = append(memberListResp.Data,
|
||||
MemberResult{GroupId: req.GroupID,
|
||||
UserId: v.UserId,
|
||||
Role: v.Role,
|
||||
JoinTime: uint64(v.JoinTime),
|
||||
Nickname: v.NickName,
|
||||
FaceUrl: v.FaceUrl})
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
|
||||
}
|
||||
|
||||
func GetGroupAllMember(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupAllMember start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := getGroupAllMemberReq{}
|
||||
func GetGroupAllMemberList(c *gin.Context) {
|
||||
params := api.GetGroupAllMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.GetGroupAllMemberReq{
|
||||
GroupID: params.GroupID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.GetGroupAllMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "GetGroupAllMember failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
type GetGroupMemberListResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
Data []MemberResult `json:"data"`
|
||||
}
|
||||
|
||||
var memberListResp GetGroupMemberListResp
|
||||
memberListResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
memberListResp.ErrorCode = RpcResp.ErrorCode
|
||||
for _, v := range RpcResp.MemberList {
|
||||
memberListResp.Data = append(memberListResp.Data,
|
||||
MemberResult{GroupId: req.GroupID,
|
||||
UserId: v.UserId,
|
||||
Role: v.Role,
|
||||
JoinTime: uint64(v.JoinTime),
|
||||
Nickname: v.NickName,
|
||||
FaceUrl: v.FaceUrl})
|
||||
}
|
||||
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
type groupResult struct {
|
||||
GroupId string `json:"groupId"`
|
||||
GroupName string `json:"groupName"`
|
||||
Notification string `json:"notification"`
|
||||
Introduction string `json:"introduction"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
OwnerId string `json:"ownerId"`
|
||||
CreateTime uint64 `json:"createTime"`
|
||||
MemberCount uint32 `json:"memberCount"`
|
||||
}
|
||||
|
||||
func GetJoinedGroupList(c *gin.Context) {
|
||||
log.Info("", "", "GetJoinedGroupList start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
fmt.Println("config: ", etcdConn, config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := GetJoinedGroupListReq{}
|
||||
params := api.GetJoinedGroupListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.GetJoinedGroupListReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.GetJoinedGroupListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "GetJoinedGroupList failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "GetJoinedGroupList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "GetJoinedGroupList: ", RpcResp)
|
||||
|
||||
type GetJoinedGroupListResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
Data []groupResult `json:"data"`
|
||||
}
|
||||
|
||||
var GroupListResp GetJoinedGroupListResp
|
||||
GroupListResp.ErrorCode = RpcResp.ErrorCode
|
||||
GroupListResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
for _, v := range RpcResp.GroupList {
|
||||
GroupListResp.Data = append(GroupListResp.Data,
|
||||
groupResult{GroupId: v.GroupId, GroupName: v.GroupName,
|
||||
Notification: v.Notification,
|
||||
Introduction: v.Introduction,
|
||||
FaceUrl: v.FaceUrl,
|
||||
OwnerId: v.OwnerId,
|
||||
CreateTime: v.CreateTime,
|
||||
MemberCount: v.MemberCount})
|
||||
}
|
||||
GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
|
||||
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp)
|
||||
c.JSON(http.StatusOK, GroupListResp)
|
||||
}
|
||||
|
||||
type Id2Result struct {
|
||||
UId string `json:"uid"`
|
||||
Result int32 `json:"result"`
|
||||
}
|
||||
|
||||
func InviteUserToGroup(c *gin.Context) {
|
||||
log.Info("", "", "InviteUserToGroup start....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := InviteUserToGroupReq{}
|
||||
params := api.InviteUserToGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.InviteUserToGroupReq{
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
Reason: params.Reason,
|
||||
UidList: params.UidList,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.InviteUserToGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.InviteUserToGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "InviteUserToGroup failed, err: ", err.Error())
|
||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
type InviteUserToGroupResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
ErrorMsg string `json:"errMsg"`
|
||||
I2R []Id2Result `json:"data"`
|
||||
resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
for _, v := range RpcResp.Id2ResultList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
|
||||
var iResp InviteUserToGroupResp
|
||||
iResp.ErrorMsg = RpcResp.ErrorMsg
|
||||
iResp.ErrorCode = RpcResp.ErrorCode
|
||||
for _, v := range RpcResp.Id2Result {
|
||||
iResp.I2R = append(iResp.I2R, Id2Result{UId: v.UId, Result: v.Result})
|
||||
if len(resp.UserIDResultList) == 0 {
|
||||
resp.UserIDResultList = *new([]*api.UserIDResult)
|
||||
}
|
||||
|
||||
//resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": RpcResp.Id2Result}
|
||||
c.JSON(http.StatusOK, iResp)
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func CreateGroup(c *gin.Context) {
|
||||
params := api.CreateGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
//
|
||||
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
|
||||
for _, v := range params.MemberList {
|
||||
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
|
||||
}
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
req.OwnerUserID = req.OpUserID
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.CreateGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CreateGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
if RpcResp.ErrCode == 0 {
|
||||
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
||||
resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// 群主或管理员收到的
|
||||
func GetRecvGroupApplicationList(c *gin.Context) {
|
||||
params := api.GetGroupApplicationListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupApplicationListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
//var ok bool
|
||||
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
//if !ok {
|
||||
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
var params api.GetUserReqGroupApplicationListReq
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserReqApplicationListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
//ok, req.OpUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
//if !ok {
|
||||
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, RpcResp)
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupRequestList: RpcResp.GroupRequestList}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupsInfo(c *gin.Context) {
|
||||
params := api.GetGroupInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupsInfoReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//process application
|
||||
func ApplicationGroupResponse(c *gin.Context) {
|
||||
params := api.ApplicationGroupResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GroupApplicationResponseReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.GroupApplicationResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.ApplicationGroupResponseResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func JoinGroup(c *gin.Context) {
|
||||
params := api.JoinGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.JoinGroupReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.JoinGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "JoinGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
|
||||
log.NewInfo(req.OperationID, "JoinGroup api return", RpcResp.String())
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func QuitGroup(c *gin.Context) {
|
||||
params := api.QuitGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.QuitGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.QuitGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call quit group rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
|
||||
log.NewInfo(req.OperationID, "QuitGroup api return", RpcResp.String())
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetGroupInfo(c *gin.Context) {
|
||||
params := api.SetGroupInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.SetGroupInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.SetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo api return ", resp)
|
||||
}
|
||||
|
||||
func TransferGroupOwner(c *gin.Context) {
|
||||
params := api.TransferGroupOwnerReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.TransferGroupOwnerReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.TransferGroupOwner(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "TransferGroupOwner failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.TransferGroupOwnerResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func DismissGroup(c *gin.Context) {
|
||||
params := api.DismissGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DismissGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.DismissGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.DismissGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsGroupApplicationResponse struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
FromUserID string `json:"fromUserID" binding:"required"`
|
||||
FromUserNickName string `json:"fromUserNickName"`
|
||||
FromUserFaceUrl string `json:"fromUserFaceUrl"`
|
||||
ToUserID string `json:"toUserID" binding:"required"`
|
||||
ToUserNickName string `json:"toUserNickName"`
|
||||
ToUserFaceUrl string `json:"toUserFaceUrl"`
|
||||
AddTime int64 `json:"addTime"`
|
||||
RequestMsg string `json:"requestMsg"`
|
||||
HandledMsg string `json:"handledMsg"`
|
||||
Type int32 `json:"type"`
|
||||
HandleStatus int32 `json:"handleStatus"`
|
||||
HandleResult int32 `json:"handleResult"`
|
||||
}
|
||||
|
||||
func newGroupApplicationResponse(params *paramsGroupApplicationResponse) *group.GroupApplicationResponseReq {
|
||||
pbData := group.GroupApplicationResponseReq{
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
FromUserID: params.FromUserID,
|
||||
FromUserNickName: params.FromUserNickName,
|
||||
FromUserFaceUrl: params.FromUserFaceUrl,
|
||||
ToUserID: params.ToUserID,
|
||||
ToUserNickName: params.ToUserNickName,
|
||||
ToUserFaceUrl: params.ToUserFaceUrl,
|
||||
AddTime: params.AddTime,
|
||||
RequestMsg: params.RequestMsg,
|
||||
HandledMsg: params.HandledMsg,
|
||||
Type: params.Type,
|
||||
HandleStatus: params.HandleStatus,
|
||||
HandleResult: params.HandleResult,
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func ApplicationGroupResponse(c *gin.Context) {
|
||||
log.Info("", "", "api GroupApplicationResponse init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGroupApplicationResponse{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := newGroupApplicationResponse(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
pbData.OwnerID = claims.UID
|
||||
}
|
||||
|
||||
log.Info("", "", "api GroupApplicationResponse is server, [data: %s]", pbData.String())
|
||||
reply, err := client.GroupApplicationResponse(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.Error("", "", "api GroupApplicationResponse call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api GroupApplicationResponse call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsJoinGroup struct {
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
Message string `json:"message"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func JoinGroup(c *gin.Context) {
|
||||
log.Info("", "", "api join group init....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsJoinGroup{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.JoinGroupReq{
|
||||
GroupID: params.GroupID,
|
||||
Message: params.Message,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api join group is server,params=%s", req.String())
|
||||
RpcResp, err := client.JoinGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "call join group rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call join group rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsQuitGroup struct {
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func QuitGroup(c *gin.Context) {
|
||||
log.Info("", "", "api quit group init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsQuitGroup{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.QuitGroupReq{
|
||||
GroupID: params.GroupID,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api quit group is server,params=%s", req.String())
|
||||
RpcResp, err := client.QuitGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "call quit group rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call quit group rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
log.InfoByArgs("api quit group success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsSetGroupInfo struct {
|
||||
GroupID string `json:"groupId" binding:"required"`
|
||||
GroupName string `json:"groupName"`
|
||||
Notification string `json:"notification"`
|
||||
Introduction string `json:"introduction"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func SetGroupInfo(c *gin.Context) {
|
||||
log.Info("", "", "api set group info init...")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSetGroupInfo{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pb.SetGroupInfoReq{
|
||||
GroupID: params.GroupID,
|
||||
GroupName: params.GroupName,
|
||||
Notification: params.Notification,
|
||||
Introduction: params.Introduction,
|
||||
FaceUrl: params.FaceUrl,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api set group info is server,params=%s", req.String())
|
||||
RpcResp, err := client.SetGroupInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "call set group info rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call set group info rpc server success,args=%s", RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsTransferGroupOwner struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
}
|
||||
|
||||
func newTransferGroupOwnerReq(params *paramsTransferGroupOwner) *group.TransferGroupOwnerReq {
|
||||
pbData := group.TransferGroupOwnerReq{
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
NewOwner: params.UID,
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func TransferGroupOwner(c *gin.Context) {
|
||||
log.Info("", "", "api TransferGroupOwner init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsTransferGroupOwner{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := newTransferGroupOwnerReq(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
pbData.OldOwner = claims.UID
|
||||
}
|
||||
|
||||
log.Info("", "", "api TransferGroupOwner is server, [data: %s]", pbData.String())
|
||||
reply, err := client.TransferGroupOwner(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.Error("", "", "api TransferGroupOwner call rpc fail, [data: %s] [err: %s]", pbData.String(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api TransferGroupOwner call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
})
|
||||
|
||||
}
|
||||
@@ -7,12 +7,15 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -24,21 +27,7 @@ import (
|
||||
|
||||
var validate *validator.Validate
|
||||
|
||||
type paramsManagementSendMsg struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
}
|
||||
|
||||
func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
var newContent string
|
||||
switch params.ContentType {
|
||||
case constant.Text:
|
||||
@@ -51,37 +40,47 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
fallthrough
|
||||
case constant.File:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
default:
|
||||
}
|
||||
options := make(map[string]int32, 2)
|
||||
var options map[string]bool
|
||||
if params.IsOnlineOnly {
|
||||
options["history"] = 0
|
||||
options["persistent"] = 0
|
||||
options = make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, false)
|
||||
}
|
||||
pbData := pbChat.UserSendMsgReq{
|
||||
ReqIdentifier: constant.WSSendMsg,
|
||||
SendID: params.SendID,
|
||||
SenderNickName: params.SenderNickName,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
OperationID: params.OperationID,
|
||||
PlatformID: params.SenderPlatformID,
|
||||
SessionType: params.SessionType,
|
||||
MsgFrom: constant.UserMsgType,
|
||||
ContentType: params.ContentType,
|
||||
RecvID: params.RecvID,
|
||||
ForceList: params.ForceList,
|
||||
Content: newContent,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
Options: utils.MapIntToJsonString(options),
|
||||
pbData := pbChat.SendMsgReq{
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.RecvID,
|
||||
GroupID: params.GroupID,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
SenderNickname: params.SenderNickname,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
SessionType: params.SessionType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: params.ContentType,
|
||||
Content: []byte(newContent),
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
OfflinePushInfo: params.OfflinePushInfo,
|
||||
},
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
|
||||
func ManagementSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := paramsManagementSendMsg{}
|
||||
params := ManagementSendMsgReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
||||
@@ -106,7 +105,8 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
//case constant.Location:
|
||||
case constant.Custom:
|
||||
data = CustomElem{}
|
||||
//case constant.Revoke:
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
//case constant.HasReadReceipt:
|
||||
//case constant.Typing:
|
||||
//case constant.Quote:
|
||||
@@ -124,17 +124,33 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo("", data, params)
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
|
||||
}
|
||||
switch params.SessionType {
|
||||
case constant.SingleChatType:
|
||||
if len(params.RecvID) == 0 {
|
||||
log.NewError(params.OperationID, "recvID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
log.NewError(params.OperationID, "groupID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
@@ -146,21 +162,44 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
|
||||
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||
|
||||
reply, err := client.UserSendMsg(context.Background(), pbData)
|
||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"sendTime": reply.SendTime,
|
||||
"msgID": reply.ClientMsgID,
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
//type MergeElem struct {
|
||||
// Title string `json:"title"`
|
||||
// AbstractList []string `json:"abstractList"`
|
||||
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||
//}
|
||||
//
|
||||
//type QuoteElem struct {
|
||||
// Text string `json:"text"`
|
||||
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||
//}
|
||||
type ManagementSendMsgReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
SenderNickname string `json:"senderNickname" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
@@ -206,12 +245,6 @@ type FileElem struct {
|
||||
FileName string `mapstructure:"fileName"`
|
||||
FileSize int64 `mapstructure:"fileSize"`
|
||||
}
|
||||
|
||||
//type MergeElem struct {
|
||||
// Title string `json:"title"`
|
||||
// AbstractList []string `json:"abstractList"`
|
||||
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||
//}
|
||||
type AtElem struct {
|
||||
Text string `mapstructure:"text"`
|
||||
AtUserList []string `mapstructure:"atUserList"`
|
||||
@@ -231,7 +264,6 @@ type TextElem struct {
|
||||
Text string `mapstructure:"text" validate:"required"`
|
||||
}
|
||||
|
||||
//type QuoteElem struct {
|
||||
// Text string `json:"text"`
|
||||
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||
//}
|
||||
type RevokeElem struct {
|
||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -21,128 +22,121 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsDeleteUsers struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
DeleteUidList []string `json:"deleteUidList" binding:"required"`
|
||||
}
|
||||
type paramsGetAllUsersUid struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
type paramsGetUsersOnlineStatus struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||
}
|
||||
type paramsAccountCheck struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=100"`
|
||||
}
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
params := paramsDeleteUsers{}
|
||||
params := api.DeleteUsersReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("DeleteUser req come here", params.OperationID, "DeleteUidList", params.DeleteUidList)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
req := &pbUser.DeleteUsersReq{
|
||||
OperationID: params.OperationID,
|
||||
DeleteUidList: params.DeleteUidList,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
req := &rpc.DeleteUsersReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
||||
return
|
||||
}
|
||||
failedUidList := make([]string, 0)
|
||||
for _, v := range RpcResp.FailedUidList {
|
||||
failedUidList = append(failedUidList, v)
|
||||
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
|
||||
if len(RpcResp.FailedUserIDList) == 0 {
|
||||
resp.FailedUserIDList = []string{}
|
||||
}
|
||||
log.InfoByKv("call delete user rpc server is success", params.OperationID, "resp args", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
||||
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func GetAllUsersUid(c *gin.Context) {
|
||||
params := paramsGetAllUsersUid{}
|
||||
params := api.GetAllUsersUidReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("GetAllUsersUid req come here", params.OperationID)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
req := &pbUser.GetAllUsersUidReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
RpcResp, err := client.GetAllUsersUid(context.Background(), req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error(), "uidList": []string{}})
|
||||
req := &rpc.GetAllUserIDReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call GetAllUsersUid rpc server is success", params.OperationID, "resp args", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "uidList": RpcResp.UidList}
|
||||
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetAllUserID(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call GetAllUsersUid users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call GetAllUsersUid users rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.GetAllUsersUidResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserIDList: RpcResp.UserIDList}
|
||||
if len(RpcResp.UserIDList) == 0 {
|
||||
resp.UserIDList = []string{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetAllUsersUid api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
func AccountCheck(c *gin.Context) {
|
||||
params := paramsAccountCheck{}
|
||||
params := api.AccountCheckReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("AccountCheck req come here", params.OperationID, params.UserIDList)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
req := &pbUser.AccountCheckReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
UidList: params.UserIDList,
|
||||
req := &rpc.AccountCheckReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.AccountCheck(context.Background(), req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
log.NewError(req.OperationID, "call AccountCheck users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AccountCheck users rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call AccountCheck rpc server is success", params.OperationID, "resp args", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "result": RpcResp.Result}
|
||||
resp := api.AccountCheckResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, ResultList: RpcResp.ResultList}
|
||||
if len(RpcResp.ResultList) == 0 {
|
||||
resp.ResultList = []*rpc.AccountCheckResp_SingleUserStatus{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "AccountCheck api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
func GetUsersOnlineStatus(c *gin.Context) {
|
||||
params := paramsGetUsersOnlineStatus{}
|
||||
params := api.GetUsersOnlineStatusReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.ErrorByKv("parse token failed", params.OperationID, "err", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
log.ErrorByKv(" Authentication failed", params.OperationID, "args", c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 402, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{
|
||||
OperationID: params.OperationID,
|
||||
UserIDList: params.UserIDList,
|
||||
}
|
||||
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
@@ -156,7 +150,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.NewDebug(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
|
||||
log.NewInfo(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
|
||||
//Online data merge of each node
|
||||
for _, v1 := range params.UserIDList {
|
||||
flag = false
|
||||
@@ -176,8 +170,11 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
}
|
||||
respResult = append(respResult, temp)
|
||||
}
|
||||
log.NewDebug(params.OperationID, "Finished merged data", respResult)
|
||||
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
|
||||
resp := api.GetUsersOnlineStatusResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, SuccessResult: respResult}
|
||||
if len(respResult) == 0 {
|
||||
resp.SuccessResult = []*pbRelay.GetUsersOnlineStatusResp_SuccessResult{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
url2 "net/url"
|
||||
)
|
||||
|
||||
var (
|
||||
minioClient *minio.Client
|
||||
)
|
||||
|
||||
func MinioInit() {
|
||||
log.NewInfo("", utils.GetSelfFuncName())
|
||||
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
||||
return
|
||||
}
|
||||
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
Secure: false,
|
||||
})
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
||||
return
|
||||
}
|
||||
opt := minio.MakeBucketOptions{
|
||||
Region: config.Config.Credential.Minio.Location,
|
||||
ObjectLocking: false,
|
||||
}
|
||||
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
||||
if err != nil {
|
||||
log.NewInfo("", utils.GetSelfFuncName(), err.Error())
|
||||
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
if err == nil && exists {
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
|
||||
} else {
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
log.NewError("", utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
||||
return
|
||||
}
|
||||
}
|
||||
// 自动化桶public的代码
|
||||
//err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
||||
//if err != nil {
|
||||
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||
// return
|
||||
//}
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "minio create and set policy success")
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
_ "Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/minio/minio-go/v7"
|
||||
_ "github.com/minio/minio-go/v7"
|
||||
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func MinioUploadFile(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.MinioUploadFileReq
|
||||
resp apiStruct.MinioUploadFileResp
|
||||
)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), r)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file or snapShot args"})
|
||||
return
|
||||
}
|
||||
}()
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
switch req.FileType {
|
||||
case constant.VideoType:
|
||||
snapShotFile, err := c.FormFile("snapShot")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing snapshot arg: " + err.Error()})
|
||||
return
|
||||
}
|
||||
snapShotFileObj, err := snapShotFile.Open()
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
||||
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.SnapshotURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + snapShotNewName
|
||||
resp.SnapshotNewName = snapShotNewName
|
||||
}
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||
return
|
||||
}
|
||||
fileObj, err := file.Open()
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
||||
return
|
||||
}
|
||||
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
|
||||
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.NewName = newName
|
||||
resp.URL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + newName
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
return
|
||||
}
|
||||
|
||||
func MinioStorageCredential(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.MinioStorageCredentialReq
|
||||
resp apiStruct.MiniostorageCredentialResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
var stsOpts cr.STSAssumeRoleOptions
|
||||
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
|
||||
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
|
||||
stsOpts.DurationSeconds = constant.MinioDurationTimes
|
||||
li, err := cr.NewSTSAssumeRole(config.Config.Credential.Minio.Endpoint, stsOpts)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
v, err := li.Get()
|
||||
if err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "li.Get error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.SessionToken = v.SessionToken
|
||||
resp.SecretAccessKey = v.SecretAccessKey
|
||||
resp.AccessKeyID = v.AccessKeyID
|
||||
resp.BucketName = config.Config.Credential.Minio.Bucket
|
||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
@@ -1,51 +1,40 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"github.com/fatih/structs"
|
||||
|
||||
//"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type paramsTencentCloudStorageCredential struct {
|
||||
Token string `json:"token"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
var lastTime int64
|
||||
var lastRes *sts.CredentialResult
|
||||
|
||||
func TencentCloudStorageCredential(c *gin.Context) {
|
||||
params := paramsTencentCloudStorageCredential{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Parameter parsing error,please check the parameters and request service again"})
|
||||
req := api.TencentCloudStorageCredentialReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
log2.Info(params.Token, params.OperationID, "api TencentUpLoadCredential call start...")
|
||||
|
||||
if time.Now().Unix()-lastTime < 10 && lastRes != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": 0,
|
||||
"errMsg": "",
|
||||
"region": config.Config.Credential.Tencent.Region,
|
||||
"bucket": config.Config.Credential.Tencent.Bucket,
|
||||
"data": lastRes,
|
||||
})
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
lastTime = time.Now().Unix()
|
||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
|
||||
|
||||
cli := sts.NewClient(
|
||||
config.Config.Credential.Tencent.SecretID,
|
||||
config.Config.Credential.Tencent.SecretKey,
|
||||
nil,
|
||||
)
|
||||
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential sts.NewClient cli = %v", cli)
|
||||
|
||||
opt := &sts.CredentialOptions{
|
||||
DurationSeconds: int64(time.Hour.Seconds()),
|
||||
@@ -65,29 +54,19 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
||||
},
|
||||
},
|
||||
}
|
||||
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential sts.CredentialOptions opt = %v", opt)
|
||||
|
||||
res, err := cli.GetCredential(opt)
|
||||
resp := api.TencentCloudStorageCredentialResp{}
|
||||
if err != nil {
|
||||
log2.Error(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential err = %s", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": constant.ErrTencentCredential.ErrCode,
|
||||
"errMsg": err.Error(),
|
||||
"bucket": "",
|
||||
"region": "",
|
||||
"data": res,
|
||||
})
|
||||
return
|
||||
resp.ErrCode = constant.ErrTencentCredential.ErrCode
|
||||
resp.ErrMsg = err.Error()
|
||||
} else {
|
||||
resp.CosData.Bucket = config.Config.Credential.Tencent.Bucket
|
||||
resp.CosData.Region = config.Config.Credential.Tencent.Region
|
||||
resp.CosData.CredentialResult = res
|
||||
}
|
||||
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential success res = %v, res.Credentials = %v", res, res.Credentials)
|
||||
|
||||
lastRes = res
|
||||
resp.Data = structs.Map(&resp.CosData)
|
||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": 0,
|
||||
"errMsg": "",
|
||||
"region": config.Config.Credential.Tencent.Region,
|
||||
"bucket": config.Config.Credential.Tencent.Bucket,
|
||||
"data": res,
|
||||
})
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type userInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
type paramsGetUsersOnlineStatus struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||
Secret string `json:"secret" binding:"required,max=32"`
|
||||
}
|
||||
|
||||
func GetUsersOnlineStatus(c *gin.Context) {
|
||||
params := paramsGetUsersOnlineStatus{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
log.NewError(params.OperationID, "parse token failed ", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "secret failed"})
|
||||
return
|
||||
}
|
||||
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{
|
||||
OperationID: params.OperationID,
|
||||
UserIDList: params.UserIDList,
|
||||
}
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
|
||||
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
|
||||
continue
|
||||
} else {
|
||||
if reply.ErrCode == 0 {
|
||||
wsResult = append(wsResult, reply.SuccessResult...)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.NewDebug(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
|
||||
//Online data merge of each node
|
||||
for _, v1 := range params.UserIDList {
|
||||
flag = false
|
||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||
for _, v2 := range wsResult {
|
||||
if v2.UserID == v1 {
|
||||
flag = true
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OnlineStatus
|
||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, v2.DetailPlatformStatus...)
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OfflineStatus
|
||||
}
|
||||
respResult = append(respResult, temp)
|
||||
}
|
||||
log.NewDebug(params.OperationID, "Finished merged data", respResult)
|
||||
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetUserInfo(c *gin.Context) {
|
||||
log.InfoByKv("api get userinfo init...", "")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbUser.GetUserInfoReq{
|
||||
UserIDList: params.UIDList,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.InfoByKv("api get user info is server", c.PostForm("OperationID"), c.Request.Header.Get("token"))
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"errorCode": 500,
|
||||
"errorMsg": "call rpc server failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call get user info rpc server success", params.OperationID)
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
userInfoList := make([]userInfo, 0)
|
||||
for _, user := range RpcResp.Data {
|
||||
var ui userInfo
|
||||
ui.UID = user.Uid
|
||||
ui.Name = user.Name
|
||||
ui.Icon = user.Icon
|
||||
ui.Gender = user.Gender
|
||||
ui.Mobile = user.Mobile
|
||||
ui.Birth = user.Birth
|
||||
ui.Email = user.Email
|
||||
ui.Ex = user.Ex
|
||||
userInfoList = append(userInfoList, ui)
|
||||
}
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByKv("api get user info return success", params.OperationID, "args=%s", RpcResp.String())
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsStruct struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UIDList []string `json:"uidList"`
|
||||
Platform int32 `json:"platform"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
Ex string `json:"ex"`
|
||||
Uid string `json:"uid"`
|
||||
}
|
||||
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
log.InfoByKv("api update userinfo init...", "")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbUser.UpdateUserInfoReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
Name: params.Name,
|
||||
Icon: params.Icon,
|
||||
Gender: params.Gender,
|
||||
Mobile: params.Mobile,
|
||||
Birth: params.Birth,
|
||||
Email: params.Email,
|
||||
Ex: params.Ex,
|
||||
Uid: params.Uid,
|
||||
}
|
||||
log.InfoByKv("api update user info is server", req.OperationID, req.Token)
|
||||
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call update user info rpc server success", params.OperationID)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
log.InfoByKv("api update user info return success", params.OperationID, "args=%s", RpcResp.String())
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
jsonData "Open_IM/internal/utils"
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetUsersInfo(c *gin.Context) {
|
||||
params := api.GetUsersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
var publicUserInfoList []*open_im_sdk.PublicUserInfo
|
||||
for _, v := range RpcResp.UserInfoList {
|
||||
publicUserInfoList = append(publicUserInfoList,
|
||||
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
||||
}
|
||||
|
||||
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
||||
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
params := api.UpdateSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||
utils.CopyStructFields(req.UserInfo, ¶ms)
|
||||
|
||||
req.OperationID = params.OperationID
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetSelfUserInfo(c *gin.Context) {
|
||||
params := api.GetSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
if len(RpcResp.UserInfoList) == 1 {
|
||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfo: RpcResp.UserInfoList[0]}
|
||||
resp.Data = jsonData.JsonDataOne(resp.UserInfo)
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// register
|
||||
func AdminLogin(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.AdminLoginRequest
|
||||
resp cms_api_struct.AdminLoginResponse
|
||||
reqPb pbAdmin.AdminLoginReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.Secret = req.Secret
|
||||
reqPb.AdminID = req.AdminName
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName)
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.Token = respPb.Token
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetGroupById(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupByIdRequest
|
||||
resp cms_api_struct.GetGroupByIdResponse
|
||||
reqPb pbGroup.GetGroupByIdReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupById failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.GroupName = respPb.CMSGroup.GroupInfo.GroupName
|
||||
resp.GroupID = respPb.CMSGroup.GroupInfo.GroupID
|
||||
resp.CreateTime = (utils.UnixSecondToTime(int64(respPb.CMSGroup.GroupInfo.CreateTime))).String()
|
||||
resp.ProfilePhoto = respPb.CMSGroup.GroupInfo.FaceURL
|
||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetGroups(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupsRequest
|
||||
resp cms_api_struct.GetGroupsResponse
|
||||
reqPb pbGroup.GetGroupsReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.CMSGroups {
|
||||
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
|
||||
GroupName: v.GroupInfo.GroupName,
|
||||
GroupID: v.GroupInfo.GroupID,
|
||||
GroupMasterName: v.GroupMasterName,
|
||||
GroupMasterId: v.GroupMasterId,
|
||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||
IsBanChat: false,
|
||||
IsBanPrivateChat: false,
|
||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||
})
|
||||
}
|
||||
resp.GroupNums = int(respPb.GroupNum)
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetGroupByName(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupRequest
|
||||
resp cms_api_struct.GetGroupResponse
|
||||
reqPb pbGroup.GetGroupReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupName = req.GroupName
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.CMSGroups {
|
||||
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
|
||||
GroupName: v.GroupInfo.GroupName,
|
||||
GroupID: v.GroupInfo.GroupID,
|
||||
GroupMasterName: v.GroupMasterName,
|
||||
GroupMasterId: v.GroupMasterId,
|
||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||
IsBanChat: false,
|
||||
IsBanPrivateChat: false,
|
||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||
})
|
||||
}
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.GroupNums = int(respPb.GroupNums)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func CreateGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.CreateGroupRequest
|
||||
_ cms_api_struct.CreateGroupResponse
|
||||
reqPb pbGroup.CreateGroupReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
||||
reqPb.GroupInfo.GroupName = req.GroupName
|
||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
||||
reqPb.OwnerUserID = req.GroupMasterId
|
||||
reqPb.OpUserID = req.GroupMasterId
|
||||
for _, v := range req.GroupMembers {
|
||||
reqPb.InitMemberList = append(reqPb.InitMemberList, &pbGroup.GroupAddMemberInfo{
|
||||
UserID: v,
|
||||
RoleLevel: 1,
|
||||
})
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "CreateGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func BanGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanGroupChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BanGroupChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
|
||||
}
|
||||
|
||||
func BanPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanPrivateChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OpenPrivateChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func GetGroupMembers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupMembersRequest
|
||||
reqPb pbGroup.GetGroupMembersCMSReq
|
||||
resp cms_api_struct.GetGroupMembersResponse
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.Pagination = &commonPb.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserName = req.UserName
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||
CurrentPage: int(respPb.Pagination.CurrentPage),
|
||||
ShowNumber: int(respPb.Pagination.ShowNumber),
|
||||
}
|
||||
resp.MemberNums = int(respPb.MemberNums)
|
||||
for _, groupMembers := range respPb.Members {
|
||||
resp.GroupMembers = append(resp.GroupMembers, cms_api_struct.GroupMemberResponse{
|
||||
MemberPosition: int(groupMembers.RoleLevel),
|
||||
MemberNickName: groupMembers.Nickname,
|
||||
MemberId: groupMembers.UserID,
|
||||
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||
})
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func AddGroupMembers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.RemoveGroupMembersRequest
|
||||
resp cms_api_struct.RemoveGroupMembersResponse
|
||||
reqPb pbGroup.AddGroupMembersCMSReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.Success = respPb.Success
|
||||
resp.Failed = respPb.Failed
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func RemoveGroupMembers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.RemoveGroupMembersRequest
|
||||
resp cms_api_struct.RemoveGroupMembersResponse
|
||||
reqPb pbGroup.RemoveGroupMembersCMSReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "RemoveGroupMembersCMS failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.Success = respPb.Success
|
||||
resp.Failed = respPb.Failed
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func DeleteGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.DeleteGroupRequest
|
||||
_ cms_api_struct.DeleteGroupResponse
|
||||
reqPb pbGroup.DeleteGroupReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func SetGroupMaster(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.SetGroupMasterRequest
|
||||
_ cms_api_struct.SetGroupMasterResponse
|
||||
reqPb pbGroup.OperateUserRoleReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOwner
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func SetGroupOrdinaryUsers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.SetGroupMemberRequest
|
||||
_ cms_api_struct.AdminLoginResponse
|
||||
reqPb pbGroup.OperateUserRoleReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func AlterGroupInfo(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.AlterGroupInfoRequest
|
||||
_ cms_api_struct.SetGroupMasterResponse
|
||||
reqPb pbGroup.SetGroupInfoReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OpUserID = c.MustGet("userID").(string)
|
||||
reqPb.GroupInfo = &commonPb.GroupInfo{
|
||||
GroupID: req.GroupID,
|
||||
GroupName: req.GroupName,
|
||||
Introduction: req.Introduction,
|
||||
Notification: req.Notification,
|
||||
FaceURL: req.ProfilePhoto,
|
||||
GroupType: int32(req.GroupType),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package messageCMS
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMessage "Open_IM/pkg/proto/message_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"Open_IM/pkg/common/constant"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func BroadcastMessage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.BoradcastMessageReq
|
||||
)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func MassSendMassage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.MassSendMessageReq
|
||||
)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func WithdrawMessage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.WithdrawMessageReq
|
||||
)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func GetChatLogs(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetChatLogsRequest
|
||||
resp cms_api_struct.GetChatLogsResponse
|
||||
reqPb pbMessage.GetChatLogsReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
return
|
||||
}
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
//utils.CopyStructFields(&resp, &respPb)
|
||||
for _, chatLog := range respPb.ChatLogs {
|
||||
resp.ChatLogs = append(resp.ChatLogs, cms_api_struct.ChatLog{
|
||||
SessionType: int(chatLog.SessionType),
|
||||
ContentType: int(chatLog.ContentType),
|
||||
SenderNickName: chatLog.SenderNickName,
|
||||
SenderId: chatLog.SenderId,
|
||||
SearchContent: chatLog.SearchContent,
|
||||
WholeContent: chatLog.WholeContent,
|
||||
ReceiverNickName: chatLog.ReciverNickName,
|
||||
ReceiverID: chatLog.ReciverId,
|
||||
GroupName: chatLog.GroupName,
|
||||
GroupId: chatLog.GroupId,
|
||||
Date: chatLog.Date,
|
||||
})
|
||||
}
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func CorsHandler() gin.HandlerFunc {
|
||||
return func(context *gin.Context) {
|
||||
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
context.Header("Access-Control-Allow-Methods", "*")
|
||||
context.Header("Access-Control-Allow-Headers", "*")
|
||||
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
|
||||
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
|
||||
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
|
||||
context.Header("content-type", "application/json") // 设置返回格式是json
|
||||
//Release all option pre-requests
|
||||
if context.Request.Method == http.MethodOptions {
|
||||
context.JSON(http.StatusOK, "Options Request!")
|
||||
}
|
||||
context.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func JWTAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
||||
c.Set("userID", userID)
|
||||
if !ok {
|
||||
log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.Abort()
|
||||
http.RespHttp200(c, constant.ErrParseToken, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package organization
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetStaffs(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GetOrganizations(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GetSquads(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func AlterStaff(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func AddOrganization(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func InquireOrganization(g *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func AlterOrganization(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func DeleteOrganization(g *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GetOrganizationSquads(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func AlterStaffsInfo(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func AddChildOrganization(c *gin.Context) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package cms_api
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api/admin"
|
||||
"Open_IM/internal/cms_api/group"
|
||||
messageCMS "Open_IM/internal/cms_api/message_cms"
|
||||
"Open_IM/internal/cms_api/middleware"
|
||||
"Open_IM/internal/cms_api/organization"
|
||||
"Open_IM/internal/cms_api/statistics"
|
||||
"Open_IM/internal/cms_api/user"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func NewGinRouter() *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
baseRouter := gin.Default()
|
||||
router := baseRouter.Group("/api")
|
||||
router.Use(middleware.CorsHandler())
|
||||
adminRouterGroup := router.Group("/admin")
|
||||
{
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
}
|
||||
r2 := router.Group("")
|
||||
r2.Use(middleware.JWTAuth())
|
||||
statisticsRouterGroup := r2.Group("/statistics")
|
||||
{
|
||||
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
|
||||
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
|
||||
statisticsRouterGroup.GET("/get_group_statistics", statistics.GetGroupStatistics)
|
||||
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
|
||||
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
|
||||
}
|
||||
organizationRouterGroup := r2.Group("/organization")
|
||||
{
|
||||
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
|
||||
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
|
||||
organizationRouterGroup.GET("/get_squad", organization.GetSquads)
|
||||
organizationRouterGroup.POST("/add_organization", organization.AddOrganization)
|
||||
organizationRouterGroup.POST("/alter_staff", organization.AlterStaff)
|
||||
organizationRouterGroup.GET("/inquire_organization", organization.InquireOrganization)
|
||||
organizationRouterGroup.POST("/alter_organization", organization.AlterOrganization)
|
||||
organizationRouterGroup.POST("/delete_organization", organization.DeleteOrganization)
|
||||
organizationRouterGroup.POST("/get_organization_squad", organization.GetOrganizationSquads)
|
||||
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
|
||||
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
|
||||
}
|
||||
groupRouterGroup := r2.Group("/group")
|
||||
{
|
||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
|
||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
||||
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
|
||||
groupRouterGroup.GET("/get_group_members", group.GetGroupMembers)
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
||||
groupRouterGroup.POST("/add_members", group.AddGroupMembers)
|
||||
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
|
||||
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
|
||||
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
|
||||
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
|
||||
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
|
||||
groupRouterGroup.POST("/delete_group", group.DeleteGroup)
|
||||
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
|
||||
groupRouterGroup.POST("/set_group_master", group.SetGroupMaster)
|
||||
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
|
||||
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
|
||||
}
|
||||
userRouterGroup := r2.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/resign", user.ResignUser)
|
||||
userRouterGroup.GET("/get_user", user.GetUserById)
|
||||
userRouterGroup.POST("/alter_user", user.AlterUser)
|
||||
userRouterGroup.GET("/get_users", user.GetUsers)
|
||||
userRouterGroup.POST("/add_user", user.AddUser)
|
||||
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
||||
userRouterGroup.POST("/block_user", user.BlockUser)
|
||||
userRouterGroup.GET("/get_block_users", user.GetBlockUsers)
|
||||
userRouterGroup.GET("/get_block_user", user.GetBlockUserById)
|
||||
userRouterGroup.POST("/delete_user", user.DeleteUser)
|
||||
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
|
||||
}
|
||||
friendRouterGroup := r2.Group("/friend")
|
||||
{
|
||||
friendRouterGroup.POST("/get_friends_by_id")
|
||||
friendRouterGroup.POST("/set_friend")
|
||||
friendRouterGroup.POST("/remove_friend")
|
||||
}
|
||||
messageCMSRouterGroup := r2.Group("/message")
|
||||
{
|
||||
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
|
||||
messageCMSRouterGroup.POST("/broadcast_message", messageCMS.BroadcastMessage)
|
||||
messageCMSRouterGroup.POST("/mass_send_message", messageCMS.MassSendMassage)
|
||||
messageCMSRouterGroup.POST("/withdraw_message", messageCMS.WithdrawMessage)
|
||||
}
|
||||
return baseRouter
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/statistics"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetMessagesStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetMessageStatisticsRequest
|
||||
resp cms_api_struct.GetMessageStatisticsResponse
|
||||
reqPb pb.GetMessageStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
// utils.CopyStructFields(&resp, respPb)
|
||||
resp.GroupMessageNum = int(respPb.GroupMessageNum)
|
||||
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
|
||||
for _, v := range respPb.PrivateMessageNumList {
|
||||
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
MessageNum int "json:\"message_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
MessageNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
for _, v := range respPb.GroupMessageNumList {
|
||||
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
MessageNum int "json:\"message_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
MessageNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetUserStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUserStatisticsRequest
|
||||
resp cms_api_struct.GetUserStatisticsResponse
|
||||
reqPb pb.GetUserStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
// utils.CopyStructFields(&resp, respPb)
|
||||
resp.ActiveUserNum = int(respPb.ActiveUserNum)
|
||||
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
|
||||
resp.TotalUserNum = int(respPb.TotalUserNum)
|
||||
for _, v := range respPb.ActiveUserNumList {
|
||||
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
ActiveUserNum int "json:\"active_user_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
ActiveUserNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
for _, v := range respPb.IncreaseUserNumList {
|
||||
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
IncreaseUserNum int "json:\"increase_user_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
IncreaseUserNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
for _, v := range respPb.TotalUserNumList {
|
||||
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
||||
Date string "json:\"date\""
|
||||
TotalUserNum int "json:\"total_user_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
TotalUserNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetGroupStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupStatisticsRequest
|
||||
resp cms_api_struct.GetGroupStatisticsResponse
|
||||
reqPb pb.GetGroupStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
// utils.CopyStructFields(&resp, respPb)
|
||||
resp.IncreaseGroupNum = int(respPb.GetIncreaseGroupNum())
|
||||
resp.TotalGroupNum = int(respPb.GetTotalGroupNum())
|
||||
for _, v := range respPb.IncreaseGroupNumList {
|
||||
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
||||
struct {
|
||||
Date string "json:\"date\""
|
||||
IncreaseGroupNum int "json:\"increase_group_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
IncreaseGroupNum: int(v.Num),
|
||||
})
|
||||
}
|
||||
for _, v := range respPb.TotalGroupNumList {
|
||||
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
||||
struct {
|
||||
Date string "json:\"date\""
|
||||
TotalGroupNum int "json:\"total_group_num\""
|
||||
}{
|
||||
Date: v.Date,
|
||||
TotalGroupNum: int(v.Num),
|
||||
})
|
||||
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetActiveUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveUserRequest
|
||||
resp cms_api_struct.GetActiveUserResponse
|
||||
reqPb pb.GetActiveUserReq
|
||||
)
|
||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetActiveGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveGroupRequest
|
||||
resp cms_api_struct.GetActiveGroupResponse
|
||||
reqPb pb.GetActiveGroupReq
|
||||
)
|
||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
for _, group := range respPb.Groups {
|
||||
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
|
||||
GroupName string "json:\"group_name\""
|
||||
GroupId string "json:\"group_id\""
|
||||
MessageNum int "json:\"message_num\""
|
||||
}{
|
||||
GroupName: group.GroupName,
|
||||
GroupId: group.GroupId,
|
||||
MessageNum: int(group.MessageNum),
|
||||
})
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
pb "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetUserById(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUserRequest
|
||||
resp cms_api_struct.GetUserResponse
|
||||
reqPb pb.GetUserByIdReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
if respPb.User.UserId == "" {
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp, respPb.User)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetUsersByName(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUsersByNameRequest
|
||||
resp cms_api_struct.GetUsersByNameResponse
|
||||
reqPb pb.GetUsersByNameReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.UserName = req.UserName
|
||||
reqPb.Pagination = &commonPb.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.Users, respPb.Users)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.UserNums = respPb.UserNums
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetUsers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUsersRequest
|
||||
resp cms_api_struct.GetUsersResponse
|
||||
reqPb pb.GetUsersReq
|
||||
)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.Users, respPb.User)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.UserNums = respPb.UserNums
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
|
||||
}
|
||||
|
||||
func ResignUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.ResignUserRequest
|
||||
resp cms_api_struct.ResignUserResponse
|
||||
reqPb pb.ResignUserReq
|
||||
)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
fmt.Println(reqPb.UserId)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func AlterUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.AlterUserRequest
|
||||
resp cms_api_struct.AlterUserResponse
|
||||
reqPb pb.AlterUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "microserver failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func AddUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.AddUserRequest
|
||||
reqPb pb.AddUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.AddUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func BlockUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BlockUserRequest
|
||||
resp cms_api_struct.BlockUserResponse
|
||||
reqPb pb.BlockUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
fmt.Println(err)
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
fmt.Println(reqPb)
|
||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func UnblockUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.UnblockUserRequest
|
||||
resp cms_api_struct.UnBlockUserResponse
|
||||
reqPb pb.UnBlockUserReq
|
||||
)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetBlockUsers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetBlockUsersRequest
|
||||
resp cms_api_struct.GetBlockUsersResponse
|
||||
reqPb pb.GetBlockUsersReq
|
||||
respPb *pb.GetBlockUsersResp
|
||||
)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.BlockUsers {
|
||||
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
||||
UserResponse: cms_api_struct.UserResponse{
|
||||
UserId: v.User.UserId,
|
||||
ProfilePhoto: v.User.ProfilePhoto,
|
||||
Nickname: v.User.Nickname,
|
||||
IsBlock: v.User.IsBlock,
|
||||
CreateTime: v.User.CreateTime,
|
||||
},
|
||||
BeginDisableTime: v.BeginDisableTime,
|
||||
EndDisableTime: v.EndDisableTime,
|
||||
})
|
||||
}
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.UserNums = respPb.UserNums
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetBlockUserById(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetBlockUserRequest
|
||||
resp cms_api_struct.GetBlockUserResponse
|
||||
reqPb pb.GetBlockUserByIdReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.UserId = req.UserId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "GetBlockUserById rpc failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
||||
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
||||
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.DeleteUserRequest
|
||||
reqPb pb.DeleteUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.UserId = req.UserId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "DeleteUser rpc failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -19,16 +19,15 @@ type ParamsLogin struct {
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Password string `json:"password"`
|
||||
Platform int32 `json:"platform"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
log.NewDebug("Login api is statrting...")
|
||||
params := ParamsLogin{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
@@ -36,77 +35,36 @@ func Login(c *gin.Context) {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
log.InfoByKv("api Login get params", account)
|
||||
|
||||
queryParams := im_mysql_model.Register{
|
||||
Account: account,
|
||||
Password: params.Password,
|
||||
}
|
||||
|
||||
canLogin := im_mysql_model.Login(&queryParams)
|
||||
if canLogin == 1 {
|
||||
log.ErrorByKv("Incorrect phone number password", account, "err", "Mobile phone number is not registered")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Mobile phone number is not registered"})
|
||||
return
|
||||
}
|
||||
if canLogin == 2 {
|
||||
log.ErrorByKv("Incorrect phone number password", account, "err", "Incorrect password")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Incorrect password"})
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := OpenIMToken(account, params.Platform)
|
||||
r, err := im_mysql_model.GetRegister(account)
|
||||
if err != nil {
|
||||
log.ErrorByKv("get token by phone number err", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
|
||||
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})
|
||||
return
|
||||
}
|
||||
response, err := ioutil.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
log.ErrorByKv("Failed to read file", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
|
||||
if r.Password != params.Password {
|
||||
log.NewError(params.OperationID, "password err", params.Password, account, r.Password, r.Account)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.PasswordErr, "errMsg": "password err"})
|
||||
return
|
||||
}
|
||||
imRep := IMRegisterResp{}
|
||||
err = json.Unmarshal(response, &imRep)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json parsing failed", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if imRep.ErrCode != 0 {
|
||||
log.ErrorByKv("openIM Login request failed", account, "err")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imRep.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imRep.Data})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func OpenIMToken(Account string, platform int32) (*http.Response, error) {
|
||||
url := fmt.Sprintf("http://%s:10000/auth/user_token", utils.ServerIP)
|
||||
|
||||
client := &http.Client{}
|
||||
params := make(map[string]interface{})
|
||||
|
||||
params["secret"] = config.Config.Secret
|
||||
params["platform"] = platform
|
||||
params["uid"] = Account
|
||||
con, err := json.Marshal(params)
|
||||
openIMGetUserToken := api.UserTokenReq{}
|
||||
openIMGetUserToken.OperationID = params.OperationID
|
||||
openIMGetUserToken.Platform = params.Platform
|
||||
openIMGetUserToken.Secret = config.Config.Secret
|
||||
openIMGetUserToken.UserID = account
|
||||
openIMGetUserTokenResp := api.UserTokenResp{}
|
||||
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json parsing failed", Account, "err", err.Error())
|
||||
return nil, err
|
||||
log.NewError(params.OperationID, "request openIM get user token error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
|
||||
if err != nil {
|
||||
log.ErrorByKv("request error", "/auth/user_token", "err", err.Error())
|
||||
return nil, err
|
||||
err = json.Unmarshal(bMsg, &openIMGetUserTokenResp)
|
||||
if err != nil || openIMGetUserTokenResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, "request get user token", account, "err", "")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": ""})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMGetUserTokenResp.UserToken})
|
||||
|
||||
resp, err := client.Do(req)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type resetPasswordRequest struct {
|
||||
VerificationCode string `json:"verificationCode" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
NewPassword string `json:"newPassword" binding:"required"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
func ResetPassword(c *gin.Context) {
|
||||
var (
|
||||
req resetPasswordRequest
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
var account string
|
||||
if req.Email != "" {
|
||||
account = req.Email
|
||||
} else {
|
||||
account = req.PhoneNumber
|
||||
}
|
||||
if req.VerificationCode != config.Config.Demo.SuperCode {
|
||||
accountKey := account + "_" + constant.VerificationCodeForResetSuffix
|
||||
v, err := db.DB.GetAccountCode(accountKey)
|
||||
if err != nil || v != req.VerificationCode {
|
||||
log.NewError(req.OperationID, "password Verification code error", account, req.VerificationCode, v)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
}
|
||||
user, err := im_mysql_model.GetRegister(account)
|
||||
if err != nil || user.Account == "" {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "user not register!"})
|
||||
return
|
||||
}
|
||||
if err := im_mysql_model.ResetPassword(account, req.NewPassword); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ResetPasswordFailed, "errMsg": "reset password failed: "+err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "reset password success"})
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
||||
dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
"math/rand"
|
||||
@@ -21,39 +20,55 @@ import (
|
||||
type paramsVerificationCode struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
log.InfoByKv("sendCode api is statrting...", "")
|
||||
params := paramsVerificationCode{}
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.ErrorByKv("request params json parsing failed", params.PhoneNumber, params.Email, "err", err.Error())
|
||||
log.NewError("", "BindJSON failed", "err:", err.Error(), "phoneNumber", params.PhoneNumber, "email", params.Email)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
queryParams := im_mysql_model.GetRegisterParams{
|
||||
Account: account,
|
||||
var accountKey string
|
||||
if params.UsedFor == 0 {
|
||||
params.UsedFor = constant.VerificationCodeForRegister
|
||||
}
|
||||
_, err, rowsAffected := im_mysql_model.GetRegister(&queryParams)
|
||||
switch params.UsedFor {
|
||||
case constant.VerificationCodeForRegister:
|
||||
_, err := im_mysql_model.GetRegister(account)
|
||||
if err == nil {
|
||||
log.NewError(params.OperationID, "The phone number has been registered", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
ok, err := db.DB.JudgeAccountEXISTS(account)
|
||||
if ok || err != nil {
|
||||
log.NewError(params.OperationID, "The phone number has been registered", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RepeatSendCode, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
|
||||
if err == nil && rowsAffected != 0 {
|
||||
log.ErrorByKv("The phone number has been registered", queryParams.Account, "err")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
case constant.VerificationCodeForReset:
|
||||
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||
}
|
||||
|
||||
log.InfoByKv("begin sendSms", account)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
code := 100000 + rand.Intn(900000)
|
||||
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey, code)
|
||||
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
log.NewDebug("", config.Config.Demo)
|
||||
if params.Email != "" {
|
||||
m := gomail.NewMessage()
|
||||
@@ -63,14 +78,14 @@ func SendVerificationCode(c *gin.Context) {
|
||||
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
|
||||
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
|
||||
log.ErrorByKv("send mail error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": err.Error()})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
client, err := CreateClient(tea.String(config.Config.Demo.AliSMSVerify.AccessKeyID), tea.String(config.Config.Demo.AliSMSVerify.AccessKeySecret))
|
||||
if err != nil {
|
||||
log.ErrorByKv("create sendSms client err", "", "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
log.NewError(params.OperationID, "create sendSms client err", "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -83,56 +98,20 @@ func SendVerificationCode(c *gin.Context) {
|
||||
|
||||
response, err := client.SendSms(sendSmsRequest)
|
||||
if err != nil {
|
||||
log.ErrorByKv("sendSms error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
log.NewError(params.OperationID, "sendSms error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
if *response.Body.Code != "OK" {
|
||||
log.ErrorByKv("alibabacloud sendSms error", account, "err", response.Body.Code, response.Body.Message)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
log.NewError(params.OperationID, "alibabacloud sendSms error", account, "err", response.Body.Code, response.Body.Message)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.SmsSendCodeErr, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store redis", account)
|
||||
v, err := redis.Int(db.DB.Exec("TTL", account))
|
||||
if err != nil {
|
||||
log.ErrorByKv("get account from redis error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case v == -2:
|
||||
_, err = db.DB.Exec("SET", account, code, "EX", 600)
|
||||
if err != nil {
|
||||
log.ErrorByKv("set redis error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code sent successfully!", "data": data})
|
||||
log.InfoByKv("send new verification code", account)
|
||||
return
|
||||
case v > 540:
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Frequent operation!", "data": data})
|
||||
log.InfoByKv("frequent operation", account)
|
||||
return
|
||||
case v < 540:
|
||||
_, err = db.DB.Exec("SET", account, code, "EX", 600)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enterthe superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code has been reset!", "data": data})
|
||||
log.InfoByKv("Reset verification code", account)
|
||||
return
|
||||
}
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code has been set!", "data": data})
|
||||
}
|
||||
|
||||
func CreateClient(accessKeyId *string, accessKeySecret *string) (result *dysmsapi20170525.Client, err error) {
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -21,135 +20,66 @@ type ParamsSetPassword struct {
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Password string `json:"password"`
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
ExpiredTime int64 `json:"expiredTime"`
|
||||
Token string `json:"token"`
|
||||
Uid string `json:"uid"`
|
||||
}
|
||||
|
||||
type IMRegisterResp struct {
|
||||
Data Data `json:"data"`
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=7"`
|
||||
Ex string `json:"ex"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func SetPassword(c *gin.Context) {
|
||||
log.InfoByKv("setPassword api is statrting...", "")
|
||||
params := ParamsSetPassword{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store redis", account)
|
||||
v, err := redis.String(db.DB.Exec("GET", account))
|
||||
|
||||
if params.VerificationCode == config.Config.Demo.SuperCode {
|
||||
goto openIMRegisterTab
|
||||
if params.VerificationCode != config.Config.Demo.SuperCode {
|
||||
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
v, err := db.DB.GetAccountCode(accountKey)
|
||||
if err != nil || v != params.VerificationCode {
|
||||
log.NewError(params.OperationID, "password Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
data["PhoneNumber"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Get Redis:", v, err)
|
||||
url := fmt.Sprintf("http://%s:10000/auth/user_register", utils.ServerIP)
|
||||
openIMRegisterReq := api.UserRegisterReq{}
|
||||
openIMRegisterReq.OperationID = params.OperationID
|
||||
openIMRegisterReq.Platform = params.Platform
|
||||
openIMRegisterReq.UserID = account
|
||||
openIMRegisterReq.Nickname = account
|
||||
openIMRegisterReq.Secret = config.Config.Secret
|
||||
openIMRegisterResp := api.UserRegisterResp{}
|
||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||
if err != nil {
|
||||
log.ErrorByKv("password Verification code expired", account, "err", err.Error())
|
||||
data := make(map[string]interface{})
|
||||
data["phoneNumber"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification expired!", "data": data})
|
||||
log.NewError(params.OperationID, "request openIM register error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if v != params.VerificationCode {
|
||||
log.InfoByKv("password Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
data["PhoneNumber"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code error!", "data": data})
|
||||
err = json.Unmarshal(bMsg, &openIMRegisterResp)
|
||||
if err != nil || openIMRegisterResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: "+openIMRegisterResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
openIMRegisterTab:
|
||||
log.InfoByKv("openIM register begin", account)
|
||||
resp, err := OpenIMRegister(account)
|
||||
|
||||
log.InfoByKv("openIM register resp", account, resp, err)
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex)
|
||||
if err != nil {
|
||||
log.ErrorByKv("request openIM register error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
|
||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
response, err := ioutil.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
imrep := IMRegisterResp{}
|
||||
err = json.Unmarshal(response, &imrep)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if imrep.ErrCode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imrep.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
queryParams := im_mysql_model.SetPasswordParams{
|
||||
Account: account,
|
||||
Password: params.Password,
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store mysql", account, params.Password)
|
||||
_, err = im_mysql_model.SetPassword(&queryParams)
|
||||
if err != nil {
|
||||
log.ErrorByKv("set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.DatabaseError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
log.InfoByKv("end setPassword", account)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imrep.Data})
|
||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
||||
func OpenIMRegister(account string) (*http.Response, error) {
|
||||
url := fmt.Sprintf("http://%s:10000/auth/user_register", utils.ServerIP)
|
||||
fmt.Println("1:", config.Config.Secret)
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
params := make(map[string]interface{})
|
||||
|
||||
params["secret"] = config.Config.Secret
|
||||
params["platform"] = 2
|
||||
params["uid"] = account
|
||||
params["name"] = account
|
||||
params["icon"] = ""
|
||||
params["gender"] = 0
|
||||
|
||||
params["mobile"] = ""
|
||||
|
||||
params["email"] = ""
|
||||
params["birth"] = ""
|
||||
params["ex"] = ""
|
||||
con, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.InfoByKv("openIM register params", account, params)
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@@ -15,14 +14,14 @@ type paramsCertification struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
}
|
||||
|
||||
func Verify(c *gin.Context) {
|
||||
log.InfoByKv("Verify api is statrting...", "")
|
||||
params := paramsCertification{}
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.ErrorByKv("request params json parsing failed", "", "err", err.Error())
|
||||
log.NewError("", "request params json parsing failed", "", "err", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
@@ -44,27 +43,38 @@ func Verify(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
|
||||
log.InfoByKv("begin get form redis", account)
|
||||
v, err := redis.String(db.DB.Exec("GET", account))
|
||||
log.InfoByKv("redis phone number and verificating Code", account, v)
|
||||
log.NewInfo(params.OperationID, "begin get form redis", account)
|
||||
if params.UsedFor == 0 {
|
||||
params.UsedFor = constant.VerificationCodeForRegister
|
||||
}
|
||||
var accountKey string
|
||||
switch params.UsedFor {
|
||||
case constant.VerificationCodeForRegister:
|
||||
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
case constant.VerificationCodeForReset:
|
||||
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||
}
|
||||
|
||||
code, err := db.DB.GetAccountCode(accountKey)
|
||||
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
|
||||
if err != nil {
|
||||
log.ErrorByKv("Verification code expired", account, "err", err.Error())
|
||||
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code expired!", "data": data})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code expired!", "data": data})
|
||||
return
|
||||
}
|
||||
if params.VerificationCode == v {
|
||||
log.InfoByKv("Verified successfully", account)
|
||||
if params.VerificationCode == code {
|
||||
log.Info(params.OperationID, "Verified successfully", account)
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
data["verificationCode"] = params.VerificationCode
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
|
||||
return
|
||||
} else {
|
||||
log.InfoByKv("Verification code error", account, params.VerificationCode)
|
||||
log.Info(params.OperationID, "Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code error!", "data": data})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,19 @@ package gate
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/statistics"
|
||||
"fmt"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
rwLock *sync.RWMutex
|
||||
validate *validator.Validate
|
||||
ws WServer
|
||||
rpcSvr RPCServer
|
||||
rwLock *sync.RWMutex
|
||||
validate *validator.Validate
|
||||
ws WServer
|
||||
rpcSvr RPCServer
|
||||
sendMsgCount uint64
|
||||
userCount uint64
|
||||
)
|
||||
|
||||
func Init(rpcPort, wsPort int) {
|
||||
@@ -19,6 +23,8 @@ func Init(rpcPort, wsPort int) {
|
||||
log.NewPrivateLog(config.Config.ModuleName.LongConnSvrName)
|
||||
rwLock = new(sync.RWMutex)
|
||||
validate = validator.New()
|
||||
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)
|
||||
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", userCount), 300)
|
||||
ws.onInit(wsPort)
|
||||
rpcSvr.onInit(rpcPort)
|
||||
}
|
||||
|
||||
+108
-121
@@ -6,12 +6,10 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gorilla/websocket"
|
||||
"runtime"
|
||||
@@ -30,7 +28,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
dec := gob.NewDecoder(b)
|
||||
err := dec.Decode(&m)
|
||||
if err != nil {
|
||||
log.ErrorByKv("ws Decode err", "", "err", err.Error())
|
||||
log.NewError("", "ws Decode err", err.Error())
|
||||
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
@@ -39,7 +37,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
return
|
||||
}
|
||||
if err := validate.Struct(m); err != nil {
|
||||
log.ErrorByKv("ws args validate err", "", "err", err.Error())
|
||||
log.NewError("", "ws args validate err", err.Error())
|
||||
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
||||
return
|
||||
}
|
||||
@@ -47,46 +45,45 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
||||
// return
|
||||
//}
|
||||
log.InfoByKv("Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID, "msgIncr", m.MsgIncr)
|
||||
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m)
|
||||
|
||||
switch m.ReqIdentifier {
|
||||
case constant.WSGetNewestSeq:
|
||||
go ws.getSeqReq(conn, &m)
|
||||
case constant.WSPullMsg:
|
||||
go ws.pullMsgReq(conn, &m)
|
||||
ws.getSeqReq(conn, &m)
|
||||
case constant.WSSendMsg:
|
||||
sendTime := utils.GetCurrentTimestampByNano()
|
||||
go ws.sendMsgReq(conn, &m, sendTime)
|
||||
ws.sendMsgReq(conn, &m)
|
||||
case constant.WSSendSignalMsg:
|
||||
ws.sendSignalMsgReq(conn, &m)
|
||||
case constant.WSPullMsgBySeqList:
|
||||
go ws.pullMsgBySeqListReq(conn, &m)
|
||||
ws.pullMsgBySeqListReq(conn, &m)
|
||||
default:
|
||||
}
|
||||
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
||||
}
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
pbData := pbChat.GetMaxAndMinSeqReq{}
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier, m.Data)
|
||||
rpcReq := pbChat.GetMaxAndMinSeqReq{}
|
||||
nReply := new(pbChat.GetMaxAndMinSeqResp)
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m)
|
||||
log.ErrorByKv("get grpcConn err", rpcReq.OperationID, "args", m)
|
||||
}
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
|
||||
if err != nil {
|
||||
log.ErrorByKv("rpc call failed to getSeqReq", pbData.OperationID, "err", err, "pbData", pbData.String())
|
||||
nReply.ErrCode = 200
|
||||
log.Error(rpcReq.OperationID, "rpc call failed to getSeqReq", err, rpcReq.String())
|
||||
nReply.ErrCode = 500
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.getSeqResp(conn, m, nReply)
|
||||
} else {
|
||||
log.InfoByKv("rpc call success to getSeqReq", pbData.OperationID, "replyData", reply.String())
|
||||
ws.getSeqResp(conn, m, reply)
|
||||
log.InfoByKv("rpc call success to getSeqReq", rpcReq.OperationID, "replyData", rpcReply.String())
|
||||
ws.getSeqResp(conn, m, rpcReply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeqResp) {
|
||||
var mReplyData open_im_sdk.GetMaxAndMinSeqResp
|
||||
var mReplyData sdk_ws.GetMaxAndMinSeqResp
|
||||
mReplyData.MaxSeq = pb.GetMaxSeq()
|
||||
mReplyData.MinSeq = pb.GetMinSeq()
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
@@ -100,58 +97,38 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeq
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgReq", m.ReqIdentifier, m.MsgIncr, m.SendID)
|
||||
nReply := new(pbChat.PullMessageResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsg)
|
||||
|
||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, m.Data)
|
||||
nReply := new(sdk_ws.PullMessageBySeqListResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
|
||||
if isPass {
|
||||
pbData := pbChat.PullMessageReq{}
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
pbData.SeqBegin = data.(SeqData).SeqBegin
|
||||
pbData.SeqEnd = data.(SeqData).SeqEnd
|
||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessage error", pbData.OperationID, "err", err.Error())
|
||||
log.NewError(rpcReq.OperationID, "pullMsgBySeqListReq err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
ws.pullMsgBySeqListResp(conn, m, nReply)
|
||||
} else {
|
||||
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
|
||||
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
log.NewInfo(rpcReq.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), len(reply.List))
|
||||
ws.pullMsgBySeqListResp(conn, m, reply)
|
||||
}
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
ws.pullMsgBySeqListResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String())
|
||||
var mReplyData open_im_sdk.PullMessageBySeqListResp
|
||||
a, err := json.Marshal(pb.SingleUserMsg)
|
||||
if err != nil {
|
||||
log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error())
|
||||
}
|
||||
log.NewInfo(m.OperationID, "pullMsgResp json is ", len(pb.SingleUserMsg))
|
||||
err = json.Unmarshal(a, &mReplyData.SingleUserMsg)
|
||||
if err != nil {
|
||||
log.NewError(m.OperationID, "SingleUserMsg,json Unmarshal,err", err.Error())
|
||||
}
|
||||
b, err := json.Marshal(pb.GroupUserMsg)
|
||||
if err != nil {
|
||||
log.NewError(m.OperationID, "mReplyData,json marshal,err", err.Error())
|
||||
}
|
||||
err = json.Unmarshal(b, &mReplyData.GroupUserMsg)
|
||||
if err != nil {
|
||||
log.NewError(m.OperationID, "test SingleUserMsg,json Unmarshal,err", err.Error())
|
||||
}
|
||||
c, err := proto.Marshal(&mReplyData)
|
||||
log.NewInfo(m.OperationID, "test info is ", len(mReplyData.SingleUserMsg), mReplyData.SingleUserMsg)
|
||||
|
||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
||||
c, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
MsgIncr: m.MsgIncr,
|
||||
@@ -160,92 +137,52 @@ func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageRes
|
||||
OperationID: m.OperationID,
|
||||
Data: c,
|
||||
}
|
||||
log.NewInfo(m.OperationID, "pullMsgResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
|
||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
|
||||
len(mReply.Data))
|
||||
|
||||
ws.sendMsg(conn, mReply)
|
||||
|
||||
}
|
||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr)
|
||||
nReply := new(pbChat.PullMessageResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(open_im_sdk.PullMessageBySeqListReq).SeqList)
|
||||
if isPass {
|
||||
pbData := pbChat.PullMessageBySeqListReq{}
|
||||
pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "pullMsgBySeqListReq err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), reply.GetMaxSeq(), reply.GetMinSeq(), len(reply.GetSingleUserMsg()), len(reply.GetGroupUserMsg()))
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
}
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, sendTime)
|
||||
nReply := new(pbChat.UserSendMsgResp)
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
sendMsgCount++
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
|
||||
nReply := new(pbChat.SendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||
if isPass {
|
||||
data := pData.(open_im_sdk.UserSendMsgReq)
|
||||
pbData := pbChat.UserSendMsgReq{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
Token: m.Token,
|
||||
SendID: m.SendID,
|
||||
OperationID: m.OperationID,
|
||||
PlatformID: data.PlatformID,
|
||||
SessionType: data.SessionType,
|
||||
MsgFrom: data.MsgFrom,
|
||||
ContentType: data.ContentType,
|
||||
RecvID: data.RecvID,
|
||||
ForceList: data.ForceList,
|
||||
SenderNickName: data.SenderNickName,
|
||||
SenderFaceURL: data.SenderFaceURL,
|
||||
Content: data.Content,
|
||||
Options: utils.MapIntToJsonString(data.Options),
|
||||
ClientMsgID: data.ClientMsgID,
|
||||
SendTime: sendTime,
|
||||
data := pData.(sdk_ws.MsgData)
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: m.Token,
|
||||
OperationID: m.OperationID,
|
||||
MsgData: &data,
|
||||
}
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
reply, err := client.UserSendMsg(context.Background(), &pbData)
|
||||
reply, err := client.SendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
ws.sendMsgResp(conn, m, nReply)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||
ws.sendMsgResp(conn, m, reply)
|
||||
}
|
||||
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
ws.sendMsgResp(conn, m, nReply)
|
||||
}
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgResp, sendTime int64) {
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||
// := make(map[string]interface{})
|
||||
|
||||
var mReplyData open_im_sdk.UserSendMsgResp
|
||||
var mReplyData sdk_ws.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = sendTime
|
||||
mReplyData.SendTime = pb.GetSendTime()
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
@@ -258,17 +195,67 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgRes
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
|
||||
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
|
||||
nReply := new(pbChat.SendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
|
||||
if isPass {
|
||||
isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
|
||||
if isPass2 {
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: m.Token,
|
||||
OperationID: m.OperationID,
|
||||
MsgData: msgData,
|
||||
}
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
reply, err := client.SendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.sendSignalMsgResp(conn, 200, err.Error(), m, signalResp)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||
ws.sendSignalMsgResp(conn, 0, "", m, signalResp)
|
||||
}
|
||||
} else {
|
||||
log.NewError(m.OperationID, isPass2, errCode2, errMsg2)
|
||||
ws.sendSignalMsgResp(conn, errCode2, errMsg2, m, signalResp)
|
||||
}
|
||||
} else {
|
||||
ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil)
|
||||
}
|
||||
|
||||
}
|
||||
func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *sdk_ws.SignalResp) {
|
||||
// := make(map[string]interface{})
|
||||
|
||||
b, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
MsgIncr: m.MsgIncr,
|
||||
ErrCode: errCode,
|
||||
ErrMsg: errMsg,
|
||||
OperationID: m.OperationID,
|
||||
Data: b,
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
|
||||
var b bytes.Buffer
|
||||
enc := gob.NewEncoder(&b)
|
||||
err := enc.Encode(mReply)
|
||||
if err != nil {
|
||||
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "Encode Msg error", conn.RemoteAddr().String(), ws.getUserUid(conn), err.Error())
|
||||
uid, platform := ws.getUserUid(conn)
|
||||
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "Encode Msg error", conn.RemoteAddr().String(), uid, platform, err.Error())
|
||||
return
|
||||
}
|
||||
err = ws.writeMsg(conn, websocket.BinaryMessage, b.Bytes())
|
||||
if err != nil {
|
||||
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "WS WriteMsg error", conn.RemoteAddr().String(), ws.getUserUid(conn), err.Error())
|
||||
uid, platform := ws.getUserUid(conn)
|
||||
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "WS WriteMsg error", conn.RemoteAddr().String(), uid, platform, err.Error())
|
||||
}
|
||||
}
|
||||
func (ws *WServer) sendErrMsg(conn *UserConn, errCode int32, errMsg string, reqIdentifier int32, msgIncr string, operationID string) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package open_im_media
|
||||
|
||||
import (
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/jinzhu/copier"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
// Address gRPC服务地址
|
||||
Address = "127.0.0.1:11300"
|
||||
)
|
||||
|
||||
//var roomClient *lksdk.RoomServiceClient
|
||||
|
||||
type Media struct {
|
||||
}
|
||||
|
||||
func NewMedia() *Media {
|
||||
return &Media{}
|
||||
}
|
||||
|
||||
func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
|
||||
var newData pbRtc.ParticipantMetaData
|
||||
copier.Copy(&newData, data)
|
||||
conn, err := grpc.Dial(Address, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
defer conn.Close()
|
||||
c := pbRtc.NewRtcServiceClient(conn)
|
||||
req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
|
||||
resp, err := c.GetJoinToken(context.Background(), req)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if resp.CommonResp.ErrCode != 0 {
|
||||
return "", "", errors.New(resp.CommonResp.ErrMsg)
|
||||
}
|
||||
return resp.Jwt, resp.LiveURL, nil
|
||||
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
|
||||
//grant := &auth.VideoGrant{
|
||||
// RoomJoin: true,
|
||||
// Room: room,
|
||||
//}
|
||||
//at.AddGrant(grant).
|
||||
// SetIdentity(identity).
|
||||
// SetValidFor(time.Hour)
|
||||
//
|
||||
//return at.ToJWT()
|
||||
}
|
||||
|
||||
func init() {
|
||||
//roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)
|
||||
}
|
||||
|
||||
func (m *Media) CreateRoom(roomName string) (error, error) {
|
||||
return nil, nil
|
||||
//return roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
|
||||
// Name: roomName,
|
||||
// EmptyTimeout: 60 * 3,
|
||||
//})
|
||||
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -55,26 +55,10 @@ func (r *RPCServer) run() {
|
||||
return
|
||||
}
|
||||
}
|
||||
func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbRelay.MsgToUserResp, error) {
|
||||
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
|
||||
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
|
||||
var resp []*pbRelay.SingleMsgToUser
|
||||
var RecvID string
|
||||
msg := open_im_sdk.MsgData{
|
||||
SendID: in.SendID,
|
||||
RecvID: in.RecvID,
|
||||
MsgFrom: in.MsgFrom,
|
||||
ContentType: in.ContentType,
|
||||
SessionType: in.SessionType,
|
||||
SenderNickName: in.SenderNickName,
|
||||
SenderFaceURL: in.SenderFaceURL,
|
||||
ClientMsgID: in.ClientMsgID,
|
||||
ServerMsgID: in.ServerMsgID,
|
||||
Content: in.Content,
|
||||
Seq: in.RecvSeq,
|
||||
SendTime: in.SendTime,
|
||||
SenderPlatformID: in.PlatformID,
|
||||
}
|
||||
msgBytes, _ := proto.Marshal(&msg)
|
||||
msgBytes, _ := proto.Marshal(in.MsgData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: constant.WSPushMsg,
|
||||
OperationID: in.OperationID,
|
||||
@@ -86,65 +70,50 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
||||
if err != nil {
|
||||
log.NewError(in.OperationID, "data encode err", err.Error())
|
||||
}
|
||||
switch in.GetSessionType() {
|
||||
case constant.SingleChatType:
|
||||
RecvID = in.GetRecvID()
|
||||
case constant.GroupChatType:
|
||||
RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
||||
}
|
||||
var tag bool
|
||||
var UIDAndPID []string
|
||||
userIDList := genUidPlatformArray(RecvID)
|
||||
for _, v := range userIDList {
|
||||
UIDAndPID = strings.Split(v, " ")
|
||||
if conn := ws.getUserConn(v); conn != nil {
|
||||
recvID := in.PushToUserID
|
||||
platformList := genPlatformArray()
|
||||
for _, v := range platformList {
|
||||
if conn := ws.getUserConn(recvID, v); conn != nil {
|
||||
tag = true
|
||||
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
|
||||
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: resultCode,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
|
||||
RecvID: recvID,
|
||||
RecvPlatFormID: constant.PlatformNameToID(v),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
} else {
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: -1,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
|
||||
RecvID: recvID,
|
||||
RecvPlatFormID: constant.PlatformNameToID(v),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
}
|
||||
}
|
||||
//Single chat sender synchronization message
|
||||
if in.GetSessionType() == constant.SingleChatType && in.ContentType <= constant.Quote && in.ContentType != constant.Typing && in.ContentType != constant.HasReadReceipt {
|
||||
userIDList = genUidPlatformArray(in.SendID)
|
||||
for _, v := range userIDList {
|
||||
UIDAndPID = strings.Split(v, " ")
|
||||
if conn := ws.getUserConn(v); conn != nil {
|
||||
_ = sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
if !tag {
|
||||
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
|
||||
}
|
||||
return &pbRelay.MsgToUserResp{
|
||||
return &pbRelay.OnlinePushMsgResp{
|
||||
Resp: resp,
|
||||
}, nil
|
||||
}
|
||||
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
|
||||
log.NewDebug(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
|
||||
var UIDAndPID []string
|
||||
log.NewInfo(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
|
||||
if !token_verify.IsMangerUserID(req.OpUserID) {
|
||||
log.NewError(req.OperationID, "no permission GetUsersOnlineStatus ", req.OpUserID)
|
||||
return &pbRelay.GetUsersOnlineStatusResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
var resp pbRelay.GetUsersOnlineStatusResp
|
||||
for _, v1 := range req.UserIDList {
|
||||
userIDList := genUidPlatformArray(v1)
|
||||
for _, userID := range req.UserIDList {
|
||||
platformList := genPlatformArray()
|
||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||
temp.UserID = v1
|
||||
for _, v2 := range userIDList {
|
||||
UIDAndPID = strings.Split(v2, " ")
|
||||
if conn := ws.getUserConn(v2); conn != nil {
|
||||
temp.UserID = userID
|
||||
for _, platform := range platformList {
|
||||
if conn := ws.getUserConn(userID, platform); conn != nil {
|
||||
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
|
||||
ps.Platform = UIDAndPID[1]
|
||||
ps.Platform = platform
|
||||
ps.Status = constant.OnlineStatus
|
||||
temp.Status = constant.OnlineStatus
|
||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
|
||||
@@ -155,13 +124,14 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
|
||||
resp.SuccessResult = append(resp.SuccessResult, temp)
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetUsersOnlineStatus rpc return ", resp.String())
|
||||
return &resp, nil
|
||||
}
|
||||
func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPlatForm, RecvID string) (ResultCode int64) {
|
||||
func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.OnlinePushMsgReq, RecvPlatForm, RecvID string) (ResultCode int64) {
|
||||
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PushMsgToUser is failed By Ws", "", "Addr", conn.RemoteAddr().String(),
|
||||
"error", err, "senderPlatform", constant.PlatformIDToName(in.PlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
|
||||
"error", err, "senderPlatform", constant.PlatformIDToName(in.MsgData.SenderPlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
|
||||
ResultCode = -2
|
||||
return ResultCode
|
||||
} else {
|
||||
@@ -171,9 +141,9 @@ func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPl
|
||||
}
|
||||
|
||||
}
|
||||
func genUidPlatformArray(uid string) (array []string) {
|
||||
func genPlatformArray() (array []string) {
|
||||
for i := 1; i <= constant.LinuxPlatformID; i++ {
|
||||
array = append(array, uid+" "+constant.PlatformIDToName(int32(i)))
|
||||
array = append(array, constant.PlatformIDToName(int32(i)))
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_gateway/gate/open_im_media"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"errors"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -59,7 +62,7 @@ type SeqListData struct {
|
||||
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||
switch r {
|
||||
case constant.WSSendMsg:
|
||||
data := open_im_sdk.UserSendMsgReq{}
|
||||
data := open_im_sdk.MsgData{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
return false, 203, err.Error(), nil
|
||||
@@ -70,6 +73,18 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
|
||||
}
|
||||
return true, 0, "", data
|
||||
case constant.WSSendSignalMsg:
|
||||
data := open_im_sdk.SignalReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
return false, 203, err.Error(), nil
|
||||
}
|
||||
if err := validate.Struct(data); err != nil {
|
||||
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
return false, 204, err.Error(), nil
|
||||
|
||||
}
|
||||
return true, 0, "", &data
|
||||
case constant.WSPullMsgBySeqList:
|
||||
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
@@ -101,3 +116,139 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
//} else
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
|
||||
var msg open_im_sdk.MsgData
|
||||
var resp open_im_sdk.SignalResp
|
||||
media := open_im_media.NewMedia()
|
||||
msg.MsgFrom = constant.UserMsgType
|
||||
msg.ContentType = constant.SignalingNotification
|
||||
reqData, e := proto.Marshal(s)
|
||||
if e != nil {
|
||||
return false, 201, e.Error(), nil, nil
|
||||
}
|
||||
msg.Content = reqData
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
options := make(map[string]bool, 6)
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
|
||||
msg.Options = options
|
||||
switch payload := s.Payload.(type) {
|
||||
case *open_im_sdk.SignalReq_Invite:
|
||||
token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
|
||||
if err2 != nil {
|
||||
return false, 202, err2.Error(), nil, nil
|
||||
}
|
||||
invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
|
||||
Token: token,
|
||||
RoomID: payload.Invite.Invitation.RoomID,
|
||||
LiveURL: liveURL,
|
||||
}}
|
||||
resp.Payload = &invite
|
||||
msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
|
||||
msg.SessionType = payload.Invite.Invitation.SessionType
|
||||
msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
|
||||
msg.SendID = payload.Invite.Invitation.InviterUserID
|
||||
if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
|
||||
msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
|
||||
} else {
|
||||
return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
|
||||
return true, 0, "", &resp, &msg
|
||||
case *open_im_sdk.SignalReq_InviteInGroup:
|
||||
token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
|
||||
if err2 != nil {
|
||||
return false, 204, err2.Error(), nil, nil
|
||||
}
|
||||
inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
|
||||
RoomID: payload.InviteInGroup.Invitation.RoomID,
|
||||
Token: token,
|
||||
LiveURL: liveURL,
|
||||
}}
|
||||
resp.Payload = &inviteGroup
|
||||
msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
|
||||
msg.SessionType = payload.InviteInGroup.Invitation.SessionType
|
||||
msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
|
||||
msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
|
||||
if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
|
||||
msg.GroupID = payload.InviteInGroup.Invitation.GroupID
|
||||
} else {
|
||||
return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
|
||||
|
||||
return true, 0, "", &resp, &msg
|
||||
case *open_im_sdk.SignalReq_Cancel:
|
||||
cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
|
||||
resp.Payload = &cancel
|
||||
msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
|
||||
msg.SendID = payload.Cancel.Invitation.InviterUserID
|
||||
msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
|
||||
msg.SessionType = payload.Cancel.Invitation.SessionType
|
||||
if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
|
||||
switch payload.Cancel.Invitation.SessionType {
|
||||
case constant.SingleChatType:
|
||||
msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
|
||||
case constant.GroupChatType:
|
||||
msg.GroupID = payload.Cancel.Invitation.GroupID
|
||||
}
|
||||
} else {
|
||||
return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
|
||||
return true, 0, "", &resp, &msg
|
||||
case *open_im_sdk.SignalReq_Accept:
|
||||
token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
|
||||
if err2 != nil {
|
||||
return false, 207, err2.Error(), nil, nil
|
||||
}
|
||||
accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
|
||||
Token: token,
|
||||
LiveURL: liveURL,
|
||||
RoomID: payload.Accept.Invitation.RoomID,
|
||||
}}
|
||||
resp.Payload = &accept
|
||||
msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
|
||||
msg.SendID = payload.Accept.OpUserID
|
||||
msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
|
||||
msg.SessionType = payload.Accept.Invitation.SessionType
|
||||
if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
|
||||
switch payload.Accept.Invitation.SessionType {
|
||||
case constant.SingleChatType:
|
||||
msg.RecvID = payload.Accept.Invitation.InviterUserID
|
||||
case constant.GroupChatType:
|
||||
msg.GroupID = payload.Accept.Invitation.GroupID
|
||||
}
|
||||
} else {
|
||||
return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
|
||||
return true, 0, "", &resp, &msg
|
||||
case *open_im_sdk.SignalReq_HungUp:
|
||||
case *open_im_sdk.SignalReq_Reject:
|
||||
reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
|
||||
resp.Payload = &reject
|
||||
msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
|
||||
msg.SendID = payload.Reject.OpUserID
|
||||
msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
|
||||
msg.SessionType = payload.Reject.Invitation.SessionType
|
||||
if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
|
||||
switch payload.Reject.Invitation.SessionType {
|
||||
case constant.SingleChatType:
|
||||
msg.RecvID = payload.Reject.Invitation.InviterUserID
|
||||
case constant.GroupChatType:
|
||||
msg.GroupID = payload.Reject.Invitation.GroupID
|
||||
}
|
||||
} else {
|
||||
return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
|
||||
return true, 0, "", &resp, &msg
|
||||
}
|
||||
return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -24,15 +25,15 @@ type WServer struct {
|
||||
wsAddr string
|
||||
wsMaxConnNum int
|
||||
wsUpGrader *websocket.Upgrader
|
||||
wsConnToUser map[*UserConn]string
|
||||
wsUserToConn map[string]*UserConn
|
||||
wsConnToUser map[*UserConn]map[string]string
|
||||
wsUserToConn map[string]map[string]*UserConn
|
||||
}
|
||||
|
||||
func (ws *WServer) onInit(wsPort int) {
|
||||
ws.wsAddr = ":" + utils.IntToString(wsPort)
|
||||
ws.wsMaxConnNum = config.Config.LongConnSvr.WebsocketMaxConnNum
|
||||
ws.wsConnToUser = make(map[*UserConn]string)
|
||||
ws.wsUserToConn = make(map[string]*UserConn)
|
||||
ws.wsConnToUser = make(map[*UserConn]map[string]string)
|
||||
ws.wsUserToConn = make(map[string]map[string]*UserConn)
|
||||
ws.wsUpGrader = &websocket.Upgrader{
|
||||
HandshakeTimeout: time.Duration(config.Config.LongConnSvr.WebsocketTimeOut) * time.Second,
|
||||
ReadBufferSize: config.Config.LongConnSvr.WebsocketMaxMsgLen,
|
||||
@@ -74,7 +75,8 @@ func (ws *WServer) readMsg(conn *UserConn) {
|
||||
log.NewInfo("", "this is a pingMessage")
|
||||
}
|
||||
if err != nil {
|
||||
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn), "error", err)
|
||||
uid, platform := ws.getUserUid(conn)
|
||||
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
|
||||
ws.delUserConn(conn)
|
||||
return
|
||||
} else {
|
||||
@@ -91,39 +93,50 @@ func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
|
||||
return conn.WriteMessage(a, msg)
|
||||
|
||||
}
|
||||
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newConn *UserConn, token string) {
|
||||
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newConn *UserConn, token string, operationID string) {
|
||||
switch config.Config.MultiLoginPolicy {
|
||||
case constant.AllLoginButSameTermKick:
|
||||
if oldConn, ok := ws.wsUserToConn[genMapKey(uid, platformID)]; ok {
|
||||
log.NewDebug("", uid, platformID, "kick old conn")
|
||||
ws.sendKickMsg(oldConn, newConn)
|
||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||
if err != nil {
|
||||
log.NewError("", "get token from redis err", err.Error())
|
||||
return
|
||||
}
|
||||
if m == nil {
|
||||
log.NewError("", "get token from redis err", "m is nil")
|
||||
return
|
||||
}
|
||||
for k, _ := range m {
|
||||
if k != token {
|
||||
m[k] = constant.KickedToken
|
||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||
if oldConn, ok := oldConnMap[constant.PlatformIDToName(platformID)]; ok {
|
||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||
ws.sendKickMsg(oldConn, newConn)
|
||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
log.NewError(operationID, "get token from redis err", err.Error())
|
||||
return
|
||||
}
|
||||
if m == nil {
|
||||
log.NewError(operationID, "get token from redis err", "m is nil")
|
||||
return
|
||||
}
|
||||
for k, _ := range m {
|
||||
if k != token {
|
||||
m[k] = constant.KickedToken
|
||||
}
|
||||
}
|
||||
log.NewDebug(operationID, "get map is ", m)
|
||||
err = db.DB.SetTokenMapByUidPid(uid, platformID, m)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error())
|
||||
return
|
||||
}
|
||||
err = oldConn.Close()
|
||||
delete(oldConnMap, constant.PlatformIDToName(platformID))
|
||||
ws.wsUserToConn[uid] = oldConnMap
|
||||
if len(oldConnMap) == 0 {
|
||||
delete(ws.wsUserToConn, uid)
|
||||
}
|
||||
delete(ws.wsConnToUser, oldConn)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
|
||||
}
|
||||
|
||||
} else {
|
||||
log.NewWarn(operationID, "abnormal uid-conn ", uid, platformID, oldConnMap[constant.PlatformIDToName(platformID)])
|
||||
}
|
||||
log.NewDebug("get map is ", m)
|
||||
err = db.DB.SetTokenMapByUidPid(uid, platformID, m)
|
||||
if err != nil {
|
||||
log.NewError("", "SetTokenMapByUidPid err", err.Error())
|
||||
return
|
||||
}
|
||||
err = oldConn.Close()
|
||||
delete(ws.wsConnToUser, oldConn)
|
||||
if err != nil {
|
||||
log.NewError("", "conn close err", err.Error())
|
||||
}
|
||||
|
||||
} else {
|
||||
log.NewDebug("no other conn", ws.wsUserToConn)
|
||||
log.NewDebug(operationID, "no other conn", ws.wsUserToConn, uid, platformID)
|
||||
}
|
||||
|
||||
case constant.SingleTerminalLogin:
|
||||
@@ -149,61 +162,110 @@ func (ws *WServer) sendKickMsg(oldConn, newConn *UserConn) {
|
||||
}
|
||||
}
|
||||
func (ws *WServer) addUserConn(uid string, platformID int32, conn *UserConn, token string) {
|
||||
key := genMapKey(uid, platformID)
|
||||
rwLock.Lock()
|
||||
defer rwLock.Unlock()
|
||||
ws.MultiTerminalLoginChecker(uid, platformID, conn, token)
|
||||
ws.wsConnToUser[conn] = key
|
||||
ws.wsUserToConn[key] = conn
|
||||
log.WarnByKv("WS Add operation", "", "wsUser added", ws.wsUserToConn, "uid", uid, "online_num", len(ws.wsUserToConn))
|
||||
operationID := utils.OperationIDGenerator()
|
||||
ws.MultiTerminalLoginChecker(uid, platformID, conn, token, operationID)
|
||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
|
||||
oldConnMap[constant.PlatformIDToName(platformID)] = conn
|
||||
ws.wsUserToConn[uid] = oldConnMap
|
||||
log.Debug(operationID, "user not first come in, add conn ", uid, platformID, conn, oldConnMap)
|
||||
} else {
|
||||
i := make(map[string]*UserConn)
|
||||
i[constant.PlatformIDToName(platformID)] = conn
|
||||
ws.wsUserToConn[uid] = i
|
||||
log.Debug(operationID, "user first come in, new user, conn", uid, platformID, conn, ws.wsUserToConn[uid])
|
||||
}
|
||||
if oldStringMap, ok := ws.wsConnToUser[conn]; ok {
|
||||
oldStringMap[constant.PlatformIDToName(platformID)] = uid
|
||||
ws.wsConnToUser[conn] = oldStringMap
|
||||
} else {
|
||||
i := make(map[string]string)
|
||||
i[constant.PlatformIDToName(platformID)] = uid
|
||||
ws.wsConnToUser[conn] = i
|
||||
}
|
||||
count := 0
|
||||
for _, v := range ws.wsUserToConn {
|
||||
count = count + len(v)
|
||||
}
|
||||
log.Debug(operationID, "WS Add operation", "", "wsUser added", ws.wsUserToConn, "connection_uid", uid, "connection_platform", constant.PlatformIDToName(platformID), "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
|
||||
userCount = uint64(len(ws.wsUserToConn))
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) delUserConn(conn *UserConn) {
|
||||
rwLock.Lock()
|
||||
defer rwLock.Unlock()
|
||||
var uidPlatform string
|
||||
if uid, ok := ws.wsConnToUser[conn]; ok {
|
||||
uidPlatform = uid
|
||||
if _, ok = ws.wsUserToConn[uid]; ok {
|
||||
delete(ws.wsUserToConn, uid)
|
||||
log.WarnByKv("WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "uid", uid, "online_num", len(ws.wsUserToConn))
|
||||
} else {
|
||||
log.WarnByKv("uid not exist", "", "wsUser deleted", ws.wsUserToConn, "uid", uid, "online_num", len(ws.wsUserToConn))
|
||||
var platform, uid string
|
||||
if oldStringMap, ok := ws.wsConnToUser[conn]; ok {
|
||||
for k, v := range oldStringMap {
|
||||
platform = k
|
||||
uid = v
|
||||
}
|
||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
|
||||
delete(oldConnMap, platform)
|
||||
ws.wsUserToConn[uid] = oldConnMap
|
||||
if len(oldConnMap) == 0 {
|
||||
delete(ws.wsUserToConn, uid)
|
||||
}
|
||||
count := 0
|
||||
for _, v := range ws.wsUserToConn {
|
||||
count = count + len(v)
|
||||
}
|
||||
log.WarnByKv("WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
|
||||
} else {
|
||||
log.WarnByKv("WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn))
|
||||
}
|
||||
userCount = uint64(len(ws.wsUserToConn))
|
||||
delete(ws.wsConnToUser, conn)
|
||||
|
||||
}
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
log.ErrorByKv("close err", "", "uid", uidPlatform)
|
||||
log.ErrorByKv("close err", "", "uid", uid, "platform", platform)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) getUserConn(uid string) *UserConn {
|
||||
func (ws *WServer) getUserConn(uid string, platform string) *UserConn {
|
||||
rwLock.RLock()
|
||||
defer rwLock.RUnlock()
|
||||
if conn, ok := ws.wsUserToConn[uid]; ok {
|
||||
return conn
|
||||
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
||||
if conn, flag := connMap[platform]; flag {
|
||||
return conn
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (ws *WServer) getUserUid(conn *UserConn) string {
|
||||
func (ws *WServer) getSingleUserAllConn(uid string) map[string]*UserConn {
|
||||
rwLock.RLock()
|
||||
defer rwLock.RUnlock()
|
||||
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
||||
return connMap
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (ws *WServer) getUserUid(conn *UserConn) (uid, platform string) {
|
||||
rwLock.RLock()
|
||||
defer rwLock.RUnlock()
|
||||
|
||||
if uid, ok := ws.wsConnToUser[conn]; ok {
|
||||
return uid
|
||||
if stringMap, ok := ws.wsConnToUser[conn]; ok {
|
||||
for k, v := range stringMap {
|
||||
platform = k
|
||||
uid = v
|
||||
}
|
||||
return uid, platform
|
||||
}
|
||||
return ""
|
||||
return "", ""
|
||||
}
|
||||
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
|
||||
status := http.StatusUnauthorized
|
||||
query := r.URL.Query()
|
||||
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
|
||||
if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
|
||||
if ok, err, msg := token_verify.WsVerifyToken(query["token"][0], query["sendID"][0], query["platformID"][0]); !ok {
|
||||
e := err.(*constant.ErrInfo)
|
||||
log.ErrorByKv("Token verify failed", "", "query", query)
|
||||
log.ErrorByKv("Token verify failed", "", "query", query, msg)
|
||||
w.Header().Set("Sec-Websocket-Version", "13")
|
||||
http.Error(w, e.ErrMsg, int(e.ErrCode))
|
||||
return false
|
||||
@@ -217,7 +279,6 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
|
||||
http.Error(w, http.StatusText(status), status)
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
func genMapKey(uid string, platformID int32) string {
|
||||
return uid + " " + constant.PlatformIDToName(platformID)
|
||||
|
||||
@@ -2,24 +2,22 @@ package logic
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
)
|
||||
|
||||
func saveUserChat(uid string, pbMsg *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
||||
func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error {
|
||||
time := utils.GetCurrentTimestampByMill()
|
||||
seq, err := db.DB.IncrUserSeq(uid)
|
||||
if err != nil {
|
||||
log.NewError(pbMsg.OperationID, "data insert to redis err", err.Error(), pbMsg.String())
|
||||
log.NewError(msg.OperationID, "data insert to redis err", err.Error(), msg.String())
|
||||
return err
|
||||
}
|
||||
pbMsg.RecvSeq = seq
|
||||
log.NewInfo(pbMsg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
||||
return db.DB.SaveUserChat(uid, pbMsg.SendTime, pbMsg)
|
||||
}
|
||||
|
||||
func getGroupList(groupID string) ([]string, error) {
|
||||
return im_mysql_model.SelectGroupList(groupID)
|
||||
msg.MsgData.Seq = uint32(seq)
|
||||
pbSaveData := pbMsg.MsgDataToDB{}
|
||||
pbSaveData.MsgData = msg.MsgData
|
||||
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
||||
return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/statistics"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/Shopify/sarama"
|
||||
@@ -20,9 +21,14 @@ type fcb func(msg []byte, msgKey string)
|
||||
type HistoryConsumerHandler struct {
|
||||
msgHandle map[string]fcb
|
||||
historyConsumerGroup *kfk.MConsumerGroup
|
||||
singleMsgCount uint64
|
||||
groupMsgCount uint64
|
||||
}
|
||||
|
||||
func (mc *HistoryConsumerHandler) Init() {
|
||||
statistics.NewStatistics(&mc.singleMsgCount, config.Config.ModuleName.MsgTransferName, "singleMsgCount insert to mongo ", 300)
|
||||
statistics.NewStatistics(&mc.groupMsgCount, config.Config.ModuleName.MsgTransferName, "groupMsgCount insert to mongo ", 300)
|
||||
|
||||
mc.msgHandle = make(map[string]fcb)
|
||||
mc.msgHandle[config.Config.Kafka.Ws2mschat.Topic] = mc.handleChatWs2Mongo
|
||||
mc.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V0_10_2_0,
|
||||
@@ -32,80 +38,53 @@ func (mc *HistoryConsumerHandler) Init() {
|
||||
}
|
||||
|
||||
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
||||
log.InfoByKv("chat come mongo!!!", "", "chat", string(msg))
|
||||
time := utils.GetCurrentTimestampByNano()
|
||||
pbData := pbMsg.WSToMsgSvrChatMsg{}
|
||||
err := proto.Unmarshal(msg, &pbData)
|
||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.ErrorByKv("msg_transfer Unmarshal chat err", "", "chat", string(msg), "err", err.Error())
|
||||
log.Error("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
||||
return
|
||||
}
|
||||
pbSaveData := pbMsg.MsgSvrToPushSvrChatMsg{}
|
||||
pbSaveData.SendID = pbData.SendID
|
||||
pbSaveData.SenderNickName = pbData.SenderNickName
|
||||
pbSaveData.SenderFaceURL = pbData.SenderFaceURL
|
||||
pbSaveData.ClientMsgID = pbData.ClientMsgID
|
||||
pbSaveData.SendTime = pbData.SendTime
|
||||
pbSaveData.Content = pbData.Content
|
||||
pbSaveData.MsgFrom = pbData.MsgFrom
|
||||
pbSaveData.ContentType = pbData.ContentType
|
||||
pbSaveData.SessionType = pbData.SessionType
|
||||
pbSaveData.MsgID = pbData.MsgID
|
||||
pbSaveData.OperationID = pbData.OperationID
|
||||
pbSaveData.RecvID = pbData.RecvID
|
||||
pbSaveData.PlatformID = pbData.PlatformID
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
operationID := msgFromMQ.OperationID
|
||||
log.NewInfo(operationID, "msg come mongo!!!", "", "msg", string(msg))
|
||||
//Control whether to store offline messages (mongo)
|
||||
isHistory := utils.GetSwitchFromOptions(options, "history")
|
||||
isHistory := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsHistory)
|
||||
//Control whether to store history messages (mysql)
|
||||
isPersist := utils.GetSwitchFromOptions(options, "persistent")
|
||||
switch pbData.SessionType {
|
||||
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
|
||||
isSenderSync := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsSenderSync)
|
||||
switch msgFromMQ.MsgData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = SingleChatType", isHistory, isPersist)
|
||||
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = SingleChatType", isHistory, isPersist)
|
||||
if isHistory {
|
||||
if msgKey == pbSaveData.RecvID {
|
||||
err := saveUserChat(pbData.RecvID, &pbSaveData)
|
||||
if err != nil {
|
||||
log.NewError(pbSaveData.OperationID, "single data insert to mongo err", err.Error(), pbSaveData.String())
|
||||
return
|
||||
}
|
||||
|
||||
} else if msgKey == pbSaveData.SendID {
|
||||
err := saveUserChat(pbData.SendID, &pbSaveData)
|
||||
if err != nil {
|
||||
log.NewError(pbSaveData.OperationID, "single data insert to mongo err", err.Error(), pbSaveData.String())
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.NewDebug(pbSaveData.OperationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||
}
|
||||
if msgKey == pbSaveData.RecvID {
|
||||
pbSaveData.Options = pbData.Options
|
||||
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
||||
go sendMessageToPush(&pbSaveData)
|
||||
log.NewDebug(pbSaveData.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||
}
|
||||
|
||||
case constant.GroupChatType:
|
||||
log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = GroupChatType", isHistory, isPersist)
|
||||
if isHistory {
|
||||
uidAndGroupID := strings.Split(pbData.RecvID, " ")
|
||||
err := saveUserChat(uidAndGroupID[0], &pbSaveData)
|
||||
err := saveUserChat(msgKey, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.NewError(pbSaveData.OperationID, "group data insert to mongo err", pbSaveData.String(), uidAndGroupID[0], err.Error())
|
||||
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
|
||||
return
|
||||
}
|
||||
mc.singleMsgCount++
|
||||
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||
}
|
||||
pbSaveData.Options = pbData.Options
|
||||
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
||||
go sendMessageToPush(&pbSaveData)
|
||||
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
|
||||
} else {
|
||||
go sendMessageToPush(&msgFromMQ, msgKey)
|
||||
}
|
||||
log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||
case constant.GroupChatType:
|
||||
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = GroupChatType", isHistory, isPersist)
|
||||
if isHistory {
|
||||
err := saveUserChat(msgFromMQ.MsgData.RecvID, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "group data insert to mongo err", msgFromMQ.String(), msgFromMQ.MsgData.RecvID, err.Error())
|
||||
return
|
||||
}
|
||||
mc.groupMsgCount++
|
||||
}
|
||||
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
|
||||
default:
|
||||
log.NewError(pbSaveData.OperationID, "SessionType error", pbSaveData.String())
|
||||
log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String())
|
||||
return
|
||||
}
|
||||
log.NewDebug(pbSaveData.OperationID, "msg_transfer handle topic data to database success...", pbSaveData.String())
|
||||
log.NewDebug(msgFromMQ.OperationID, "msg_transfer handle topic data to database success...", msgFromMQ.String())
|
||||
}
|
||||
|
||||
func (HistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
@@ -113,50 +92,35 @@ func (HistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { ret
|
||||
func (mc *HistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||
claim sarama.ConsumerGroupClaim) error {
|
||||
for msg := range claim.Messages() {
|
||||
log.InfoByKv("kafka get info to mongo", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "chat", string(msg.Value))
|
||||
log.InfoByKv("kafka get info to mongo", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
|
||||
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
||||
sess.MarkMessage(msg, "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func sendMessageToPush(message *pbMsg.MsgSvrToPushSvrChatMsg) {
|
||||
log.InfoByKv("msg_transfer send message to push", message.OperationID, "message", message.String())
|
||||
msg := pbPush.PushMsgReq{}
|
||||
msg.OperationID = message.OperationID
|
||||
msg.PlatformID = message.PlatformID
|
||||
msg.Content = message.Content
|
||||
msg.ContentType = message.ContentType
|
||||
msg.SessionType = message.SessionType
|
||||
msg.RecvID = message.RecvID
|
||||
msg.SendID = message.SendID
|
||||
msg.SenderNickName = message.SenderNickName
|
||||
msg.SenderFaceURL = message.SenderFaceURL
|
||||
msg.ClientMsgID = message.ClientMsgID
|
||||
msg.MsgFrom = message.MsgFrom
|
||||
msg.Options = message.Options
|
||||
msg.RecvSeq = message.RecvSeq
|
||||
msg.SendTime = message.SendTime
|
||||
msg.MsgID = message.MsgID
|
||||
msg.OfflineInfo = message.OfflineInfo
|
||||
func sendMessageToPush(message *pbMsg.MsgDataToMQ, pushToUserID string) {
|
||||
log.Info(message.OperationID, "msg_transfer send message to push", "message", message.String())
|
||||
rpcPushMsg := pbPush.PushMsgReq{OperationID: message.OperationID, MsgData: message.MsgData, PushToUserID: pushToUserID}
|
||||
mqPushMsg := pbMsg.PushMsgDataToMQ{OperationID: message.OperationID, MsgData: message.MsgData, PushToUserID: pushToUserID}
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("rpc dial failed", msg.OperationID, "push data", msg.String())
|
||||
pid, offset, err := producer.SendMessage(message)
|
||||
log.Error(rpcPushMsg.OperationID, "rpc dial failed", "push data", rpcPushMsg.String())
|
||||
pid, offset, err := producer.SendMessage(&mqPushMsg)
|
||||
if err != nil {
|
||||
log.ErrorByKv("kafka send failed", msg.OperationID, "send data", message.String(), "pid", pid, "offset", offset, "err", err.Error())
|
||||
log.Error(mqPushMsg.OperationID, "kafka send failed", "send data", message.String(), "pid", pid, "offset", offset, "err", err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
msgClient := pbPush.NewPushMsgServiceClient(grpcConn)
|
||||
_, err := msgClient.PushMsg(context.Background(), &msg)
|
||||
_, err := msgClient.PushMsg(context.Background(), &rpcPushMsg)
|
||||
if err != nil {
|
||||
log.ErrorByKv("rpc send failed", msg.OperationID, "push data", msg.String(), "err", err.Error())
|
||||
pid, offset, err := producer.SendMessage(message)
|
||||
log.Error(rpcPushMsg.OperationID, "rpc send failed", rpcPushMsg.OperationID, "push data", rpcPushMsg.String(), "err", err.Error())
|
||||
pid, offset, err := producer.SendMessage(&mqPushMsg)
|
||||
if err != nil {
|
||||
log.ErrorByKv("kafka send failed", msg.OperationID, "send data", message.String(), "pid", pid, "offset", offset, "err", err.Error())
|
||||
log.Error("kafka send failed", mqPushMsg.OperationID, "send data", mqPushMsg.String(), "pid", pid, "offset", offset, "err", err.Error())
|
||||
}
|
||||
} else {
|
||||
log.InfoByKv("rpc send success", msg.OperationID, "push data", msg.String())
|
||||
log.Info("rpc send success", rpcPushMsg.OperationID, "push data", rpcPushMsg.String())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type PersistentConsumerHandler struct {
|
||||
@@ -32,30 +31,29 @@ func (pc *PersistentConsumerHandler) Init() {
|
||||
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql)
|
||||
|
||||
}
|
||||
|
||||
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
|
||||
log.InfoByKv("chat come here mysql!!!", "", "chat", string(msg))
|
||||
pbData := pbMsg.WSToMsgSvrChatMsg{}
|
||||
err := proto.Unmarshal(msg, &pbData)
|
||||
log.NewInfo("msg come here mysql!!!", "", "msg", string(msg))
|
||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.ErrorByKv("msg_transfer Unmarshal chat err", "", "chat", string(msg), "err", err.Error())
|
||||
log.ErrorByKv("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
||||
return
|
||||
}
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
//Control whether to store history messages (mysql)
|
||||
isPersist := utils.GetSwitchFromOptions(options, "persistent")
|
||||
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
|
||||
//Only process receiver data
|
||||
if isPersist {
|
||||
if msgKey == pbData.RecvID && pbData.SessionType == constant.SingleChatType {
|
||||
log.InfoByKv("msg_transfer chat persisting", pbData.OperationID)
|
||||
if err = im_mysql_msg_model.InsertMessageToChatLog(pbData); err != nil {
|
||||
log.ErrorByKv("Message insert failed", pbData.OperationID, "err", err.Error(), "chat", pbData.String())
|
||||
if msgKey == msgFromMQ.MsgData.RecvID && msgFromMQ.MsgData.SessionType == constant.SingleChatType {
|
||||
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
|
||||
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
|
||||
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
|
||||
return
|
||||
}
|
||||
} else if pbData.SessionType == constant.GroupChatType && msgKey == "0" {
|
||||
pbData.RecvID = strings.Split(pbData.RecvID, " ")[1]
|
||||
log.InfoByKv("msg_transfer chat persisting", pbData.OperationID)
|
||||
if err = im_mysql_msg_model.InsertMessageToChatLog(pbData); err != nil {
|
||||
log.ErrorByKv("Message insert failed", pbData.OperationID, "err", err.Error(), "chat", pbData.String())
|
||||
} else if msgFromMQ.MsgData.SessionType == constant.GroupChatType && msgKey == msgFromMQ.MsgData.SendID {
|
||||
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
|
||||
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
|
||||
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -67,7 +65,7 @@ func (PersistentConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error {
|
||||
func (pc *PersistentConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||
claim sarama.ConsumerGroupClaim) error {
|
||||
for msg := range claim.Messages() {
|
||||
log.InfoByKv("kafka get info to mysql", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "chat", string(msg.Value))
|
||||
log.InfoByKv("kafka get info to mysql", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
|
||||
pc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
||||
sess.MarkMessage(msg, "")
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ import (
|
||||
type JPushResp struct {
|
||||
}
|
||||
|
||||
func JGAccountListPush(accounts []string, content, detailContent, platform string) ([]byte, error) {
|
||||
func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) {
|
||||
|
||||
var pf requestBody.Platform
|
||||
_ = pf.SetPlatform(platform)
|
||||
var au requestBody.Audience
|
||||
au.SetAlias(accounts)
|
||||
var no requestBody.Notification
|
||||
no.SetAlert(content, platform)
|
||||
no.SetAlert(alert, platform)
|
||||
var me requestBody.Message
|
||||
me.SetMsgContent(detailContent)
|
||||
var o requestBody.Options
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/statistics"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -18,6 +20,7 @@ var (
|
||||
pushCh PushConsumerHandler
|
||||
pushTerminal []int32
|
||||
producer *kafka.Producer
|
||||
count uint64
|
||||
)
|
||||
|
||||
func Init(rpcPort int) {
|
||||
@@ -28,6 +31,7 @@ func Init(rpcPort int) {
|
||||
}
|
||||
func init() {
|
||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
||||
statistics.NewStatistics(&count, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", 300), 300)
|
||||
}
|
||||
|
||||
func Run() {
|
||||
|
||||
@@ -11,8 +11,7 @@ import (
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
@@ -33,28 +32,13 @@ func (ms *PushConsumerHandler) Init() {
|
||||
}
|
||||
func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
|
||||
log.InfoByKv("msg come from kafka And push!!!", "", "msg", string(msg))
|
||||
pbData := pbChat.MsgSvrToPushSvrChatMsg{}
|
||||
if err := proto.Unmarshal(msg, &pbData); err != nil {
|
||||
msgFromMQ := pbChat.PushMsgDataToMQ{}
|
||||
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
||||
log.ErrorByKv("push Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
||||
return
|
||||
}
|
||||
sendPbData := pbRelay.MsgToUserReq{}
|
||||
sendPbData.SendTime = pbData.SendTime
|
||||
sendPbData.OperationID = pbData.OperationID
|
||||
sendPbData.ServerMsgID = pbData.MsgID
|
||||
sendPbData.MsgFrom = pbData.MsgFrom
|
||||
sendPbData.ContentType = pbData.ContentType
|
||||
sendPbData.SessionType = pbData.SessionType
|
||||
sendPbData.RecvID = pbData.RecvID
|
||||
sendPbData.Content = pbData.Content
|
||||
sendPbData.SendID = pbData.SendID
|
||||
sendPbData.SenderNickName = pbData.SenderNickName
|
||||
sendPbData.SenderFaceURL = pbData.SenderFaceURL
|
||||
sendPbData.ClientMsgID = pbData.ClientMsgID
|
||||
sendPbData.PlatformID = pbData.PlatformID
|
||||
sendPbData.RecvSeq = pbData.RecvSeq
|
||||
//Call push module to send message to the user
|
||||
MsgToUser(&sendPbData, pbData.OfflineInfo, utils.JsonStringToMap(pbData.Options))
|
||||
MsgToUser((*pbPush.PushMsgReq)(&msgFromMQ))
|
||||
}
|
||||
func (PushConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
func (PushConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
@@ -49,23 +48,8 @@ func (r *RPCServer) run() {
|
||||
}
|
||||
}
|
||||
func (r *RPCServer) PushMsg(_ context.Context, pbData *pbPush.PushMsgReq) (*pbPush.PushMsgResp, error) {
|
||||
sendPbData := pbRelay.MsgToUserReq{}
|
||||
sendPbData.SendTime = pbData.SendTime
|
||||
sendPbData.OperationID = pbData.OperationID
|
||||
sendPbData.ServerMsgID = pbData.MsgID
|
||||
sendPbData.MsgFrom = pbData.MsgFrom
|
||||
sendPbData.ContentType = pbData.ContentType
|
||||
sendPbData.SenderNickName = pbData.SenderNickName
|
||||
sendPbData.SenderFaceURL = pbData.SenderFaceURL
|
||||
sendPbData.ClientMsgID = pbData.ClientMsgID
|
||||
sendPbData.SessionType = pbData.SessionType
|
||||
sendPbData.RecvID = pbData.RecvID
|
||||
sendPbData.Content = pbData.Content
|
||||
sendPbData.SendID = pbData.SendID
|
||||
sendPbData.PlatformID = pbData.PlatformID
|
||||
sendPbData.RecvSeq = pbData.RecvSeq
|
||||
//Call push module to send message to the user
|
||||
MsgToUser(&sendPbData, pbData.OfflineInfo, utils.JsonStringToMap(pbData.Options))
|
||||
MsgToUser(pbData)
|
||||
return &pbPush.PushMsgResp{
|
||||
ResultCode: 0,
|
||||
}, nil
|
||||
|
||||
@@ -8,13 +8,11 @@ package logic
|
||||
|
||||
import (
|
||||
push "Open_IM/internal/push/jpush"
|
||||
rpcChat "Open_IM/internal/rpc/chat"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -26,7 +24,7 @@ type OpenIMContent struct {
|
||||
SessionType int `json:"sessionType"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Seq int64 `json:"seq"`
|
||||
Seq uint32 `json:"seq"`
|
||||
}
|
||||
type AtContent struct {
|
||||
Text string `json:"text"`
|
||||
@@ -34,47 +32,51 @@ type AtContent struct {
|
||||
IsAtSelf bool `json:"isAtSelf"`
|
||||
}
|
||||
|
||||
func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo string, Options map[string]int32) {
|
||||
func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var wsResult []*pbRelay.SingleMsgToUser
|
||||
isOfflinePush := utils.GetSwitchFromOptions(Options, "offlinePush")
|
||||
log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData, Options, isOfflinePush)
|
||||
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
log.Debug("Get msg from msg_transfer And push msg", pushMsg.OperationID, "PushData", pushMsg.String())
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
//Online push message
|
||||
log.InfoByKv("test", sendPbData.OperationID, "len grpc", len(grpcCons), "data", sendPbData)
|
||||
log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||
for _, v := range grpcCons {
|
||||
msgClient := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
reply, err := msgClient.MsgToUser(context.Background(), sendPbData)
|
||||
reply, err := msgClient.OnlinePushMsg(context.Background(), &pbRelay.OnlinePushMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserID: pushMsg.PushToUserID})
|
||||
if err != nil {
|
||||
log.InfoByKv("push data to client rpc err", sendPbData.OperationID, "err", err)
|
||||
log.InfoByKv("push data to client rpc err", pushMsg.OperationID, "err", err)
|
||||
continue
|
||||
}
|
||||
if reply != nil && reply.Resp != nil {
|
||||
wsResult = append(wsResult, reply.Resp...)
|
||||
}
|
||||
}
|
||||
log.InfoByKv("push_result", sendPbData.OperationID, "result", wsResult, "sendData", sendPbData)
|
||||
if sendPbData.ContentType != constant.Typing && sendPbData.ContentType != constant.HasReadReceipt {
|
||||
if isOfflinePush {
|
||||
for _, v := range wsResult {
|
||||
if v.ResultCode == 0 {
|
||||
continue
|
||||
}
|
||||
//supported terminal
|
||||
for _, t := range pushTerminal {
|
||||
if v.RecvPlatFormID == t {
|
||||
//Use offline push messaging
|
||||
var UIDList []string
|
||||
UIDList = append(UIDList, v.RecvID)
|
||||
customContent := OpenIMContent{
|
||||
SessionType: int(sendPbData.SessionType),
|
||||
From: sendPbData.SendID,
|
||||
To: sendPbData.RecvID,
|
||||
Seq: sendPbData.RecvSeq,
|
||||
}
|
||||
bCustomContent, _ := json.Marshal(customContent)
|
||||
jsonCustomContent := string(bCustomContent)
|
||||
var content string
|
||||
switch sendPbData.ContentType {
|
||||
log.InfoByKv("push_result", pushMsg.OperationID, "result", wsResult, "sendData", pushMsg.MsgData)
|
||||
count++
|
||||
if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID {
|
||||
for _, v := range wsResult {
|
||||
if v.ResultCode == 0 {
|
||||
continue
|
||||
}
|
||||
//supported terminal
|
||||
for _, t := range pushTerminal {
|
||||
if v.RecvPlatFormID == t {
|
||||
//Use offline push messaging
|
||||
var UIDList []string
|
||||
UIDList = append(UIDList, v.RecvID)
|
||||
customContent := OpenIMContent{
|
||||
SessionType: int(pushMsg.MsgData.SessionType),
|
||||
From: pushMsg.MsgData.SendID,
|
||||
To: pushMsg.MsgData.RecvID,
|
||||
Seq: pushMsg.MsgData.Seq,
|
||||
}
|
||||
bCustomContent, _ := json.Marshal(customContent)
|
||||
jsonCustomContent := string(bCustomContent)
|
||||
var content string
|
||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||
|
||||
} else {
|
||||
switch pushMsg.MsgData.ContentType {
|
||||
case constant.Text:
|
||||
content = constant.ContentType2PushContent[constant.Text]
|
||||
case constant.Picture:
|
||||
@@ -87,7 +89,7 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo string, Options map
|
||||
content = constant.ContentType2PushContent[constant.File]
|
||||
case constant.AtText:
|
||||
a := AtContent{}
|
||||
_ = utils.JsonStringToStruct(sendPbData.Content, &a)
|
||||
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||
if utils.IsContain(v.RecvID, a.AtUserList) {
|
||||
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||
} else {
|
||||
@@ -96,60 +98,60 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo string, Options map
|
||||
default:
|
||||
content = constant.ContentType2PushContent[constant.Common]
|
||||
}
|
||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
||||
if err != nil {
|
||||
log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), constant.PlatformIDToName(t))
|
||||
} else {
|
||||
log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, constant.PlatformIDToName(t))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error(), constant.PlatformIDToName(t))
|
||||
} else {
|
||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", string(pushResult), pushMsg.MsgData, constant.PlatformIDToName(t))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {
|
||||
m.MsgID = rpcChat.GetMsgID(m.SendID)
|
||||
m.ClientMsgID = m.MsgID
|
||||
switch m.SessionType {
|
||||
case constant.SingleChatType:
|
||||
sendMsgToKafka(m, m.SendID, "msgKey--sendID")
|
||||
sendMsgToKafka(m, m.RecvID, "msgKey--recvID")
|
||||
case constant.GroupChatType:
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
req := &pbGroup.GetGroupAllMemberReq{
|
||||
GroupID: m.RecvID,
|
||||
Token: config.Config.Secret,
|
||||
OperationID: m.OperationID,
|
||||
}
|
||||
reply, err := client.GetGroupAllMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(m.Token, m.OperationID, "rpc getGroupInfo failed, err = %s", err.Error())
|
||||
return
|
||||
}
|
||||
if reply.ErrorCode != 0 {
|
||||
log.Error(m.Token, m.OperationID, "rpc getGroupInfo failed, err = %s", reply.ErrorMsg)
|
||||
return
|
||||
}
|
||||
groupID := m.RecvID
|
||||
for i, v := range reply.MemberList {
|
||||
m.RecvID = v.UserId + " " + groupID
|
||||
sendMsgToKafka(m, utils.IntToString(i), "msgKey--recvID+\" \"+groupID")
|
||||
}
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func sendMsgToKafka(m *pbChat.WSToMsgSvrChatMsg, key string, flag string) {
|
||||
pid, offset, err := producer.SendMessage(m, key)
|
||||
if err != nil {
|
||||
log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), flag, key)
|
||||
}
|
||||
|
||||
}
|
||||
//func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {
|
||||
// m.MsgID = rpcChat.GetMsgID(m.SendID)
|
||||
// m.ClientMsgID = m.MsgID
|
||||
// switch m.SessionType {
|
||||
// case constant.SingleChatType:
|
||||
// sendMsgToKafka(m, m.SendID, "msgKey--sendID")
|
||||
// sendMsgToKafka(m, m.RecvID, "msgKey--recvID")
|
||||
// case constant.GroupChatType:
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
// client := pbGroup.NewGroupClient(etcdConn)
|
||||
// req := &pbGroup.Req{
|
||||
// GroupID: m.RecvID,
|
||||
// Token: config.Config.Secret,
|
||||
// OperationID: m.OperationID,
|
||||
// }
|
||||
// reply, err := client.(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.Error(m.Token, m.OperationID, "rpc getGroupInfo failed, err = %s", err.Error())
|
||||
// return
|
||||
// }
|
||||
// if reply.ErrorCode != 0 {
|
||||
// log.Error(m.Token, m.OperationID, "rpc getGroupInfo failed, err = %s", reply.ErrorMsg)
|
||||
// return
|
||||
// }
|
||||
// groupID := m.RecvID
|
||||
// for i, v := range reply.MemberList {
|
||||
// m.RecvID = v.UserId + " " + groupID
|
||||
// sendMsgToKafka(m, utils.IntToString(i), "msgKey--recvID+\" \"+groupID")
|
||||
// }
|
||||
// default:
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func sendMsgToKafka(m *pbChat.WSToMsgSvrChatMsg, key string, flag string) {
|
||||
// pid, offset, err := producer.SendMessage(m, key)
|
||||
// if err != nil {
|
||||
// log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), flag, key)
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package admin_cms
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type adminCMSServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewAdminCMSServer(port int) *adminCMSServer {
|
||||
log.NewPrivateLog("AdminCMS")
|
||||
return &adminCMSServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAdminCMSName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) Run() {
|
||||
log.NewInfo("0", "AdminCMS rpc start ")
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "listen network success, ", registerAddress, listener)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbAdminCMS.RegisterAdminCMSServer(srv, s)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
return
|
||||
}
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "message cms rpc success")
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.AdminLoginResp{}
|
||||
for i, adminID := range config.Config.Manager.AppManagerUid{
|
||||
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
||||
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
||||
}
|
||||
resp.Token = token
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if resp.Token == "" {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"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/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) {
|
||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||
var user db.User
|
||||
utils.CopyStructFields(&user, req.UserInfo)
|
||||
if req.UserInfo.Birth != 0 {
|
||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||
}
|
||||
err := imdb.UserRegister(user)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "UserRegister failed ", err.Error(), user)
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "rpc UserRegister return")
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
|
||||
_, err := imdb.GetUserByUserID(req.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.FromUserID)
|
||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, req.Platform)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CreateToken failed ", err.Error(), req.FromUserID, req.Platform)
|
||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "rpc UserToken return ", tokens, expTime)
|
||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
||||
}
|
||||
|
||||
type rpcAuth struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewRpcAuthServer(port int) *rpcAuth {
|
||||
log.NewPrivateLog("auth")
|
||||
return &rpcAuth{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (rpc *rpcAuth) Run() {
|
||||
log.NewInfo("0", "rpc auth start...")
|
||||
|
||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.NewError("0", "listen network failed ", err.Error(), address)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "listen network success, ", address, listener)
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
|
||||
//service registers with etcd
|
||||
pbAuth.RegisterAuthServer(srv, rpc)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error(),
|
||||
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "RegisterAuthServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "rpc auth ok")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package auth
|
||||
@@ -1,62 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"Open_IM/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type rpcAuth struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewRpcAuthServer(port int) *rpcAuth {
|
||||
log.NewPrivateLog("auth")
|
||||
return &rpcAuth{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (rpc *rpcAuth) Run() {
|
||||
log.Info("", "", "rpc get_token init...")
|
||||
|
||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
||||
return
|
||||
}
|
||||
log.Info("", "", "listen network success, address = %s", address)
|
||||
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
|
||||
//service registers with etcd
|
||||
|
||||
pbAuth.RegisterAuthServer(srv, rpc)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.Info("", "", "rpc get_token fail, err = %s", err.Error())
|
||||
return
|
||||
}
|
||||
log.Info("", "", "rpc get_token init success")
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (rpc *rpcAuth) UserRegister(_ context.Context, pb *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) {
|
||||
log.Info("", "", "rpc user_register start, [data: %s]", pb.String())
|
||||
|
||||
//if len(pb.UID) == 0 {
|
||||
// pb.UID = utils.GenID()
|
||||
//}
|
||||
if err := im_mysql_model.UserRegister(pb); err != nil {
|
||||
log.Error("", "", "rpc user_register error, [data: %s] [err: %s]", pb.String(), err.Error())
|
||||
return &pbAuth.UserRegisterResp{Success: false}, err
|
||||
}
|
||||
log.Info("", "", "rpc user_register success return")
|
||||
|
||||
return &pbAuth.UserRegisterResp{Success: true}, nil
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (rpc *rpcAuth) UserToken(_ context.Context, pb *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||
log.Info("", "", "rpc user_token call start..., [pbTokenReq: %s]", pb.String())
|
||||
|
||||
_, err := im_mysql_model.FindUserByUID(pb.UID)
|
||||
if err != nil {
|
||||
log.Error("", "", "rpc user_token call..., im_mysql_model.AppServerFindFromUserByUserID fail [uid: %s] [err: %s]", pb.UID, err.Error())
|
||||
return &pbAuth.UserTokenResp{ErrCode: 500, ErrMsg: err.Error()}, err
|
||||
}
|
||||
log.Info("", "", "rpc user_token call..., im_mysql_model.AppServerFindFromUserByUserID")
|
||||
|
||||
tokens, expTime, err := token_verify.CreateToken(pb.UID, pb.Platform)
|
||||
if err != nil {
|
||||
log.Error("", "", "rpc user_token call..., utils.CreateToken fail [uid: %s] [err: %s]", pb.UID, err.Error())
|
||||
return &pbAuth.UserTokenResp{ErrCode: 500, ErrMsg: err.Error()}, err
|
||||
}
|
||||
log.Info("", "", "rpc user_token success return, [uid: %s] [tokens: %s]", pb.UID, tokens)
|
||||
|
||||
return &pbAuth.UserTokenResp{Token: tokens, ExpiredTime: expTime}, nil
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
)
|
||||
|
||||
func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeqReq) (*pbMsg.GetMaxAndMinSeqResp, error) {
|
||||
log.InfoByKv("rpc getMaxAndMinSeq is arriving", in.OperationID, in.String())
|
||||
//seq, err := model.GetBiggestSeqFromReceive(in.UserID)
|
||||
maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID)
|
||||
minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
|
||||
resp := new(pbMsg.GetMaxAndMinSeqResp)
|
||||
if err1 == nil {
|
||||
resp.MaxSeq = maxSeq
|
||||
} else if err1 == redis.ErrNil {
|
||||
resp.MaxSeq = 0
|
||||
} else {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error())
|
||||
resp.MaxSeq = -1
|
||||
resp.ErrCode = 200
|
||||
resp.ErrMsg = "redis get err"
|
||||
}
|
||||
if err2 == nil {
|
||||
resp.MinSeq = minSeq
|
||||
} else if err2 == redis.ErrNil {
|
||||
resp.MinSeq = 0
|
||||
} else {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error())
|
||||
resp.MinSeq = -1
|
||||
resp.ErrCode = 201
|
||||
resp.ErrMsg = "redis get err"
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (rpc *rpcChat) PullMessage(_ context.Context, in *pbMsg.PullMessageReq) (*pbMsg.PullMessageResp, error) {
|
||||
log.InfoByKv("rpc pullMessage is arriving", in.OperationID, "args", in.String())
|
||||
resp := new(pbMsg.PullMessageResp)
|
||||
var respSingleMsgFormat []*pbMsg.GatherFormat
|
||||
var respGroupMsgFormat []*pbMsg.GatherFormat
|
||||
SingleMsgFormat, GroupMsgFormat, MaxSeq, MinSeq, err := commonDB.DB.GetMsgBySeqRange(in.UserID, in.SeqBegin, in.SeqEnd)
|
||||
if err != nil {
|
||||
log.ErrorByKv("pullMsg data error", in.OperationID, in.String())
|
||||
resp.ErrCode = 1
|
||||
resp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
respSingleMsgFormat = singleMsgHandleByUser(SingleMsgFormat, in.UserID)
|
||||
respGroupMsgFormat = groupMsgHandleByUser(GroupMsgFormat)
|
||||
return &pbMsg.PullMessageResp{
|
||||
ErrCode: 0,
|
||||
ErrMsg: "",
|
||||
MaxSeq: MaxSeq,
|
||||
MinSeq: MinSeq,
|
||||
SingleUserMsg: respSingleMsgFormat,
|
||||
GroupUserMsg: respGroupMsgFormat,
|
||||
}, nil
|
||||
}
|
||||
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *pbMsg.PullMessageBySeqListReq) (*pbMsg.PullMessageResp, error) {
|
||||
log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String())
|
||||
resp := new(pbMsg.PullMessageResp)
|
||||
var respSingleMsgFormat []*pbMsg.GatherFormat
|
||||
var respGroupMsgFormat []*pbMsg.GatherFormat
|
||||
SingleMsgFormat, GroupMsgFormat, MaxSeq, MinSeq, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
|
||||
resp.ErrCode = 1
|
||||
resp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
respSingleMsgFormat = singleMsgHandleByUser(SingleMsgFormat, in.UserID)
|
||||
respGroupMsgFormat = groupMsgHandleByUser(GroupMsgFormat)
|
||||
return &pbMsg.PullMessageResp{
|
||||
ErrCode: 0,
|
||||
ErrMsg: "",
|
||||
MaxSeq: MaxSeq,
|
||||
MinSeq: MinSeq,
|
||||
SingleUserMsg: respSingleMsgFormat,
|
||||
GroupUserMsg: respGroupMsgFormat,
|
||||
}, nil
|
||||
}
|
||||
func singleMsgHandleByUser(allMsg []*pbMsg.MsgFormat, ownerId string) []*pbMsg.GatherFormat {
|
||||
var userid string
|
||||
var respMsgFormat []*pbMsg.GatherFormat
|
||||
m := make(map[string]MsgFormats)
|
||||
//Gather messages in the dimension of users
|
||||
for _, v := range allMsg {
|
||||
if v.RecvID != ownerId {
|
||||
userid = v.RecvID
|
||||
} else {
|
||||
userid = v.SendID
|
||||
}
|
||||
if value, ok := m[userid]; !ok {
|
||||
var t MsgFormats
|
||||
m[userid] = append(t, v)
|
||||
} else {
|
||||
m[userid] = append(value, v)
|
||||
}
|
||||
}
|
||||
//Return in pb format
|
||||
for user, msg := range m {
|
||||
tempUserMsg := new(pbMsg.GatherFormat)
|
||||
tempUserMsg.ID = user
|
||||
tempUserMsg.List = msg
|
||||
sort.Sort(msg)
|
||||
respMsgFormat = append(respMsgFormat, tempUserMsg)
|
||||
}
|
||||
return respMsgFormat
|
||||
}
|
||||
func groupMsgHandleByUser(allMsg []*pbMsg.MsgFormat) []*pbMsg.GatherFormat {
|
||||
var respMsgFormat []*pbMsg.GatherFormat
|
||||
m := make(map[string]MsgFormats)
|
||||
//Gather messages in the dimension of users
|
||||
for _, v := range allMsg {
|
||||
//Get group ID
|
||||
groupID := strings.Split(v.RecvID, " ")[1]
|
||||
if value, ok := m[groupID]; !ok {
|
||||
var t MsgFormats
|
||||
m[groupID] = append(t, v)
|
||||
} else {
|
||||
m[groupID] = append(value, v)
|
||||
}
|
||||
|
||||
}
|
||||
//Return in pb format
|
||||
for groupID, msg := range m {
|
||||
tempUserMsg := new(pbMsg.GatherFormat)
|
||||
tempUserMsg.ID = groupID
|
||||
tempUserMsg.List = msg
|
||||
sort.Sort(msg)
|
||||
respMsgFormat = append(respMsgFormat, tempUserMsg)
|
||||
}
|
||||
return respMsgFormat
|
||||
}
|
||||
|
||||
type MsgFormats []*pbMsg.MsgFormat
|
||||
|
||||
// Implement the sort.Interface interface to get the number of elements method
|
||||
func (s MsgFormats) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
//Implement the sort.Interface interface comparison element method
|
||||
func (s MsgFormats) Less(i, j int) bool {
|
||||
return s[i].SendTime < s[j].SendTime
|
||||
}
|
||||
|
||||
//Implement the sort.Interface interface exchange element method
|
||||
func (s MsgFormats) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"Open_IM/internal/api/group"
|
||||
"Open_IM/internal/push/content_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MsgCallBackReq struct {
|
||||
SendID string `json:"sendID"`
|
||||
RecvID string `json:"recvID"`
|
||||
Content string `json:"content"`
|
||||
SendTime int64 `json:"sendTime"`
|
||||
MsgFrom int32 `json:"msgFrom"`
|
||||
ContentType int32 `json:"contentType"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
PlatformID int32 `json:"senderPlatformID"`
|
||||
MsgID string `json:"msgID"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
}
|
||||
type MsgCallBackResp struct {
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
ResponseErrCode int32 `json:"responseErrCode"`
|
||||
ResponseResult struct {
|
||||
ModifiedMsg string `json:"modifiedMsg"`
|
||||
Ext string `json:"ext"`
|
||||
}
|
||||
}
|
||||
|
||||
func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*pbChat.UserSendMsgResp, error) {
|
||||
replay := pbChat.UserSendMsgResp{}
|
||||
log.NewDebug(pb.OperationID, "rpc sendMsg come here", pb.String())
|
||||
//if !utils.VerifyToken(pb.Token, pb.SendID) {
|
||||
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
|
||||
serverMsgID := GetMsgID(pb.SendID)
|
||||
pbData := pbChat.WSToMsgSvrChatMsg{}
|
||||
pbData.MsgFrom = pb.MsgFrom
|
||||
pbData.SessionType = pb.SessionType
|
||||
pbData.ContentType = pb.ContentType
|
||||
pbData.Content = pb.Content
|
||||
pbData.RecvID = pb.RecvID
|
||||
pbData.ForceList = pb.ForceList
|
||||
pbData.OfflineInfo = pb.OffLineInfo
|
||||
pbData.Options = pb.Options
|
||||
pbData.PlatformID = pb.PlatformID
|
||||
pbData.ClientMsgID = pb.ClientMsgID
|
||||
pbData.SendID = pb.SendID
|
||||
pbData.SenderNickName = pb.SenderNickName
|
||||
pbData.SenderFaceURL = pb.SenderFaceURL
|
||||
pbData.MsgID = serverMsgID
|
||||
pbData.OperationID = pb.OperationID
|
||||
pbData.Token = pb.Token
|
||||
if pb.SendTime == 0 {
|
||||
pbData.SendTime = utils.GetCurrentTimestampByNano()
|
||||
} else {
|
||||
pbData.SendTime = pb.SendTime
|
||||
}
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
isHistory := utils.GetSwitchFromOptions(options, "history")
|
||||
mReq := MsgCallBackReq{
|
||||
SendID: pb.SendID,
|
||||
RecvID: pb.RecvID,
|
||||
Content: pb.Content,
|
||||
SendTime: pbData.SendTime,
|
||||
MsgFrom: pbData.MsgFrom,
|
||||
ContentType: pb.ContentType,
|
||||
SessionType: pb.SessionType,
|
||||
PlatformID: pb.PlatformID,
|
||||
MsgID: pb.ClientMsgID,
|
||||
}
|
||||
if !isHistory {
|
||||
mReq.IsOnlineOnly = true
|
||||
}
|
||||
mResp := MsgCallBackResp{}
|
||||
if config.Config.MessageCallBack.CallbackSwitch {
|
||||
bMsg, err := http2.Post(config.Config.MessageCallBack.CallbackUrl, mReq, config.Config.MessageCallBack.CallBackTimeOut)
|
||||
if err != nil {
|
||||
log.ErrorByKv("callback to Business server err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
||||
return returnMsg(&replay, pb, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError), "", 0)
|
||||
} else if err = json.Unmarshal(bMsg, &mResp); err != nil {
|
||||
log.ErrorByKv("ws json Unmarshal err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
||||
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
||||
} else {
|
||||
if mResp.ErrCode != 0 {
|
||||
return returnMsg(&replay, pb, mResp.ResponseErrCode, mResp.ErrMsg, "", 0)
|
||||
} else {
|
||||
pbData.Content = mResp.ResponseResult.ModifiedMsg
|
||||
}
|
||||
}
|
||||
}
|
||||
switch pbData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(pbData.RecvID, pbData.SendID, constant.SingleChatType, &pbData)
|
||||
if isSend {
|
||||
err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID)
|
||||
if err1 != nil {
|
||||
log.NewError(pbData.OperationID, "kafka send msg err:RecvID", pbData.RecvID, pbData.String())
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
}
|
||||
err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID)
|
||||
if err2 != nil {
|
||||
log.NewError(pbData.OperationID, "kafka send msg err:SendID", pbData.SendID, pbData.String())
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime)
|
||||
case constant.GroupChatType:
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
req := &pbGroup.GetGroupAllMemberReq{
|
||||
GroupID: pbData.RecvID,
|
||||
Token: pbData.Token,
|
||||
OperationID: pbData.OperationID,
|
||||
}
|
||||
reply, err := client.GetGroupAllMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error())
|
||||
return returnMsg(&replay, pb, 201, err.Error(), "", 0)
|
||||
}
|
||||
if reply.ErrorCode != 0 {
|
||||
log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrorMsg)
|
||||
return returnMsg(&replay, pb, reply.ErrorCode, reply.ErrorMsg, "", 0)
|
||||
}
|
||||
var addUidList []string
|
||||
switch pbData.ContentType {
|
||||
case constant.KickGroupMemberTip:
|
||||
var notification content_struct.NotificationContent
|
||||
var kickContent group.KickGroupMemberReq
|
||||
err := utils.JsonStringToStruct(pbData.Content, ¬ification)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json unmarshall err", pbData.OperationID, "err", err.Error())
|
||||
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
||||
} else {
|
||||
err := utils.JsonStringToStruct(notification.Detail, &kickContent)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json unmarshall err", pbData.OperationID, "err", err.Error())
|
||||
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
||||
}
|
||||
for _, v := range kickContent.UidListInfo {
|
||||
addUidList = append(addUidList, v.UserId)
|
||||
}
|
||||
}
|
||||
case constant.QuitGroupTip:
|
||||
addUidList = append(addUidList, pbData.SendID)
|
||||
default:
|
||||
}
|
||||
groupID := pbData.RecvID
|
||||
for i, v := range reply.MemberList {
|
||||
pbData.RecvID = v.UserId + " " + groupID
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(v.UserId, groupID, constant.GroupChatType, &pbData)
|
||||
if isSend {
|
||||
err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i))
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "kafka send msg err:UserId", v.UserId, pbData.String())
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for i, v := range addUidList {
|
||||
pbData.RecvID = v + " " + groupID
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(v, groupID, constant.GroupChatType, &pbData)
|
||||
if isSend {
|
||||
err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i+1))
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "kafka send msg err:UserId", v, pbData.String())
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime)
|
||||
default:
|
||||
return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type WSToMsgSvrChatMsg struct {
|
||||
SendID string `protobuf:"bytes,1,opt,name=SendID" json:"SendID,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
Content string `protobuf:"bytes,3,opt,name=Content" json:"Content,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,5,opt,name=MsgFrom" json:"MsgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,8,opt,name=ContentType" json:"ContentType,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,9,opt,name=SessionType" json:"SessionType,omitempty"`
|
||||
OperationID string `protobuf:"bytes,10,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
}
|
||||
|
||||
func CreateGroupNotification(SendID, RecvID string, tip open_im_sdk.CreateGroupTip) {
|
||||
var msg WSToMsgSvrChatMsg
|
||||
msg.OperationID = utils.OperationIDGenerator()
|
||||
msg.SendID = SendID
|
||||
msg.RecvID = RecvID
|
||||
msg.ContentType = constant.CreateGroupTip
|
||||
msg.SessionType = constant.SysMsgType
|
||||
|
||||
}
|
||||
|
||||
func Notification(m *WSToMsgSvrChatMsg, onlineUserOnly bool, offlineInfo open_im_sdk.OfflinePushInfo) {
|
||||
|
||||
}
|
||||
|
||||
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.WSToMsgSvrChatMsg, key string) error {
|
||||
pid, offset, err := rpc.producer.SendMessage(m, key)
|
||||
if err != nil {
|
||||
log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
|
||||
}
|
||||
return err
|
||||
}
|
||||
func GetMsgID(sendID string) string {
|
||||
t := time.Now().Format("2006-01-02 15:04:05")
|
||||
return t + "-" + sendID + "-" + strconv.Itoa(rand.Int())
|
||||
}
|
||||
func returnMsg(replay *pbChat.UserSendMsgResp, pb *pbChat.UserSendMsgReq, errCode int32, errMsg, serverMsgID string, sendTime int64) (*pbChat.UserSendMsgResp, error) {
|
||||
replay.ErrCode = errCode
|
||||
replay.ErrMsg = errMsg
|
||||
replay.ReqIdentifier = pb.ReqIdentifier
|
||||
replay.ClientMsgID = pb.ClientMsgID
|
||||
replay.ServerMsgID = serverMsgID
|
||||
replay.SendTime = sendTime
|
||||
return replay, nil
|
||||
}
|
||||
func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, msg *pbChat.WSToMsgSvrChatMsg) bool {
|
||||
conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType)
|
||||
opt, err := db.DB.GetSingleConversationMsgOpt(userID, conversationID)
|
||||
if err != nil {
|
||||
log.NewError(msg.OperationID, "GetSingleConversationMsgOpt from redis err", msg.String())
|
||||
return true
|
||||
}
|
||||
switch opt {
|
||||
case constant.ReceiveMessage:
|
||||
return true
|
||||
case constant.NotReceiveMessage:
|
||||
return false
|
||||
case constant.ReceiveNotNotifyMessage:
|
||||
options := utils.JsonStringToMap(msg.Options)
|
||||
if options == nil {
|
||||
options = make(map[string]int32, 2)
|
||||
}
|
||||
utils.SetSwitchFromOptions(options, "offlinePush", 0)
|
||||
msg.Options = utils.MapIntToJsonString(options)
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"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"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.CommonResp, error) {
|
||||
log.Info(req.Token, req.OperationID, "rpc add blacklist is server,args=%s", req.String())
|
||||
//Parse token, to find current user information
|
||||
claims, err := token_verify.ParseToken(req.Token)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||
}
|
||||
|
||||
isMagagerFlag := 0
|
||||
tokenUid := claims.UID
|
||||
|
||||
if utils.IsContain(tokenUid, config.Config.Manager.AppManagerUid) {
|
||||
isMagagerFlag = 1
|
||||
}
|
||||
|
||||
if isMagagerFlag == 0 {
|
||||
err = im_mysql_model.InsertInToUserBlackList(claims.UID, req.Uid)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
||||
return &pbFriend.CommonResp{}, nil
|
||||
}
|
||||
|
||||
err = im_mysql_model.InsertInToUserBlackList(req.OwnerUid, req.Uid)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
||||
return &pbFriend.CommonResp{}, nil
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/content_struct"
|
||||
"Open_IM/internal/push/logic"
|
||||
"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"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.CommonResp, error) {
|
||||
log.Info(req.Token, req.OperationID, "rpc add friend is server,userid=%s", req.Uid)
|
||||
//Parse token, to find current user information
|
||||
claims, err := token_verify.ParseToken(req.Token)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||
}
|
||||
//Cannot add non-existent users
|
||||
if _, err = im_mysql_model.FindUserByUID(req.Uid); err != nil {
|
||||
log.Error(req.Token, req.OperationID, "this user not exists,cant not add friend")
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrAddFriend.ErrCode, ErrorMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||
}
|
||||
|
||||
//Establish a latest relationship in the friend request table
|
||||
err = im_mysql_model.ReplaceIntoFriendReq(claims.UID, req.Uid, constant.ApplicationFriendFlag, req.ReqMessage)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,create friend request record failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrAddFriend.ErrCode, ErrorMsg: constant.ErrAddFriend.ErrMsg}, nil
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc add friend is success return,uid=%s", req.Uid)
|
||||
//Push message when add friend successfully
|
||||
senderInfo, errSend := im_mysql_model.FindUserByUID(claims.UID)
|
||||
receiverInfo, errReceive := im_mysql_model.FindUserByUID(req.Uid)
|
||||
if errSend == nil && errReceive == nil {
|
||||
logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
SendID: senderInfo.UID,
|
||||
RecvID: receiverInfo.UID,
|
||||
Content: content_struct.NewContentStructString(0, "", senderInfo.Name+" asked to add you as a friend"),
|
||||
SendTime: utils.GetCurrentTimestampBySecond(),
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.AddFriendTip,
|
||||
SessionType: constant.SingleChatType,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
}
|
||||
return &pbFriend.CommonResp{}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFriendReq) (*pbFriend.ImportFriendResp, error) {
|
||||
log.Info(req.Token, req.OperationID, "ImportFriend come here,args=%s", req.String())
|
||||
var resp pbFriend.ImportFriendResp
|
||||
var c pbFriend.CommonResp
|
||||
//Parse token, to find current user information
|
||||
claims, err := token_verify.ParseToken(req.Token)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "parse token failed", err.Error())
|
||||
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||
c.ErrorMsg = constant.ErrParseToken.ErrMsg
|
||||
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||
}
|
||||
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
log.NewError(req.OperationID, "not manager uid", claims.UID)
|
||||
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||
c.ErrorMsg = "not authorized"
|
||||
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||
}
|
||||
if _, err = im_mysql_model.FindUserByUID(req.OwnerUid); err != nil {
|
||||
log.NewError(req.OperationID, "this user not exists,cant not add friend", req.OwnerUid)
|
||||
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||
c.ErrorMsg = "this user not exists,cant not add friend"
|
||||
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||
}
|
||||
for _, v := range req.UidList {
|
||||
if _, fErr := im_mysql_model.FindUserByUID(v); fErr != nil {
|
||||
c.ErrorMsg = "some uid establish failed"
|
||||
c.ErrorCode = 408
|
||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||
} else {
|
||||
if _, err = im_mysql_model.FindFriendRelationshipFromFriend(req.OwnerUid, v); err != nil {
|
||||
//Establish two single friendship
|
||||
err1 := im_mysql_model.InsertToFriend(req.OwnerUid, v, 1)
|
||||
if err1 != nil {
|
||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||
log.NewError(req.OperationID, "err1,create friendship failed", req.OwnerUid, v, err1.Error())
|
||||
}
|
||||
err2 := im_mysql_model.InsertToFriend(v, req.OwnerUid, 1)
|
||||
if err2 != nil {
|
||||
log.NewError(req.OperationID, "err2,create friendship failed", v, req.OwnerUid, err2.Error())
|
||||
}
|
||||
if err1 == nil && err2 == nil {
|
||||
var name, faceUrl string
|
||||
n := content_struct.NotificationContent{IsDisplay: 1, DefaultTips: constant.FriendAcceptTip}
|
||||
r, err := im_mysql_model.FindUserByUID(v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "get info failed", err.Error(), v)
|
||||
}
|
||||
if r != nil {
|
||||
name, faceUrl = r.Name, r.Icon
|
||||
}
|
||||
|
||||
logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
SendID: v,
|
||||
RecvID: req.OwnerUid,
|
||||
SenderFaceURL: faceUrl,
|
||||
SenderNickName: name,
|
||||
Content: n.ContentToString(),
|
||||
SendTime: utils.GetCurrentTimestampByNano(),
|
||||
MsgFrom: constant.UserMsgType, //Notification message identification
|
||||
ContentType: constant.AcceptFriendApplicationTip, //Add friend flag
|
||||
SessionType: constant.SingleChatType,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
} else {
|
||||
c.ErrorMsg = "some uid establish failed"
|
||||
c.ErrorCode = 408
|
||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resp.CommonResp = &c
|
||||
log.NewDebug(req.OperationID, "rpc come end", resp.CommonResp.ErrorCode, resp.CommonResp.ErrorMsg, resp.FailedUidList)
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/content_struct"
|
||||
"Open_IM/internal/push/logic"
|
||||
"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"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddFriendResponseReq) (*pbFriend.CommonResp, error) {
|
||||
log.Info(req.Token, req.OperationID, "rpc add friend response is server,args=%s", req.String())
|
||||
//Parse token, to find current user information
|
||||
claims, err := token_verify.ParseToken(req.Token)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||
}
|
||||
//Check there application before agreeing or refuse to a friend's application
|
||||
if _, err = im_mysql_model.FindFriendApplyFromFriendReqByUid(req.Uid, claims.UID); err != nil {
|
||||
log.Error(req.Token, req.OperationID, "No such application record")
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrAgreeToAddFriend.ErrCode, ErrorMsg: constant.ErrAgreeToAddFriend.ErrMsg}, nil
|
||||
}
|
||||
//Change friend request status flag
|
||||
err = im_mysql_model.UpdateFriendRelationshipToFriendReq(req.Uid, claims.UID, req.Flag)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,update friend request table failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrAgreeToAddFriend.ErrMsg}, nil
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc add friend response success return,userid=%s,flag=%d", req.Uid, req.Flag)
|
||||
//Change the status of the friend request form
|
||||
if req.Flag == constant.FriendFlag {
|
||||
//Establish friendship after find friend relationship not exists
|
||||
_, err := im_mysql_model.FindFriendRelationshipFromFriend(claims.UID, req.Uid)
|
||||
//fixme If there is an error, it means that there is no friend record or database err, if no friend record should be inserted,Continue down execution
|
||||
if err != nil {
|
||||
log.Error("", req.OperationID, err.Error())
|
||||
}
|
||||
//Establish two single friendship
|
||||
err = im_mysql_model.InsertToFriend(claims.UID, req.Uid, req.Flag)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,create friendship failed", err.Error())
|
||||
}
|
||||
err = im_mysql_model.InsertToFriend(req.Uid, claims.UID, req.Flag)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,create friendship failed", err.Error())
|
||||
}
|
||||
//Push message when establish friends successfully
|
||||
//senderInfo, errSend := im_mysql_model.FindUserByUID(claims.UID)
|
||||
//if errSend == nil {
|
||||
// logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
// SendID: claims.UID,
|
||||
// RecvID: req.Uid,
|
||||
// Content: content_struct.NewContentStructString(1, "", senderInfo.Name+" agreed to add you as a friend."),
|
||||
// SendTime: utils.GetCurrentTimestampBySecond(),
|
||||
// MsgFrom: constant.UserMsgType, //Notification message identification
|
||||
// ContentType: constant.AcceptFriendApplicationTip, //Add friend flag
|
||||
// SessionType: constant.SingleChatType,
|
||||
// OperationID: req.OperationID,
|
||||
// })
|
||||
//}
|
||||
}
|
||||
if req.Flag == constant.RefuseFriendFlag {
|
||||
senderInfo, errSend := im_mysql_model.FindUserByUID(claims.UID)
|
||||
if errSend == nil {
|
||||
logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
SendID: claims.UID,
|
||||
RecvID: req.Uid,
|
||||
Content: content_struct.NewContentStructString(0, "", senderInfo.Name+" refuse to add you as a friend."),
|
||||
SendTime: utils.GetCurrentTimestampBySecond(),
|
||||
MsgFrom: constant.UserMsgType, //Notification message identification
|
||||
ContentType: constant.RefuseFriendApplicationTip, //Add friend flag
|
||||
SessionType: constant.SingleChatType,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
}
|
||||
}
|
||||
return &pbFriend.CommonResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package friend
|
||||
@@ -1,27 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"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"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (*pbFriend.CommonResp, error) {
|
||||
log.Info(req.Token, req.OperationID, "rpc delete friend is server,args=%s", req.String())
|
||||
//Parse token, to find current user information
|
||||
claims, err := token_verify.ParseToken(req.Token)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||
}
|
||||
err = im_mysql_model.DeleteSingleFriendInfo(claims.UID, req.Uid)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,delete friend failed", err.Error())
|
||||
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc delete friend success return")
|
||||
return &pbFriend.CommonResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
chat "Open_IM/internal/rpc/msg"
|
||||
"Open_IM/pkg/common/config"
|
||||
"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/common/token_verify"
|
||||
cp "Open_IM/pkg/common/utils"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
sdkws "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type friendServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewFriendServer(port int) *friendServer {
|
||||
log.NewPrivateLog("friend")
|
||||
return &friendServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *friendServer) Run() {
|
||||
log.NewInfo("0", "friendServer run...")
|
||||
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "listen ok ", registerAddress)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
//User friend related services register to etcd
|
||||
pbFriend.RegisterFriendServer(srv, s)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName)
|
||||
return
|
||||
}
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error(), listener)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.AddBlacklistResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist args ", req.String())
|
||||
ok := token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
black := db.Black{OwnerUserID: req.CommID.FromUserID, BlockUserID: req.CommID.ToUserID, OperatorUserID: req.CommID.OpUserID}
|
||||
|
||||
err := imdb.InsertInToUserBlackList(black)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "InsertInToUserBlackList failed ", err.Error())
|
||||
return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist rpc ok ", req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
chat.BlackAddedNotification(req)
|
||||
return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.AddFriendResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||
ok := token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
//Cannot add non-existent users
|
||||
if _, err := imdb.GetUserByUserID(req.CommID.ToUserID); err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetUserByUserID failed ", err.Error(), req.CommID.ToUserID)
|
||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
//Establish a latest relationship in the friend request table
|
||||
friendRequest := db.FriendRequest{
|
||||
HandleResult: 0, ReqMsg: req.ReqMsg, CreateTime: time.Now()}
|
||||
utils.CopyStructFields(&friendRequest, req.CommID)
|
||||
// {openIM001 openIM002 0 test add friend 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC }]
|
||||
log.NewDebug(req.CommID.OperationID, "UpdateFriendApplication args ", friendRequest)
|
||||
//err := imdb.InsertFriendApplication(&friendRequest)
|
||||
err := imdb.InsertFriendApplication(&friendRequest,
|
||||
map[string]interface{}{"handle_result": 0, "req_msg": friendRequest.ReqMsg, "create_time": friendRequest.CreateTime,
|
||||
"handler_user_id": "", "handle_msg": "", "handle_time": utils.UnixSecondToTime(0), "ex": ""})
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "UpdateFriendApplication failed ", err.Error(), friendRequest)
|
||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
chat.FriendApplicationNotification(req)
|
||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFriendReq) (*pbFriend.ImportFriendResp, error) {
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
resp := pbFriend.ImportFriendResp{CommonResp: &pbFriend.CommonResp{}}
|
||||
var c pbFriend.CommonResp
|
||||
|
||||
if !utils.IsContain(req.OpUserID, config.Config.Manager.AppManagerUid) {
|
||||
log.NewError(req.OperationID, "not authorized", req.OpUserID, config.Config.Manager.AppManagerUid)
|
||||
c.ErrCode = constant.ErrAccess.ErrCode
|
||||
c.ErrMsg = constant.ErrAccess.ErrMsg
|
||||
for _, v := range req.FriendUserIDList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1})
|
||||
}
|
||||
resp.CommonResp = &c
|
||||
return &resp, nil
|
||||
}
|
||||
if _, err := imdb.GetUserByUserID(req.FromUserID); err != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.FromUserID)
|
||||
c.ErrCode = constant.ErrDB.ErrCode
|
||||
c.ErrMsg = "this user not exists,cant not add friend"
|
||||
for _, v := range req.FriendUserIDList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1})
|
||||
}
|
||||
resp.CommonResp = &c
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
for _, v := range req.FriendUserIDList {
|
||||
log.NewDebug(req.OperationID, "FriendUserIDList ", v)
|
||||
if _, fErr := imdb.GetUserByUserID(v); fErr != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", fErr.Error(), v)
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1})
|
||||
} else {
|
||||
if _, err := imdb.GetFriendRelationshipFromFriend(req.FromUserID, v); err != nil {
|
||||
//Establish two single friendship
|
||||
toInsertFollow := db.Friend{OwnerUserID: req.FromUserID, FriendUserID: v}
|
||||
err1 := imdb.InsertToFriend(&toInsertFollow)
|
||||
if err1 != nil {
|
||||
log.NewError(req.OperationID, "InsertToFriend failed ", err1.Error(), toInsertFollow)
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1})
|
||||
continue
|
||||
}
|
||||
toInsertFollow = db.Friend{OwnerUserID: v, FriendUserID: req.FromUserID}
|
||||
err2 := imdb.InsertToFriend(&toInsertFollow)
|
||||
if err2 != nil {
|
||||
log.NewError(req.OperationID, "InsertToFriend failed ", err2.Error(), toInsertFollow)
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1})
|
||||
continue
|
||||
}
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: 0})
|
||||
log.NewDebug(req.OperationID, "UserIDResultList ", resp.UserIDResultList)
|
||||
chat.FriendAddedNotification(req.OperationID, req.OpUserID, req.FromUserID, v)
|
||||
} else {
|
||||
log.NewWarn(req.OperationID, "GetFriendRelationshipFromFriend ok", req.FromUserID, v)
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: 0})
|
||||
}
|
||||
}
|
||||
}
|
||||
resp.CommonResp.ErrCode = 0
|
||||
log.NewInfo(req.OperationID, "ImportFriend rpc ok ", resp.String())
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
//process Friend application
|
||||
func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddFriendResponseReq) (*pbFriend.AddFriendResponseResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
//Check there application before agreeing or refuse to a friend's application
|
||||
//req.CommID.FromUserID process req.CommID.ToUserID
|
||||
friendRequest, err := imdb.GetFriendApplicationByBothUserID(req.CommID.ToUserID, req.CommID.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetFriendApplicationByBothUserID failed ", err.Error(), req.CommID.ToUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
friendRequest.HandleResult = req.HandleResult
|
||||
friendRequest.HandleTime = time.Now()
|
||||
//friendRequest.HandleTime.Unix()
|
||||
friendRequest.HandleMsg = req.HandleMsg
|
||||
friendRequest.HandlerUserID = req.CommID.OpUserID
|
||||
err = imdb.UpdateFriendApplication(friendRequest)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "UpdateFriendApplication failed ", err.Error(), friendRequest)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
//Change the status of the friend request form
|
||||
if req.HandleResult == constant.FriendFlag {
|
||||
//Establish friendship after find friend relationship not exists
|
||||
_, err := imdb.GetFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err == nil {
|
||||
log.NewWarn(req.CommID.OperationID, "GetFriendRelationshipFromFriend exist", req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
} else {
|
||||
//Establish two single friendship
|
||||
toInsertFollow := db.Friend{OwnerUserID: req.CommID.FromUserID, FriendUserID: req.CommID.ToUserID, OperatorUserID: req.CommID.OpUserID}
|
||||
err = imdb.InsertToFriend(&toInsertFollow)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "InsertToFriend failed ", err.Error(), toInsertFollow)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
}
|
||||
|
||||
_, err = imdb.GetFriendRelationshipFromFriend(req.CommID.ToUserID, req.CommID.FromUserID)
|
||||
if err == nil {
|
||||
log.NewWarn(req.CommID.OperationID, "GetFriendRelationshipFromFriend exist", req.CommID.ToUserID, req.CommID.FromUserID)
|
||||
} else {
|
||||
toInsertFollow := db.Friend{OwnerUserID: req.CommID.ToUserID, FriendUserID: req.CommID.FromUserID, OperatorUserID: req.CommID.OpUserID}
|
||||
err = imdb.InsertToFriend(&toInsertFollow)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "InsertToFriend failed ", err.Error(), toInsertFollow)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
chat.FriendAddedNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
}
|
||||
}
|
||||
if req.HandleResult == constant.FriendResponseAgree {
|
||||
chat.FriendApplicationApprovedNotification(req)
|
||||
} else if req.HandleResult == constant.FriendResponseRefuse {
|
||||
chat.FriendApplicationRejectedNotification(req)
|
||||
} else {
|
||||
log.Error(req.CommID.OperationID, "HandleResult failed ", req.HandleResult)
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc AddFriendResponse ok")
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (*pbFriend.DeleteFriendResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
err := imdb.DeleteSingleFriendInfo(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "DeleteSingleFriendInfo failed", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend rpc ok")
|
||||
chat.FriendDeletedNotification(req)
|
||||
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) GetBlacklist(ctx context.Context, req *pbFriend.GetBlacklistReq) (*pbFriend.GetBlacklistResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.GetBlacklistResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
|
||||
blackListInfo, err := imdb.GetBlackListByUserID(req.CommID.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetBlackListByUID failed ", err.Error(), req.CommID.FromUserID)
|
||||
return &pbFriend.GetBlacklistResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
|
||||
var (
|
||||
userInfoList []*sdkws.PublicUserInfo
|
||||
)
|
||||
for _, blackUser := range blackListInfo {
|
||||
var blackUserInfo sdkws.PublicUserInfo
|
||||
//Find black user information
|
||||
us, err := imdb.GetUserByUserID(blackUser.BlockUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetUserByUserID failed ", err.Error(), blackUser.BlockUserID)
|
||||
continue
|
||||
}
|
||||
utils.CopyStructFields(&blackUserInfo, us)
|
||||
userInfoList = append(userInfoList, &blackUserInfo)
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc GetBlacklist ok ", pbFriend.GetBlacklistResp{BlackUserInfoList: userInfoList})
|
||||
return &pbFriend.GetBlacklistResp{BlackUserInfoList: userInfoList}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFriendRemarkReq) (*pbFriend.SetFriendRemarkResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
err := imdb.UpdateFriendComment(req.CommID.FromUserID, req.CommID.ToUserID, req.Remark)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "UpdateFriendComment failed ", req.CommID.FromUserID, req.CommID.ToUserID, req.Remark)
|
||||
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc SetFriendComment ok")
|
||||
chat.FriendRemarkSetNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) RemoveBlacklist(ctx context.Context, req *pbFriend.RemoveBlacklistReq) (*pbFriend.RemoveBlacklistResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
err := imdb.RemoveBlackList(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "RemoveBlackList failed", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc RemoveBlacklist ok ")
|
||||
chat.BlackDeletedNotification(req)
|
||||
return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) IsInBlackList(ctx context.Context, req *pbFriend.IsInBlackListReq) (*pbFriend.IsInBlackListResp, error) {
|
||||
log.NewInfo("IsInBlackList args ", req.String())
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.IsInBlackListResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
|
||||
var isInBlacklist = false
|
||||
err := imdb.CheckBlack(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err == nil {
|
||||
isInBlacklist = true
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "IsInBlackList rpc ok ", pbFriend.IsInBlackListResp{Response: isInBlacklist})
|
||||
return &pbFriend.IsInBlackListResp{Response: isInBlacklist}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) IsFriend(ctx context.Context, req *pbFriend.IsFriendReq) (*pbFriend.IsFriendResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, req.String())
|
||||
var isFriend bool
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.IsFriendResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
_, err := imdb.GetFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err == nil {
|
||||
isFriend = true
|
||||
} else {
|
||||
isFriend = false
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, pbFriend.IsFriendResp{Response: isFriend})
|
||||
return &pbFriend.IsFriendResp{Response: isFriend}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) GetFriendList(ctx context.Context, req *pbFriend.GetFriendListReq) (*pbFriend.GetFriendListResp, error) {
|
||||
log.NewInfo("GetFriendList args ", req.String())
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.GetFriendListResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
|
||||
friends, err := imdb.GetFriendListByUserID(req.CommID.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "FindUserInfoFromFriend failed ", err.Error(), req.CommID.FromUserID)
|
||||
return &pbFriend.GetFriendListResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
var userInfoList []*sdkws.FriendInfo
|
||||
for _, friendUser := range friends {
|
||||
friendUserInfo := sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
|
||||
cp.FriendDBCopyOpenIM(&friendUserInfo, &friendUser)
|
||||
log.NewDebug(req.CommID.OperationID, "friends : ", friendUser, "openim friends: ", friendUserInfo)
|
||||
userInfoList = append(userInfoList, &friendUserInfo)
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc GetFriendList ok", pbFriend.GetFriendListResp{FriendInfoList: userInfoList})
|
||||
return &pbFriend.GetFriendListResp{FriendInfoList: userInfoList}, nil
|
||||
}
|
||||
|
||||
//received
|
||||
func (s *friendServer) GetFriendApplyList(ctx context.Context, req *pbFriend.GetFriendApplyListReq) (*pbFriend.GetFriendApplyListResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.GetFriendApplyListResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
// Find the current user friend applications received
|
||||
ApplyUsersInfo, err := imdb.GetReceivedFriendsApplicationListByUserID(req.CommID.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetReceivedFriendsApplicationListByUserID ", err.Error(), req.CommID.FromUserID)
|
||||
return &pbFriend.GetFriendApplyListResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
|
||||
var appleUserList []*sdkws.FriendRequest
|
||||
for _, applyUserInfo := range ApplyUsersInfo {
|
||||
var userInfo sdkws.FriendRequest
|
||||
cp.FriendRequestDBCopyOpenIM(&userInfo, &applyUserInfo)
|
||||
// utils.CopyStructFields(&userInfo, applyUserInfo)
|
||||
// u, err := imdb.GetUserByUserID(userInfo.FromUserID)
|
||||
// if err != nil {
|
||||
// log.Error(req.CommID.OperationID, "GetUserByUserID", userInfo.FromUserID)
|
||||
// continue
|
||||
// }
|
||||
// userInfo.FromNickname = u.Nickname
|
||||
// userInfo.FromFaceURL = u.FaceURL
|
||||
// userInfo.FromGender = u.Gender
|
||||
//
|
||||
// u, err = imdb.GetUserByUserID(userInfo.ToUserID)
|
||||
// if err != nil {
|
||||
// log.Error(req.CommID.OperationID, "GetUserByUserID", userInfo.ToUserID)
|
||||
// continue
|
||||
// }
|
||||
// userInfo.ToNickname = u.Nickname
|
||||
// userInfo.ToFaceURL = u.FaceURL
|
||||
// userInfo.ToGender = u.Gender
|
||||
appleUserList = append(appleUserList, &userInfo)
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "rpc GetFriendApplyList ok", pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList})
|
||||
return &pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList}, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) GetSelfApplyList(ctx context.Context, req *pbFriend.GetSelfApplyListReq) (*pbFriend.GetSelfApplyListResp, error) {
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||
|
||||
//Parse token, to find current user information
|
||||
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.GetSelfApplyListResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
// Find the self add other userinfo
|
||||
usersInfo, err := imdb.GetSendFriendApplicationListByUserID(req.CommID.FromUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetSendFriendApplicationListByUserID failed ", err.Error(), req.CommID.FromUserID)
|
||||
return &pbFriend.GetSelfApplyListResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
var selfApplyOtherUserList []*sdkws.FriendRequest
|
||||
for _, selfApplyOtherUserInfo := range usersInfo {
|
||||
var userInfo sdkws.FriendRequest // pbFriend.ApplyUserInfo
|
||||
cp.FriendRequestDBCopyOpenIM(&userInfo, &selfApplyOtherUserInfo)
|
||||
//u, err := imdb.GetUserByUserID(userInfo.FromUserID)
|
||||
//if err != nil {
|
||||
// log.Error(req.CommID.OperationID, "GetUserByUserID", userInfo.FromUserID)
|
||||
// continue
|
||||
//}
|
||||
//userInfo.FromNickname = u.Nickname
|
||||
//userInfo.FromFaceURL = u.FaceURL
|
||||
//userInfo.FromGender = u.Gender
|
||||
//
|
||||
//u, err = imdb.GetUserByUserID(userInfo.ToUserID)
|
||||
//if err != nil {
|
||||
// log.Error(req.CommID.OperationID, "GetUserByUserID", userInfo.ToUserID)
|
||||
// continue
|
||||
//}
|
||||
//userInfo.ToNickname = u.Nickname
|
||||
//userInfo.ToFaceURL = u.FaceURL
|
||||
//userInfo.ToGender = u.Gender
|
||||
|
||||
selfApplyOtherUserList = append(selfApplyOtherUserList, &userInfo)
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc GetSelfApplyList ok", pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList})
|
||||
return &pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList}, nil
|
||||
}
|
||||
|
||||
////
|
||||
//func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFriendsInfoReq) (*pbFriend.GetFriendInfoResp, error) {
|
||||
// return nil, nil
|
||||
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||
//// var (
|
||||
//// isInBlackList int32
|
||||
//// // isFriend int32
|
||||
//// comment string
|
||||
//// )
|
||||
////
|
||||
//// friendShip, err := imdb.FindFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
//// if err != nil {
|
||||
//// log.NewError(req.CommID.OperationID, "FindFriendRelationshipFromFriend failed ", err.Error())
|
||||
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||
//// // isFriend = constant.FriendFlag
|
||||
//// }
|
||||
//// comment = friendShip.Remark
|
||||
////
|
||||
//// friendUserInfo, err := imdb.FindUserByUID(req.CommID.ToUserID)
|
||||
//// if err != nil {
|
||||
//// log.NewError(req.CommID.OperationID, "FindUserByUID failed ", err.Error())
|
||||
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||
//// }
|
||||
////
|
||||
//// err = imdb.FindRelationshipFromBlackList(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
//// if err == nil {
|
||||
//// isInBlackList = constant.BlackListFlag
|
||||
//// }
|
||||
////
|
||||
//// resp := pbFriend.GetFriendInfoResp{ErrCode: 0, ErrMsg: "",}
|
||||
////
|
||||
//// utils.CopyStructFields(resp.FriendInfoList, friendUserInfo)
|
||||
//// resp.Data.IsBlack = isInBlackList
|
||||
//// resp.Data.OwnerUserID = req.CommID.FromUserID
|
||||
//// resp.Data.Remark = comment
|
||||
//// resp.Data.CreateTime = friendUserInfo.CreateTime
|
||||
////
|
||||
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo ok ", resp)
|
||||
//// return &resp, nil
|
||||
////
|
||||
//}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user