mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
mongodb superGroup to cache
This commit is contained in:
parent
5a626e9dab
commit
8f12fa52b4
@ -118,6 +118,7 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
storageTime: 50 #文件在minio中保存的时间
|
||||
ali: # ali oss
|
||||
regionID: "oss-cn-beijing"
|
||||
accessKeyID: ""
|
||||
@ -130,7 +131,7 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
OssRoleArn: "acs:ram::xxx:role/xxx"
|
||||
|
||||
dtm:
|
||||
serverURL: 43.128.5.63:10007
|
||||
serverURL: 127.0.0.1:10007
|
||||
|
||||
rpcport: #rpc服务端口 默认即可
|
||||
openImUserPort: [ 10110 ]
|
||||
@ -300,6 +301,15 @@ callback:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
callbackOnlinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
callbackSuperGroupOnlinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
|
||||
|
||||
notification:
|
||||
groupCreated:
|
||||
|
9
go.mod
9
go.mod
@ -12,9 +12,7 @@ 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/dtm-labs/dtmcli v1.15.0 // indirect
|
||||
github.com/dtm-labs/dtmgrpc v1.15.0 // indirect
|
||||
github.com/dtm-labs/rockscache v0.0.8
|
||||
github.com/dtm-labs/rockscache v0.0.11
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-openapi/spec v0.20.6 // indirect
|
||||
@ -30,14 +28,12 @@ require (
|
||||
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/lithammer/shortuuid v3.0.0+incompatible // 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/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.11.1
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.2
|
||||
@ -50,6 +46,9 @@ require (
|
||||
go.etcd.io/etcd/api/v3 v3.5.4
|
||||
go.etcd.io/etcd/client/v3 v3.5.4
|
||||
go.mongodb.org/mongo-driver v1.8.3
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305
|
||||
|
31
go.sum
31
go.sum
@ -50,8 +50,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
|
||||
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
||||
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
@ -105,7 +103,6 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
@ -139,14 +136,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/dtm-labs/dtmcli v1.15.0 h1:kqiV47I9Am/0QuzX11cGTPp/Z2AcOaRDXU7E7SZWYNk=
|
||||
github.com/dtm-labs/dtmcli v1.15.0/go.mod h1:otEdxUwM5FIKlCLmg5hL5+Z539DmCK2YJ0G4WNsP6Tw=
|
||||
github.com/dtm-labs/dtmdriver v0.0.3 h1:9iAtvXKR3lJXQ7dvS87e4xdtmqkzN+ofek+CF9AvUSY=
|
||||
github.com/dtm-labs/dtmdriver v0.0.3/go.mod h1:fLiEeD2BPwM9Yq96TfcP9KpbTwFsn5nTxa/PP0jmFuk=
|
||||
github.com/dtm-labs/dtmgrpc v1.15.0 h1:ZLSbCa/83J4LUR2A/h1h68D6EPuFfDkiUTZ5btKlJvg=
|
||||
github.com/dtm-labs/dtmgrpc v1.15.0/go.mod h1:fc7Mg6UGrNsHVsPrFNZhAH12/ddNHUP5E84EQY1Fz7w=
|
||||
github.com/dtm-labs/rockscache v0.0.8 h1:H6cXO7YhguE9jdvdfK5rrbUUu2MWjgWqsGEA645iFQQ=
|
||||
github.com/dtm-labs/rockscache v0.0.8/go.mod h1:vJmJJmuBNxcio03abYk1QPLmmQo/Kg92jB+28QmLcgY=
|
||||
github.com/dtm-labs/rockscache v0.0.11 h1:V6M+KH9fFRFDXgB+Uux1d6zwhZt1O34sgPwM0wjud9Y=
|
||||
github.com/dtm-labs/rockscache v0.0.11/go.mod h1:vJmJJmuBNxcio03abYk1QPLmmQo/Kg92jB+28QmLcgY=
|
||||
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/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q=
|
||||
@ -217,12 +208,8 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
|
||||
github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q=
|
||||
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
|
||||
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
|
||||
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=
|
||||
@ -418,7 +405,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||
@ -440,8 +426,6 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
|
||||
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/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
||||
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/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
@ -459,7 +443,6 @@ github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
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.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
@ -484,21 +467,17 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s=
|
||||
github.com/prometheus/client_golang v1.11.1/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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0 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/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=
|
||||
@ -711,9 +690,7 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
@ -989,7 +966,6 @@ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKr
|
||||
google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
|
||||
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w=
|
||||
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/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
@ -1023,7 +999,6 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
|
||||
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
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=
|
||||
@ -1061,8 +1036,6 @@ gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
|
||||
gopkg.in/ini.v1 v1.66.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/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
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.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
@ -160,6 +160,7 @@ func MinioStorageCredential(c *gin.Context) {
|
||||
resp.AccessKeyID = v.AccessKeyID
|
||||
resp.BucketName = config.Config.Credential.Minio.Bucket
|
||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||
resp.StorageTime = config.Config.Credential.Minio.StorageTime
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
|
@ -5,22 +5,22 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
http2 "net/http"
|
||||
)
|
||||
|
||||
func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
callbackOfflinePushReq := cbApi.CallbackOfflinePushReq{
|
||||
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
|
||||
CallbackCommand: constant.CallbackOfflinePushCommand,
|
||||
OperationID: operationID,
|
||||
UserID: userID,
|
||||
PlatformID: msg.SenderPlatformID,
|
||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||
func callbackBeforePush(operationID string, userIDList []string, msg *commonPb.MsgData, command string, callbackResp cbApi.CommonCallbackResp, timeOut int) cbApi.CommonCallbackResp {
|
||||
req := cbApi.CallbackBeforePushReq{
|
||||
UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{
|
||||
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||
CallbackCommand: command,
|
||||
OperationID: operationID,
|
||||
PlatformID: msg.SenderPlatformID,
|
||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||
},
|
||||
UserIDList: userIDList,
|
||||
},
|
||||
OfflinePushInfo: msg.OfflinePushInfo,
|
||||
SendID: msg.SendID,
|
||||
@ -30,8 +30,8 @@ func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbAp
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
}
|
||||
callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, timeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
callbackResp.ErrMsg = err.Error()
|
||||
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
||||
@ -44,3 +44,59 @@ func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbAp
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
||||
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
return callbackBeforePush(operationID, userIDList, msg, constant.CallbackOfflinePushCommand, callbackResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut)
|
||||
}
|
||||
|
||||
func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackOnlinePush.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
return callbackBeforePush(operationID, userIDList, msg, constant.CallbackOnlinePushCommand, callbackResp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut)
|
||||
}
|
||||
|
||||
func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *commonPb.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
req := cbApi.CallbackBeforeSuperGroupOnlinePushReq{
|
||||
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||
CallbackCommand: constant.CallbackSuperGroupOnlinePushCommand,
|
||||
OperationID: operationID,
|
||||
PlatformID: msg.SenderPlatformID,
|
||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||
},
|
||||
OfflinePushInfo: msg.OfflinePushInfo,
|
||||
SendID: msg.SendID,
|
||||
GroupID: groupID,
|
||||
ContentType: msg.ContentType,
|
||||
SessionType: msg.SessionType,
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
}
|
||||
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
callbackResp.ErrMsg = err.Error()
|
||||
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
||||
callbackResp.ActionCode = constant.ActionForbidden
|
||||
return callbackResp
|
||||
} else {
|
||||
callbackResp.ActionCode = constant.ActionAllow
|
||||
return callbackResp
|
||||
}
|
||||
}
|
||||
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow && len(resp.UserIDList) != 0 {
|
||||
*pushToUserList = resp.UserIDList
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), pushToUserList, resp.UserIDList)
|
||||
return callbackResp
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,18 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
||||
grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
}
|
||||
|
||||
var UIDList = []string{pushMsg.PushToUserID}
|
||||
callbackResp := callbackOnlinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "OnlinePush callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOnlinePush result: ", callbackResp)
|
||||
}
|
||||
if callbackResp.ActionCode != constant.ActionAllow {
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "OnlinePush stop")
|
||||
return
|
||||
}
|
||||
|
||||
//Online push message
|
||||
log.Debug(pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||
for _, v := range grpcCons {
|
||||
@ -75,9 +87,6 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
return
|
||||
}
|
||||
}
|
||||
//Use offline push messaging
|
||||
var UIDList []string
|
||||
UIDList = append(UIDList, pushMsg.PushToUserID)
|
||||
customContent := OpenIMContent{
|
||||
SessionType: int(pushMsg.MsgData.SessionType),
|
||||
From: pushMsg.MsgData.SendID,
|
||||
@ -118,7 +127,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
}
|
||||
}
|
||||
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData)
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
@ -148,32 +157,49 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var wsResult []*pbRelay.SingelMsgToUserResultList
|
||||
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
log.Debug(pushMsg.OperationID, "Get super group msg from msg_transfer And push msg", pushMsg.String())
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := pushMsg.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(pushMsg.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
client := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||
return
|
||||
}
|
||||
if cacheResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return
|
||||
var pushToUserIDList []string
|
||||
if config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable {
|
||||
callbackResp := callbackBeforeSuperGroupOnlinePush(pushMsg.OperationID, pushMsg.PushToUserID, pushMsg.MsgData, &pushToUserIDList)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
}
|
||||
if callbackResp.ActionCode != constant.ActionAllow {
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "onlinePush stop")
|
||||
return
|
||||
}
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
||||
} else {
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := pushMsg.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(pushMsg.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
client := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||
return
|
||||
}
|
||||
if cacheResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return
|
||||
}
|
||||
pushToUserIDList = cacheResp.UserIDList
|
||||
}
|
||||
|
||||
if len(grpcCons) == 0 {
|
||||
log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
||||
grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
}
|
||||
|
||||
//Online push message
|
||||
log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||
for _, v := range grpcCons {
|
||||
msgClient := pbRelay.NewRelayClient(v)
|
||||
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserIDList: cacheResp.UserIDList})
|
||||
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserIDList: pushToUserIDList})
|
||||
if err != nil {
|
||||
log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err)
|
||||
continue
|
||||
@ -192,7 +218,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
onlineSuccessUserIDList = append(onlineSuccessUserIDList, v.UserID)
|
||||
}
|
||||
}
|
||||
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, cacheResp.UserIDList)
|
||||
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
|
||||
//Use offline push messaging
|
||||
customContent := OpenIMContent{
|
||||
SessionType: int(pushMsg.MsgData.SessionType),
|
||||
@ -234,7 +260,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
}
|
||||
}
|
||||
if len(onlineFailedUserIDList) > 0 {
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList[0], pushMsg.MsgData)
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
|
@ -178,6 +178,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
resp.GroupInfo.OwnerUserID = req.OwnerUserID
|
||||
okUserIDList = append(okUserIDList, req.OwnerUserID)
|
||||
}
|
||||
// superGroup stored in mongodb
|
||||
} else {
|
||||
for _, v := range req.InitMemberList {
|
||||
okUserIDList = append(okUserIDList, v.UserID)
|
||||
@ -186,20 +187,25 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
log.NewError(req.OperationID, "GetGroupMemberNumByGroupID failed ", err.Error(), groupId)
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.ErrMsg = err.Error() + ": CreateSuperGroup failed"
|
||||
}
|
||||
}
|
||||
|
||||
for _, userID := range okUserIDList {
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(userID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), userID, err.Error())
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
if len(okUserIDList) != 0 {
|
||||
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
|
||||
if req.GroupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(userID); err != nil {
|
||||
log.NewWarn(req.OperationID, utils.GetSelfFuncName(), userID, err.Error())
|
||||
}
|
||||
}
|
||||
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
|
||||
} else {
|
||||
for _, userID := range okUserIDList {
|
||||
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(userID); err != nil {
|
||||
log.NewWarn(req.OperationID, utils.GetSelfFuncName(), userID, err.Error())
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
for _, v := range okUserIDList {
|
||||
chat.SuperGroupNotification(req.OperationID, v, v)
|
||||
@ -426,7 +432,6 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
log.NewError(req.OperationID, "AddUserToSuperGroup failed ", req.GroupID, err)
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
@ -449,19 +454,23 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList)
|
||||
} else {
|
||||
for _, v := range req.InvitedUserIDList {
|
||||
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(v); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
for _, v := range req.InvitedUserIDList {
|
||||
chat.SuperGroupNotification(req.OperationID, v, v)
|
||||
@ -492,18 +501,9 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return &resp, nil
|
||||
}
|
||||
//memberList, err := imdb.GetGroupMemberListByGroupID(req.GroupID)
|
||||
//if err != nil {
|
||||
// log.NewError(req.OperationID, "GetGroupMemberListByGroupID failed,", err.Error(), req.GroupID)
|
||||
// resp.ErrCode = constant.ErrDB.ErrCode
|
||||
// resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
// return &resp, nil
|
||||
//}
|
||||
for _, v := range memberList {
|
||||
var node open_im_sdk.GroupMemberFullInfo
|
||||
cp.GroupMemberDBCopyOpenIM(&node, v)
|
||||
//log.Debug(req.OperationID, "db value:", v.MuteEndTime, "seconds: ", v.MuteEndTime.Unix())
|
||||
//log.Debug(req.OperationID, "cp value: ", node)
|
||||
resp.MemberList = append(resp.MemberList, &node)
|
||||
}
|
||||
}
|
||||
@ -681,22 +681,24 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
if err = rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.MemberKickedNotification(req, okUserIDList)
|
||||
} else {
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedSuperGroupIDListFromCache(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
for _, v := range req.KickedUserIDList {
|
||||
chat.SuperGroupNotification(req.OperationID, v, v)
|
||||
@ -711,24 +713,8 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
|
||||
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetGroupMembersInfoReq) (*pbGroup.GetGroupMembersInfoResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
|
||||
var resp pbGroup.GetGroupMembersInfoResp
|
||||
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
|
||||
|
||||
//for _, v := range req.MemberList {
|
||||
// var memberNode open_im_sdk.GroupMemberFullInfo
|
||||
// memberInfo, err := imdb.GetMemberInfoByID(req.GroupID, v)
|
||||
// memberNode.UserID = v
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "GetMemberInfoById failed ", err.Error(), req.GroupID, v)
|
||||
// continue
|
||||
// } else {
|
||||
// utils.CopyStructFields(&memberNode, memberInfo)
|
||||
// memberNode.JoinTime = int32(memberInfo.JoinTime.Unix())
|
||||
// resp.MemberList = append(resp.MemberList, &memberNode)
|
||||
// }
|
||||
//}
|
||||
|
||||
groupMembers, err := rocksCache.GetAllGroupMembersInfoFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
@ -791,7 +777,6 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
groupsInfoList := make([]*open_im_sdk.GroupInfo, 0)
|
||||
for _, groupID := range req.GroupIDList {
|
||||
//groupInfoFromMysql, err := imdb.GetGroupInfoByGroupID(groupID)
|
||||
groupInfoFromRedis, err := rocksCache.GetGroupInfoFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID)
|
||||
@ -1021,7 +1006,6 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
//
|
||||
//_, err = imdb.GetGroupMemberListByGroupIDAndRoleLevel(req.GroupID, constant.GroupOwner)
|
||||
//if err != nil {
|
||||
// log.NewError(req.OperationID, "GetGroupMemberListByGroupIDAndRoleLevel failed ", err.Error(), req.GroupID, constant.GroupOwner)
|
||||
@ -1110,17 +1094,19 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
}
|
||||
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
|
||||
}
|
||||
chat.MemberQuitNotification(req)
|
||||
} else {
|
||||
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(req.OpUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
|
||||
}
|
||||
chat.SuperGroupNotification(req.OperationID, req.OpUserID, req.OpUserID)
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
|
||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
}
|
||||
|
@ -2,47 +2,42 @@ package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
cp "Open_IM/pkg/common/utils"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
userToSuperGroup, err := db.DB.GetSuperGroupByUserID(req.UserID)
|
||||
if err == mongo.ErrNoDocuments {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed ", err.Error(), req.UserID)
|
||||
return resp, nil
|
||||
}
|
||||
//userToSuperGroup, err := db.DB.GetSuperGroupByUserID(req.UserID)
|
||||
groupIDList, err := rocksCache.GetJoinedSuperGroupListFromCache(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed ", err.Error(), req.UserID)
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return resp, nil
|
||||
}
|
||||
for _, groupID := range userToSuperGroup.GroupIDList {
|
||||
groupInfoDB, err := imdb.GetGroupInfoByGroupID(groupID)
|
||||
for _, groupID := range groupIDList {
|
||||
groupInfoFromCache, err := rocksCache.GetGroupInfoFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupInfoByGroupID failed", groupID, err.Error())
|
||||
continue
|
||||
}
|
||||
groupInfo := &commonPb.GroupInfo{}
|
||||
if err := utils.CopyStructFields(groupInfo, groupInfoDB); err != nil {
|
||||
if err := utils.CopyStructFields(groupInfo, groupInfoFromCache); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
group, err := db.DB.GetSuperGroup(groupID)
|
||||
groupMemberIDList, err := rocksCache.GetGroupMemberIDListFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroup failed", groupID, err.Error())
|
||||
continue
|
||||
}
|
||||
groupInfo.MemberCount = uint32(len(group.MemberIDList))
|
||||
groupInfo.MemberCount = uint32(len(groupMemberIDList))
|
||||
resp.GroupList = append(resp.GroupList, groupInfo)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
@ -54,13 +49,13 @@ func (s *groupServer) GetSuperGroupsInfo(_ context.Context, req *pbGroup.GetSupe
|
||||
resp = &pbGroup.GetSuperGroupsInfoResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
groupsInfoList := make([]*commonPb.GroupInfo, 0)
|
||||
for _, groupID := range req.GroupIDList {
|
||||
groupInfoFromMysql, err := imdb.GetGroupInfoByGroupID(groupID)
|
||||
groupInfoFromRedis, err := rocksCache.GetGroupInfoFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID)
|
||||
continue
|
||||
}
|
||||
var groupInfo commonPb.GroupInfo
|
||||
cp.GroupDBCopyOpenIM(&groupInfo, groupInfoFromMysql)
|
||||
cp.GroupDBCopyOpenIM(&groupInfo, groupInfoFromRedis)
|
||||
groupsInfoList = append(groupsInfoList, &groupInfo)
|
||||
}
|
||||
resp.GroupInfoList = groupsInfoList
|
||||
|
@ -74,7 +74,7 @@ func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string
|
||||
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
||||
return true, 0, "", nil
|
||||
}
|
||||
if data.MsgData.ContentType <= constant.FriendApplicationNotification && data.MsgData.ContentType >= constant.FriendApplicationApprovedNotification {
|
||||
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
|
||||
return true, 0, "", nil
|
||||
}
|
||||
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
||||
|
@ -12,6 +12,7 @@ type MiniostorageCredentialResp struct {
|
||||
SessionToken string `json:"sessionToken"`
|
||||
BucketName string `json:"bucketName"`
|
||||
StsEndpointURL string `json:"stsEndpointURL"`
|
||||
StorageTime int `json:"storageTime"`
|
||||
}
|
||||
|
||||
type MinioUploadFileReq struct {
|
||||
|
@ -25,10 +25,19 @@ type CommonCallbackResp struct {
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
type UserStatusCallbackReq struct {
|
||||
type UserStatusBaseCallback struct {
|
||||
CallbackCommand string `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
UserID string `json:"userID"`
|
||||
PlatformID int32 `json:"platformID"`
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
||||
type UserStatusCallbackReq struct {
|
||||
UserStatusBaseCallback
|
||||
UserID string `json:"userID"`
|
||||
}
|
||||
|
||||
type UserStatusBatchCallbackReq struct {
|
||||
UserStatusBaseCallback
|
||||
UserIDList []string `json:"userIDList"`
|
||||
}
|
||||
|
@ -2,18 +2,33 @@ package call_back_struct
|
||||
|
||||
import commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
|
||||
type CallbackOfflinePushReq struct {
|
||||
UserStatusCallbackReq
|
||||
type CallbackBeforePushReq struct {
|
||||
UserStatusBatchCallbackReq
|
||||
*commonPb.OfflinePushInfo
|
||||
//CommonCallbackReq
|
||||
SendID string `json:"sendID"`
|
||||
GroupID string `json:"groupID"`
|
||||
ContentType int32 `json:"contentType"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
AtUserIDList []string `json:"atUserIDList"`
|
||||
Content string `json`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type CallbackOfflinePushResp struct {
|
||||
type CallbackBeforePushResp struct {
|
||||
*CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackBeforeSuperGroupOnlinePushReq struct {
|
||||
*commonPb.OfflinePushInfo
|
||||
UserStatusBaseCallback
|
||||
SendID string `json:"sendID"`
|
||||
GroupID string `json:"groupID"`
|
||||
ContentType int32 `json:"contentType"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
AtUserIDList []string `json:"atUserIDList"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
||||
*CommonCallbackResp
|
||||
UserIDList []string `json:"userIDList"`
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ type config struct {
|
||||
SecretAccessKey string `yaml:"secretAccessKey"`
|
||||
EndpointInner string `yaml:"endpointInner"`
|
||||
EndpointInnerEnable bool `yaml:"endpointInnerEnable"`
|
||||
StorageTime int `yaml:"storageTime"`
|
||||
} `yaml:"minio"`
|
||||
}
|
||||
|
||||
@ -253,15 +254,17 @@ type config struct {
|
||||
}
|
||||
|
||||
Callback struct {
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackBeforeSendSingleMsg"`
|
||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
||||
CallbackOfflinePush callBackConfig `yaml:"callbackOfflinePush"`
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackBeforeSendSingleMsg"`
|
||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
||||
CallbackOfflinePush callBackConfig `yaml:"callbackOfflinePush"`
|
||||
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
|
||||
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
||||
} `yaml:"callback"`
|
||||
Notification struct {
|
||||
///////////////////////group/////////////////////////////
|
||||
|
@ -192,14 +192,16 @@ const (
|
||||
VerificationCodeForResetSuffix = "_forReset"
|
||||
|
||||
//callbackCommand
|
||||
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
||||
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
||||
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
||||
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
|
||||
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
||||
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
||||
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
||||
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
|
||||
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
|
||||
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
|
||||
//callback actionCode
|
||||
ActionAllow = 0
|
||||
ActionForbidden = 1
|
||||
|
@ -147,21 +147,11 @@ func init() {
|
||||
}
|
||||
}
|
||||
// 强一致性缓存,当一个key被标记删除,其他请求线程会被锁住轮询直到新的key生成,适合各种同步的拉取, 如果弱一致可能导致拉取还是老数据,毫无意义
|
||||
DB.Rc = rockscache.NewClient(go_redis.NewClient(&go_redis.Options{
|
||||
Addr: config.Config.Redis.DBAddress[0],
|
||||
Password: config.Config.Redis.DBPassWord, // no password set
|
||||
DB: 0, // use default DB
|
||||
PoolSize: 100, // 连接池大小
|
||||
}), rockscache.NewDefaultOptions())
|
||||
DB.Rc = rockscache.NewClient(DB.RDB, rockscache.NewDefaultOptions())
|
||||
DB.Rc.Options.StrongConsistency = true
|
||||
|
||||
// 弱一致性缓存,当一个key被标记删除,其他请求线程直接返回该key的value,适合高频并且生成很缓存很慢的情况 如大群发消息缓存的缓存
|
||||
DB.WeakRc = rockscache.NewClient(go_redis.NewClient(&go_redis.Options{
|
||||
Addr: config.Config.Redis.DBAddress[0],
|
||||
Password: config.Config.Redis.DBPassWord, // no password set
|
||||
DB: 0, // use default DB
|
||||
PoolSize: 100, // 连接池大小
|
||||
}), rockscache.NewDefaultOptions())
|
||||
DB.WeakRc = rockscache.NewClient(DB.RDB, rockscache.NewDefaultOptions())
|
||||
DB.WeakRc.Options.StrongConsistency = false
|
||||
}
|
||||
|
||||
|
@ -908,8 +908,8 @@ func (d *DataBases) GetUserWorkMoments(opUserID, userID string, showNumber, page
|
||||
result, err := c.Find(ctx, bson.D{ // 等价条件: select * from
|
||||
{"user_id", userID},
|
||||
{"$or", bson.A{
|
||||
bson.D{{"permission", constant.WorkMomentPermissionCantSee}, {"permission_user_id_list", bson.D{{"$nin", bson.A{userID}}}}},
|
||||
bson.D{{"permission", constant.WorkMomentPermissionCanSee}, {"permission_user_id_list", bson.D{{"$in", bson.A{userID}}}}},
|
||||
bson.D{{"permission", constant.WorkMomentPermissionCantSee}, {"permission_user_id_list", bson.D{{"$nin", bson.A{opUserID}}}}},
|
||||
bson.D{{"permission", constant.WorkMomentPermissionCanSee}, {"permission_user_id_list", bson.D{{"$in", bson.A{opUserID}}}}},
|
||||
bson.D{{"permission", constant.WorkMomentPublic}},
|
||||
}},
|
||||
}, findOpts)
|
||||
@ -970,7 +970,7 @@ func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string,
|
||||
}
|
||||
_, err = c.InsertOne(sCtx, superGroup)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
var users []UserToSuperGroup
|
||||
@ -992,7 +992,7 @@ func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string,
|
||||
for _, userID := range initMemberIDList {
|
||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
|
||||
@ -1022,7 +1022,7 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
|
||||
}
|
||||
_, err = c.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDList}}})
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
||||
@ -1039,11 +1039,11 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
|
||||
for _, userID := range userIDList {
|
||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
}
|
||||
session.CommitTransaction(ctx)
|
||||
_ := session.CommitTransaction(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1058,15 +1058,15 @@ func (d *DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []strin
|
||||
sCtx := mongo.NewSessionContext(ctx, session)
|
||||
_, err = c.UpdateOne(ctx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDList}}})
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
err = d.RemoveGroupFromUser(ctx, sCtx, groupID, userIDList)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
_ := session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
session.CommitTransaction(ctx)
|
||||
_ := session.CommitTransaction(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package rocksCache
|
||||
|
||||
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"
|
||||
@ -12,18 +13,19 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
userInfoCache = "USER_INFO_CACHE:"
|
||||
friendRelationCache = "FRIEND_RELATION_CACHE:"
|
||||
blackListCache = "BLACK_LIST_CACHE:"
|
||||
groupCache = "GROUP_CACHE:"
|
||||
groupInfoCache = "GROUP_INFO_CACHE:"
|
||||
groupOwnerIDCache = "GROUP_OWNER_ID:"
|
||||
joinedGroupListCache = "JOINED_GROUP_LIST_CACHE:"
|
||||
groupMemberInfoCache = "GROUP_MEMBER_INFO_CACHE:"
|
||||
groupAllMemberInfoCache = "GROUP_ALL_MEMBER_INFO_CACHE:"
|
||||
allFriendInfoCache = "ALL_FRIEND_INFO_CACHE:"
|
||||
allDepartmentCache = "ALL_DEPARTMENT_CACHE:"
|
||||
allDepartmentMemberCache = "ALL_DEPARTMENT_MEMBER_CACHE:"
|
||||
userInfoCache = "USER_INFO_CACHE:"
|
||||
friendRelationCache = "FRIEND_RELATION_CACHE:"
|
||||
blackListCache = "BLACK_LIST_CACHE:"
|
||||
groupCache = "GROUP_CACHE:"
|
||||
groupInfoCache = "GROUP_INFO_CACHE:"
|
||||
groupOwnerIDCache = "GROUP_OWNER_ID:"
|
||||
joinedGroupListCache = "JOINED_GROUP_LIST_CACHE:"
|
||||
groupMemberInfoCache = "GROUP_MEMBER_INFO_CACHE:"
|
||||
groupAllMemberInfoCache = "GROUP_ALL_MEMBER_INFO_CACHE:"
|
||||
allFriendInfoCache = "ALL_FRIEND_INFO_CACHE:"
|
||||
allDepartmentCache = "ALL_DEPARTMENT_CACHE:"
|
||||
allDepartmentMemberCache = "ALL_DEPARTMENT_MEMBER_CACHE:"
|
||||
joinedSuperGroupListCache = "JOINED_SUPER_GROUP_LIST_CACHE:"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -41,13 +43,7 @@ func init() {
|
||||
panic(err.Error())
|
||||
}
|
||||
n += len(keys)
|
||||
//fmt.Printf("\n %s key found %d keys: %v, current cursor %d\n", key, n, keys, cursor)
|
||||
//if len(keys) > 0 {
|
||||
// err = db.DB.RDB.Del(context.Background(), keys...).Err()
|
||||
// if err != nil {
|
||||
// panic(err.Error())
|
||||
// }
|
||||
//}
|
||||
// for each for redis cluster
|
||||
for _, key := range keys {
|
||||
if err = db.DB.RDB.Del(context.Background(), key).Err(); err != nil {
|
||||
log.NewError("", fName, key, err.Error())
|
||||
@ -132,15 +128,28 @@ func DelJoinedGroupIDListFromCache(userID string) error {
|
||||
}
|
||||
|
||||
func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
||||
getGroupMemberIDList := func() (string, error) {
|
||||
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||
f := func() (string, error) {
|
||||
groupInfo, err := GetGroupInfoFromCache(groupID)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
return "", utils.Wrap(err, "GetGroupInfoFromCache failed")
|
||||
}
|
||||
var groupMemberIDList []string
|
||||
if groupInfo.GroupType == constant.SuperGroup {
|
||||
superGroup, err := db.DB.GetSuperGroup(groupID)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
groupMemberIDList = superGroup.MemberIDList
|
||||
} else {
|
||||
groupMemberIDList, err = imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
}
|
||||
bytes, err := json.Marshal(groupMemberIDList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, getGroupMemberIDList)
|
||||
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
@ -149,8 +158,8 @@ func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
||||
return groupMemberIDList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelGroupMemberIDListFromCache(userID string) error {
|
||||
err := db.DB.Rc.TagAsDeleted(groupCache + userID)
|
||||
func DelGroupMemberIDListFromCache(groupID string) error {
|
||||
err := db.DB.Rc.TagAsDeleted(groupCache + groupID)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -307,3 +316,31 @@ func GetAllDepartmentMembersFromCache() ([]db.DepartmentMember, error) {
|
||||
func DelAllDepartmentMembersFromCache() error {
|
||||
return db.DB.Rc.TagAsDeleted(allDepartmentMemberCache)
|
||||
}
|
||||
|
||||
func GetJoinedSuperGroupListFromCache(userID string) ([]string, error) {
|
||||
getJoinedSuperGroupIDList := func() (string, error) {
|
||||
userToSuperGroup, err := db.DB.GetSuperGroupByUserID(userID)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(userToSuperGroup.GroupIDList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
joinedSuperGroupListStr, err := db.DB.Rc.Fetch(joinedSuperGroupListCache+userID, time.Second, getJoinedSuperGroupIDList)
|
||||
var joinedSuperGroupList []string
|
||||
err = json.Unmarshal([]byte(joinedSuperGroupListStr), &joinedSuperGroupList)
|
||||
return joinedSuperGroupList, err
|
||||
}
|
||||
|
||||
func DelJoinedSuperGroupIDListFromCache(userID string) error {
|
||||
err := db.DB.Rc.TagAsDeleted(joinedSuperGroupListCache + userID)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetSuperGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
||||
return GetGroupMemberIDListFromCache(groupID)
|
||||
}
|
||||
|
||||
func DelSuperGroupMemberIDListFromCache(groupID string) error {
|
||||
return DelGroupMemberIDListFromCache(groupID)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user