mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
Conflicts: cmd/api/main.go go.mod internal/push/fcm/push.go internal/push/getui/push.go internal/push/logic/init.go internal/push/logic/push_to_client.go internal/push/push_rpc_server.go internal/rpc/conversation/conversaion.go pkg/common/db/controller/group.go pkg/proto/push/push.pb.go
This commit is contained in:
commit
e1a27e6aea
@ -23,9 +23,10 @@ import (
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/prome"
|
||||
"github.com/gin-gonic/gin"
|
||||
//"syscall"
|
||||
"Open_IM/pkg/common/constant"
|
||||
prome "Open_IM/pkg/common/prome"
|
||||
)
|
||||
|
||||
// @title open-IM-Server API
|
||||
|
@ -1,27 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
||||
"Open_IM/internal/rpc/conversation"
|
||||
"Open_IM/internal/startrpc"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
prome "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImConversationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.ConversationPrometheusPort[0], "conversationPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||
go func() {
|
||||
err := prome.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
startrpc.Start(config.Config.RpcPort.OpenImConversationPort, config.Config.RpcRegisterName.OpenImConversationName, config.Config.Prometheus.ConversationPrometheusPort, conversation.Start)
|
||||
}
|
||||
|
90
go.mod
90
go.mod
@ -1,6 +1,6 @@
|
||||
module Open_IM
|
||||
|
||||
go 1.16
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
firebase.google.com/go v3.13.0+incompatible
|
||||
@ -49,23 +49,111 @@ require (
|
||||
google.golang.org/api v0.103.0
|
||||
google.golang.org/grpc v1.52.3
|
||||
google.golang.org/protobuf v1.28.1
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
gorm.io/gorm v1.23.8
|
||||
)
|
||||
|
||||
require github.com/minio/minio-go v6.0.14+incompatible
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.105.0 // indirect
|
||||
cloud.google.com/go/compute v1.13.0 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.1 // indirect
|
||||
cloud.google.com/go/firestore v1.9.0 // indirect
|
||||
cloud.google.com/go/iam v0.8.0 // indirect
|
||||
cloud.google.com/go/longrunning v0.3.0 // indirect
|
||||
cloud.google.com/go/storage v1.27.0 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.0.9 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.3.9 // indirect
|
||||
github.com/aliyun/credentials-go v1.1.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 // indirect
|
||||
github.com/aws/smithy-go v1.12.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
github.com/go-openapi/spec v0.20.6 // indirect
|
||||
github.com/go-openapi/swag v0.21.1 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/go-zookeeper/zk v1.0.3 // indirect
|
||||
github.com/goccy/go-json v0.10.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
|
||||
github.com/golang/snappy v0.0.3 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.2 // indirect
|
||||
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/gofork v1.0.0 // indirect
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
|
||||
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jonboulle/clockwork v0.3.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/klauspost/cpuid v1.3.1 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/lestrrat-go/strftime v1.0.6 // indirect
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/minio/md5-simd v1.1.0 // indirect
|
||||
github.com/minio/sha256-simd v0.1.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rs/xid v1.2.1 // indirect
|
||||
github.com/tjfoc/gmsm v1.3.2 // indirect
|
||||
github.com/ugorji/go/codec v1.2.8 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.0.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.2 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
golang.org/x/time v0.1.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0
|
||||
|
74
go.sum
74
go.sum
@ -26,7 +26,6 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y
|
||||
cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4=
|
||||
cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc=
|
||||
cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA=
|
||||
cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U=
|
||||
cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A=
|
||||
cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc=
|
||||
cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU=
|
||||
@ -39,7 +38,6 @@ cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp
|
||||
cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE=
|
||||
cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw=
|
||||
cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY=
|
||||
cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg=
|
||||
cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI=
|
||||
cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4=
|
||||
cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk=
|
||||
@ -82,7 +80,6 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA=
|
||||
cloud.google.com/go/bigquery v1.43.0/go.mod h1:ZMQcXHsl+xmU1z36G2jNGZmKp9zNY5BUua5wDgmNCfw=
|
||||
cloud.google.com/go/bigquery v1.44.0/go.mod h1:0Y33VqXTEsbamHJvJHdFmtqHvMIY28aK1+dFsvaChGc=
|
||||
cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY=
|
||||
cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s=
|
||||
cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI=
|
||||
@ -145,7 +142,6 @@ cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4c
|
||||
cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/datastore v1.10.0/go.mod h1:PC5UzAmDEkAmkfaknstTYbNpgE49HAgW2J1gcgUfmdM=
|
||||
cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo=
|
||||
cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ=
|
||||
cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g=
|
||||
@ -167,7 +163,6 @@ cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1
|
||||
cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg=
|
||||
cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk=
|
||||
cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w=
|
||||
cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU=
|
||||
cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI=
|
||||
cloud.google.com/go/essentialcontacts v1.4.0/go.mod h1:8tRldvHYsmnBCHdFpvU+GL75oWiBKl80BiqlFh9tp+8=
|
||||
cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc=
|
||||
@ -195,7 +190,6 @@ cloud.google.com/go/gkemulticloud v0.4.0/go.mod h1:E9gxVBnseLWCk24ch+P9+B2CoDFJZ
|
||||
cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc=
|
||||
cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM=
|
||||
cloud.google.com/go/gsuiteaddons v1.4.0/go.mod h1:rZK5I8hht7u7HxFQcFei0+AtfS9uSushomRlg+3ua1o=
|
||||
cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c=
|
||||
cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY=
|
||||
cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc=
|
||||
cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc=
|
||||
@ -208,7 +202,6 @@ cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+
|
||||
cloud.google.com/go/ids v1.2.0/go.mod h1:5WXvp4n25S0rA/mQWAg1YEEBBq6/s+7ml1RDCW1IrcY=
|
||||
cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs=
|
||||
cloud.google.com/go/iot v1.4.0/go.mod h1:dIDxPOn0UvNDUMD8Ger7FIaTuvMkj+aGk94RPP0iV+g=
|
||||
cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA=
|
||||
cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg=
|
||||
cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6OgjA0=
|
||||
cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic=
|
||||
@ -217,13 +210,11 @@ cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiP
|
||||
cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8=
|
||||
cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8=
|
||||
cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08=
|
||||
cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw=
|
||||
cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE=
|
||||
cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs=
|
||||
cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc=
|
||||
cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE=
|
||||
cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM=
|
||||
cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI=
|
||||
cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4=
|
||||
cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w=
|
||||
cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE=
|
||||
@ -272,9 +263,6 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/pubsub v1.26.0/go.mod h1:QgBH3U/jdJy/ftjPhTkyXNj543Tin1pRYcdcPRnFIRI=
|
||||
cloud.google.com/go/pubsub v1.27.1/go.mod h1:hQN39ymbV9geqBnfQq6Xf63yNhUAhv9CZhzp5O6qsW0=
|
||||
cloud.google.com/go/pubsublite v1.5.0/go.mod h1:xapqNQ1CuLfGi23Yda/9l4bBCKz/wC3KIJ5gKcxveZg=
|
||||
cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4=
|
||||
cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o=
|
||||
cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk=
|
||||
@ -329,7 +317,6 @@ cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5
|
||||
cloud.google.com/go/serviceusage v1.4.0/go.mod h1:SB4yxXSaYVuUBYUml6qklyONXNLt83U0Rb+CXyhjEeU=
|
||||
cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4=
|
||||
cloud.google.com/go/shell v1.4.0/go.mod h1:HDxPzZf3GkDdhExzD/gs8Grqk+dmYcEjGShZgYa9URw=
|
||||
cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos=
|
||||
cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM=
|
||||
cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ=
|
||||
cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0=
|
||||
@ -370,7 +357,6 @@ cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb
|
||||
cloud.google.com/go/vision/v2 v2.5.0/go.mod h1:MmaezXOOE+IWa+cS7OhRRLK2cNv1ZL98zhqFFZaaH2E=
|
||||
cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE=
|
||||
cloud.google.com/go/vmmigration v1.3.0/go.mod h1:oGJ6ZgGPQOFdjHuocGcLqX4lc98YQ7Ygq8YQwHh9A7g=
|
||||
cloud.google.com/go/vmwareengine v0.1.0/go.mod h1:RsdNEf/8UDvKllXhMz5J40XxDrNJNN4sagiox+OI208=
|
||||
cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w=
|
||||
cloud.google.com/go/vpcaccess v1.5.0/go.mod h1:drmg4HLk9NkZpGfCmZ3Tz0Bwnm2+DKqViEpeEpOq0m8=
|
||||
cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE=
|
||||
@ -465,8 +451,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
|
||||
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/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
@ -517,9 +501,7 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/gzip v0.0.5 h1:mhnVU32YnnBh2LPH2iqRqsA/eR7SAqRaD388jL2s/j0=
|
||||
github.com/gin-contrib/gzip v0.0.5/go.mod h1:OPIK6HR0Um2vNmBUTlayD7qle4yVVRZT0PyhdUigrKk=
|
||||
@ -527,12 +509,13 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY=
|
||||
github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
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-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
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=
|
||||
@ -564,7 +547,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
|
||||
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
@ -574,11 +556,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC
|
||||
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/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg=
|
||||
github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
|
||||
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
@ -657,12 +636,10 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
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.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.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@ -695,7 +672,6 @@ github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2I
|
||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
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/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
|
||||
@ -738,7 +714,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
|
||||
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.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
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=
|
||||
@ -772,14 +747,14 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
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=
|
||||
github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o=
|
||||
github.com/minio/minio-go v6.0.14+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8=
|
||||
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=
|
||||
@ -801,29 +776,17 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
|
||||
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=
|
||||
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/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/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/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.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=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
|
||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
|
||||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
||||
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A=
|
||||
@ -879,7 +842,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
|
||||
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/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
@ -918,10 +880,7 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
|
||||
github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM=
|
||||
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0=
|
||||
github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
@ -942,7 +901,6 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4=
|
||||
go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
||||
@ -967,7 +925,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/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-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
@ -984,7 +941,6 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
|
||||
golang.org/x/image v0.3.0 h1:HTDXbdK9bjfSWkPzDJIw89W8CAtfFGduujWs33NLLsg=
|
||||
golang.org/x/image v0.3.0/go.mod h1:fXd9211C/0VTlYuAcOhW8dY/RtEJqODXOWBDpmYBf+A=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@ -1010,12 +966,10 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
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/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -1038,7 +992,6 @@ 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=
|
||||
@ -1053,11 +1006,9 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
|
||||
golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
@ -1118,7 +1069,6 @@ golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -1129,11 +1079,8 @@ 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-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-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=
|
||||
@ -1159,7 +1106,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
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=
|
||||
@ -1180,7 +1126,6 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -1207,7 +1152,6 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
|
||||
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/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
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=
|
||||
@ -1225,7 +1169,6 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
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=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA=
|
||||
golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@ -1276,7 +1219,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u
|
||||
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=
|
||||
@ -1286,7 +1228,6 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
||||
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1461,10 +1402,7 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz
|
||||
google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
|
||||
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
|
||||
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo=
|
||||
google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg=
|
||||
google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg=
|
||||
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg=
|
||||
google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg=
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
@ -1502,7 +1440,6 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu
|
||||
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
|
||||
google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ=
|
||||
google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
@ -1530,15 +1467,12 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
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/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.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/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=
|
||||
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=
|
||||
|
@ -1,7 +1,7 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
@ -1,10 +1,9 @@
|
||||
package conversation
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -2,7 +2,7 @@ package friend
|
||||
|
||||
//import (
|
||||
// jsonData "Open_IM/internal/utils"
|
||||
// api "Open_IM/pkg/api_struct"
|
||||
// api "Open_IM/pkg/apistruct"
|
||||
// "Open_IM/pkg/common/config"
|
||||
// "Open_IM/pkg/common/log"
|
||||
// "Open_IM/pkg/common/tokenverify"
|
||||
|
@ -1,8 +1,8 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
common "Open_IM/internal/api_to_rpc"
|
||||
api "Open_IM/pkg/api_struct"
|
||||
common "Open_IM/internal/api2rpc"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
rpc "Open_IM/pkg/proto/friend"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -2,7 +2,7 @@ package group
|
||||
|
||||
//import (
|
||||
// common "Open_IM/internal/api_to_rpc"
|
||||
// api "Open_IM/pkg/api_struct"
|
||||
// api "Open_IM/pkg/apistruct"
|
||||
// "Open_IM/pkg/common/config"
|
||||
// "Open_IM/pkg/common/constant"
|
||||
// "Open_IM/pkg/common/log"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/api_struct"
|
||||
"Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"errors"
|
||||
@ -69,10 +69,10 @@ func KickGroupMember(c *gin.Context) {
|
||||
// 默认 全部自动
|
||||
NewRpc(NewApiBind[apistruct.KickGroupMemberReq, apistruct.KickGroupMemberResp](c), "", group.NewGroupClient, group.GroupClient.KickGroupMember).Execute()
|
||||
// 可以自定义编辑请求和响应
|
||||
a := NewRpc(NewApiBind[api_struct.KickGroupMemberReq, api_struct.KickGroupMemberResp](c), "", group.NewGroupClient, group.GroupClient.KickGroupMember)
|
||||
a.Before(func(apiReq *api_struct.KickGroupMemberReq, rpcReq *group.KickGroupMemberReq, bind func() error) error {
|
||||
a := NewRpc(NewApiBind[apistruct.KickGroupMemberReq, apistruct.KickGroupMemberResp](c), "", group.NewGroupClient, group.GroupClient.KickGroupMember)
|
||||
a.Before(func(apiReq *apistruct.KickGroupMemberReq, rpcReq *group.KickGroupMemberReq, bind func() error) error {
|
||||
return bind()
|
||||
}).After(func(rpcResp *group.KickGroupMemberResp, apiResp *api_struct.KickGroupMemberResp, bind func() error) error {
|
||||
}).After(func(rpcResp *group.KickGroupMemberResp, apiResp *apistruct.KickGroupMemberResp, bind func() error) error {
|
||||
return bind()
|
||||
}).Execute()
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package group
|
||||
|
||||
//import (
|
||||
// jsonData "Open_IM/internal/utils"
|
||||
// api "Open_IM/pkg/api_struct"
|
||||
// api "Open_IM/pkg/apistruct"
|
||||
// "Open_IM/pkg/common/config"
|
||||
// "Open_IM/pkg/common/log"
|
||||
// "Open_IM/pkg/common/token_verify"
|
||||
|
@ -7,10 +7,9 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"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/tokenverify"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
|
@ -7,12 +7,11 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -1,12 +1,11 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/msg"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -1,12 +1,11 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
|
||||
"Open_IM/pkg/getcdv3"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
@ -1,8 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
"Open_IM/pkg/common/db"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -1,10 +1,9 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
_ "Open_IM/pkg/common/tokenverify"
|
||||
|
@ -1,8 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
"Open_IM/pkg/common/db"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -1,8 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
"Open_IM/pkg/common/db"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/utils"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
@ -1,17 +1,16 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
jsonData "Open_IM/internal/utils"
|
||||
api "Open_IM/pkg/api_struct"
|
||||
api "Open_IM/pkg/apistruct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
cacheRpc "Open_IM/pkg/proto/cache"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
jsonData "Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -17,5 +17,5 @@ func NewBlackChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *BlackChecker {
|
||||
|
||||
// possibleBlackUserID是否被userID拉黑,也就是是否在userID的黑名单中
|
||||
func (b *BlackChecker) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) {
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) {
|
||||
}
|
||||
|
||||
func (c *ConversationChecker) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
|
||||
panic("implement me")
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package check
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
"Open_IM/pkg/proto/friend"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
@ -24,7 +25,7 @@ func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err := friend.NewFriendClient(cc).GetPaginationFriends(ctx, &friend.GetPaginationFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
|
||||
r, err := friend.NewFriendClient(cc).GetDesignatedFriends(ctx, &friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -37,5 +38,38 @@ func (f *FriendChecker) getConn() (*grpc.ClientConn, error) {
|
||||
|
||||
// possibleFriendUserID是否在userID的好友中
|
||||
func (f *FriendChecker) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp, err := friend.NewFriendClient(cc).IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return resp.InUser1Friends, nil
|
||||
|
||||
}
|
||||
|
||||
func (f *FriendChecker) GetAllPageFriends(ctx context.Context, ownerUserID string) (resp []*sdkws.FriendInfo, err error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
page := int32(0)
|
||||
req := friend.GetPaginationFriendsReq{UserID: ownerUserID}
|
||||
for {
|
||||
req.Pagination = &sdkws.RequestPagination{PageNumber: page, ShowNumber: constant.ShowNumber}
|
||||
tmp, err := friend.NewFriendClient(cc).GetPaginationFriends(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(tmp.FriendsInfo) == 0 {
|
||||
if tmp.Total == int32(len(resp)) {
|
||||
return resp, nil
|
||||
}
|
||||
return nil, constant.ErrData.Wrap("The total number of results and expectations are different, but result is nil")
|
||||
}
|
||||
resp = append(resp, tmp.FriendsInfo...)
|
||||
page++
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
//func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*sdkws.UserInfo, error) {
|
||||
// return nil, errors.New("TODO:GetUserInfo")
|
||||
//}
|
||||
|
||||
func NewUserCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *UserCheck {
|
||||
return &UserCheck{
|
||||
zk: zk,
|
||||
@ -104,5 +100,12 @@ func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string,
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
||||
|
||||
cc, err := u.getConn()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
resp, err := user.NewUserClient(cc).GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||
UserID: userID,
|
||||
})
|
||||
return resp.GlobalRecvMsgOpt, err
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqList []uint32, operationID string) {
|
||||
DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, SeqList: seqList}
|
||||
func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqs []int64, operationID string) {
|
||||
DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, Seqs: seqs}
|
||||
c.MessageNotification(ctx, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
prome "Open_IM/pkg/common/prometheus"
|
||||
prome "Open_IM/pkg/common/prome"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
@ -3,7 +3,6 @@ package msggateway
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/prome"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
|
@ -3,14 +3,12 @@ package new
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -35,35 +33,52 @@ const (
|
||||
type Client struct {
|
||||
w *sync.Mutex
|
||||
conn LongConn
|
||||
PlatformID int32
|
||||
PushedMaxSeq uint32
|
||||
IsCompress bool
|
||||
platformID int
|
||||
isCompress bool
|
||||
userID string
|
||||
IsBackground bool
|
||||
token string
|
||||
isBackground bool
|
||||
connID string
|
||||
onlineAt int64 // 上线时间戳(毫秒)
|
||||
handler MessageHandler
|
||||
unregisterChan chan *Client
|
||||
compressor Compressor
|
||||
encoder Encoder
|
||||
userContext UserConnContext
|
||||
validate *validator.Validate
|
||||
closed bool
|
||||
}
|
||||
|
||||
func newClient(conn LongConn, isCompress bool, userID string, isBackground bool, token string,
|
||||
connID string, onlineAt int64, handler MessageHandler, unregisterChan chan *Client) *Client {
|
||||
func newClient(ctx *UserConnContext, conn LongConn, isCompress bool, compressor Compressor, encoder Encoder,
|
||||
handler MessageHandler, unregisterChan chan *Client, validate *validator.Validate) *Client {
|
||||
return &Client{
|
||||
w: new(sync.Mutex),
|
||||
conn: conn,
|
||||
IsCompress: isCompress,
|
||||
userID: userID, IsBackground: isBackground, token: token,
|
||||
connID: connID,
|
||||
onlineAt: onlineAt,
|
||||
platformID: utils.StringToInt(ctx.GetPlatformID()),
|
||||
isCompress: isCompress,
|
||||
userID: ctx.GetUserID(),
|
||||
compressor: compressor,
|
||||
encoder: encoder,
|
||||
connID: ctx.GetConnID(),
|
||||
onlineAt: utils.GetCurrentTimestampByMill(),
|
||||
handler: handler,
|
||||
unregisterChan: unregisterChan,
|
||||
validate: validate,
|
||||
}
|
||||
}
|
||||
func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, isCompress bool, compressor Compressor, encoder Encoder,
|
||||
handler MessageHandler, unregisterChan chan *Client, validate *validator.Validate) {
|
||||
c.w = new(sync.Mutex)
|
||||
c.conn = conn
|
||||
c.platformID = utils.StringToInt(ctx.GetPlatformID())
|
||||
c.isCompress = isCompress
|
||||
c.userID = ctx.GetUserID()
|
||||
c.compressor = compressor
|
||||
c.encoder = encoder
|
||||
c.connID = ctx.GetConnID()
|
||||
c.onlineAt = utils.GetCurrentTimestampByMill()
|
||||
c.handler = handler
|
||||
c.unregisterChan = unregisterChan
|
||||
c.validate = validate
|
||||
}
|
||||
func (c *Client) readMessage() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@ -77,7 +92,7 @@ func (c *Client) readMessage() {
|
||||
if returnErr != nil {
|
||||
break
|
||||
}
|
||||
if c.closed == true {
|
||||
if c.closed == true { //连接刚置位已经关闭,但是协程还没退出的场景
|
||||
break
|
||||
}
|
||||
switch messageType {
|
||||
@ -119,7 +134,8 @@ func (c *Client) handleMessage(message []byte) error {
|
||||
return errors.New("exception conn userID not same to req userID")
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "operationID", binaryReq.OperationID)
|
||||
ctx = context.WithValue(ctx, c.connID, binaryReq.OperationID)
|
||||
ctx = context.WithValue(ctx, OPERATION_ID, binaryReq.OperationID)
|
||||
ctx = context.WithValue(ctx, "userID", binaryReq.SendID)
|
||||
var messageErr error
|
||||
var resp []byte
|
||||
@ -173,7 +189,7 @@ func (c *Client) writeMsg(resp Resp) error {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
_ = c.conn.SetWriteTimeout(60)
|
||||
if c.IsCompress {
|
||||
if c.isCompress {
|
||||
var compressErr error
|
||||
resultBuf, compressErr = c.compressor.Compress(encodeBuf)
|
||||
if compressErr != nil {
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io/ioutil"
|
||||
"open_im_sdk/pkg/utils"
|
||||
)
|
||||
|
||||
type Compressor interface {
|
||||
|
10
internal/msggateway/new/constant.go
Normal file
10
internal/msggateway/new/constant.go
Normal file
@ -0,0 +1,10 @@
|
||||
package new
|
||||
|
||||
const (
|
||||
USERID = "sendID"
|
||||
PLATFORM_ID = "platformID"
|
||||
TOKEN = "token"
|
||||
OPERATION_ID = "operationID"
|
||||
COMPRESSION = "compression"
|
||||
GZIP_COMPRESSION_PROTOCAL = "gzip"
|
||||
)
|
@ -1,6 +1,10 @@
|
||||
package new
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type UserConnContext struct {
|
||||
RespWriter http.ResponseWriter
|
||||
@ -19,9 +23,32 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
|
||||
RemoteAddr: req.RemoteAddr,
|
||||
}
|
||||
}
|
||||
func (c *UserConnContext) Query(key string) string {
|
||||
return c.Req.URL.Query().Get(key)
|
||||
func (c *UserConnContext) Query(key string) (string, bool) {
|
||||
var value string
|
||||
if value = c.Req.URL.Query().Get(key); value == "" {
|
||||
return value, false
|
||||
}
|
||||
return value, true
|
||||
}
|
||||
func (c *UserConnContext) GetHeader(key string) string {
|
||||
return c.Req.Header.Get(key)
|
||||
func (c *UserConnContext) GetHeader(key string) (string, bool) {
|
||||
var value string
|
||||
if value = c.Req.Header.Get(key); value == "" {
|
||||
return value, false
|
||||
}
|
||||
return value, true
|
||||
}
|
||||
func (c *UserConnContext) SetHeader(key, value string) {
|
||||
c.RespWriter.Header().Set(key, value)
|
||||
}
|
||||
func (c *UserConnContext) ErrReturn(error string, code int) {
|
||||
http.Error(c.RespWriter, error, code)
|
||||
}
|
||||
func (c *UserConnContext) GetConnID() string {
|
||||
return c.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))
|
||||
}
|
||||
func (c *UserConnContext) GetUserID() string {
|
||||
return c.Req.URL.Query().Get(USERID)
|
||||
}
|
||||
func (c *UserConnContext) GetPlatformID() string {
|
||||
return c.Req.URL.Query().Get(PLATFORM_ID)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package new
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"open_im_sdk/pkg/utils"
|
||||
)
|
||||
|
||||
type Encoder interface {
|
||||
|
44
internal/msggateway/new/http_error.go
Normal file
44
internal/msggateway/new/http_error.go
Normal file
@ -0,0 +1,44 @@
|
||||
package new
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func httpError(ctx *UserConnContext, err error) {
|
||||
code := http.StatusUnauthorized
|
||||
ctx.SetHeader("Sec-Websocket-Version", "13")
|
||||
ctx.SetHeader("ws_err_msg", err.Error())
|
||||
if errors.Is(err, constant.ErrTokenExpired) {
|
||||
code = int(constant.ErrTokenExpired.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenInvalid) {
|
||||
code = int(constant.ErrTokenInvalid.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenMalformed) {
|
||||
code = int(constant.ErrTokenMalformed.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenNotValidYet) {
|
||||
code = int(constant.ErrTokenNotValidYet.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenUnknown) {
|
||||
code = int(constant.ErrTokenUnknown.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenKicked) {
|
||||
code = int(constant.ErrTokenKicked.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenDifferentPlatformID) {
|
||||
code = int(constant.ErrTokenDifferentPlatformID.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrTokenDifferentUserID) {
|
||||
code = int(constant.ErrTokenDifferentUserID.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrConnOverMaxNumLimit) {
|
||||
code = int(constant.ErrConnOverMaxNumLimit.ErrCode)
|
||||
}
|
||||
if errors.Is(err, constant.ErrConnArgsErr) {
|
||||
code = int(constant.ErrConnArgsErr.ErrCode)
|
||||
}
|
||||
ctx.ErrReturn(err.Error(), code)
|
||||
}
|
@ -26,19 +26,37 @@ type LongConn interface {
|
||||
SetConnNil()
|
||||
//Check the connection of the current and when it was sent are the same
|
||||
CheckSendConnDiffNow() bool
|
||||
//
|
||||
GenerateLongConn(w http.ResponseWriter, r *http.Request) error
|
||||
}
|
||||
type GWebSocket struct {
|
||||
protocolType int
|
||||
conn *websocket.Conn
|
||||
handshakeTimeout time.Duration
|
||||
readBufferSize, WriteBufferSize int
|
||||
}
|
||||
|
||||
func NewDefault(protocolType int) *GWebSocket {
|
||||
return &GWebSocket{protocolType: protocolType}
|
||||
func newGWebSocket(protocolType int, handshakeTimeout time.Duration, readBufferSize int) *GWebSocket {
|
||||
return &GWebSocket{protocolType: protocolType, handshakeTimeout: handshakeTimeout, readBufferSize: readBufferSize}
|
||||
}
|
||||
|
||||
func (d *GWebSocket) Close() error {
|
||||
return d.conn.Close()
|
||||
}
|
||||
func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error {
|
||||
upgrader := &websocket.Upgrader{
|
||||
HandshakeTimeout: d.handshakeTimeout,
|
||||
ReadBufferSize: d.readBufferSize,
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
}
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.conn = conn
|
||||
return nil
|
||||
|
||||
}
|
||||
func (d *GWebSocket) WriteMessage(messageType int, message []byte) error {
|
||||
d.setSendConn(d.conn)
|
||||
return d.conn.WriteMessage(messageType, message)
|
||||
|
@ -1,6 +1,9 @@
|
||||
package new
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"Open_IM/internal/common/check"
|
||||
"context"
|
||||
)
|
||||
|
||||
type Req struct {
|
||||
ReqIdentifier int32 `json:"reqIdentifier" validate:"required"`
|
||||
@ -30,6 +33,11 @@ type MessageHandler interface {
|
||||
var _ MessageHandler = (*GrpcHandler)(nil)
|
||||
|
||||
type GrpcHandler struct {
|
||||
msg *check.MsgCheck
|
||||
}
|
||||
|
||||
func NewGrpcHandler(msg *check.MsgCheck) *GrpcHandler {
|
||||
return &GrpcHandler{msg: msg}
|
||||
}
|
||||
|
||||
func (g GrpcHandler) GetSeq(context context.Context, data Req) ([]byte, error) {
|
||||
|
@ -1,22 +1,24 @@
|
||||
package new
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/utils"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gorilla/websocket"
|
||||
"net/http"
|
||||
"open_im_sdk/pkg/utils"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
var bufferPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]byte, 1000)
|
||||
},
|
||||
}
|
||||
|
||||
type LongConnServer interface {
|
||||
Run() error
|
||||
}
|
||||
@ -29,7 +31,7 @@ type Server struct {
|
||||
}
|
||||
type WsServer struct {
|
||||
port int
|
||||
wsMaxConnNum int
|
||||
wsMaxConnNum int64
|
||||
wsUpGrader *websocket.Upgrader
|
||||
registerChan chan *Client
|
||||
unregisterChan chan *Client
|
||||
@ -37,8 +39,12 @@ type WsServer struct {
|
||||
clientPool sync.Pool
|
||||
onlineUserNum int64
|
||||
onlineUserConnNum int64
|
||||
compressor Compressor
|
||||
gzipCompressor Compressor
|
||||
encoder Encoder
|
||||
handler MessageHandler
|
||||
handshakeTimeout time.Duration
|
||||
readBufferSize, WriteBufferSize int
|
||||
validate *validator.Validate
|
||||
}
|
||||
|
||||
func newWsServer(opts ...Option) (*WsServer, error) {
|
||||
@ -53,16 +59,16 @@ func newWsServer(opts ...Option) (*WsServer, error) {
|
||||
return &WsServer{
|
||||
port: config.port,
|
||||
wsMaxConnNum: config.maxConnNum,
|
||||
wsUpGrader: &websocket.Upgrader{
|
||||
HandshakeTimeout: config.handshakeTimeout,
|
||||
ReadBufferSize: config.messageMaxMsgLength,
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
},
|
||||
handshakeTimeout: config.handshakeTimeout,
|
||||
readBufferSize: config.messageMaxMsgLength,
|
||||
clientPool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(Client)
|
||||
},
|
||||
},
|
||||
validate: validator.New(),
|
||||
clients: newUserMap(),
|
||||
handler: NewGrpcHandler(),
|
||||
}, nil
|
||||
}
|
||||
func (ws *WsServer) Run() error {
|
||||
@ -72,53 +78,115 @@ func (ws *WsServer) Run() error {
|
||||
select {
|
||||
case client = <-ws.registerChan:
|
||||
ws.registerClient(client)
|
||||
case client = <-h.unregisterChan:
|
||||
h.unregisterClient(client)
|
||||
case msg = <-h.readChan:
|
||||
h.messageHandler(msg)
|
||||
case client = <-ws.unregisterChan:
|
||||
ws.unregisterClient(client)
|
||||
}
|
||||
}
|
||||
}()
|
||||
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
|
||||
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) //Start listening
|
||||
}
|
||||
|
||||
func (ws *WsServer) registerClient(client *Client) {
|
||||
var (
|
||||
ok bool
|
||||
userOK bool
|
||||
clientOK bool
|
||||
cli *Client
|
||||
)
|
||||
|
||||
if cli, ok = h.clients.Get(client.key); ok == false {
|
||||
h.clients.Set(client.key, client)
|
||||
atomic.AddInt64(&h.onlineConnections, 1)
|
||||
fmt.Println("R在线用户数量:", h.onlineConnections)
|
||||
return
|
||||
cli, userOK,clientOK = ws.clients.Get(client.userID,client.platformID)
|
||||
if !userOK {
|
||||
ws.clients.Set(client.userID,client)
|
||||
atomic.AddInt64(&ws.onlineUserNum, 1)
|
||||
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
||||
fmt.Println("R在线用户数量:", ws.onlineUserNum)
|
||||
fmt.Println("R在线用户连接数量:", ws.onlineUserConnNum)
|
||||
}else{
|
||||
if clientOK {//已经有同平台的连接存在
|
||||
ws.clients.Set(client.userID,client)
|
||||
ws.multiTerminalLoginChecker(cli)
|
||||
}else{
|
||||
ws.clients.Set(client.userID,client)
|
||||
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
||||
fmt.Println("R在线用户数量:", ws.onlineUserNum)
|
||||
fmt.Println("R在线用户连接数量:", ws.onlineUserConnNum)
|
||||
}
|
||||
}
|
||||
|
||||
if client.onlineAt > cli.onlineAt {
|
||||
h.clients.Set(client.key, client)
|
||||
h.close(cli)
|
||||
return
|
||||
}
|
||||
h.close(client)
|
||||
}
|
||||
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
|
||||
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) //Start listening
|
||||
|
||||
func (ws *WsServer) multiTerminalLoginChecker(client *Client) {
|
||||
|
||||
}
|
||||
func (ws *WsServer) unregisterClient(client *Client) {
|
||||
isDeleteUser:=ws.clients.delete(client.userID,client.platformID)
|
||||
if isDeleteUser {
|
||||
atomic.AddInt64(&ws.onlineUserNum, -1)
|
||||
}
|
||||
atomic.AddInt64(&ws.onlineUserConnNum, -1)
|
||||
fmt.Println("R在线用户数量:", ws.onlineUserNum)
|
||||
fmt.Println("R在线用户连接数量:", ws.onlineUserConnNum)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
context := newContext(w, r)
|
||||
if isPass, compression := ws.headerCheck(w, r, operationID); isPass {
|
||||
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
|
||||
if err != nil {
|
||||
log.Error(operationID, "upgrade http conn err", err.Error(), query)
|
||||
if ws.onlineUserConnNum >= ws.wsMaxConnNum {
|
||||
httpError(context, constant.ErrConnOverMaxNumLimit)
|
||||
return
|
||||
} else {
|
||||
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0, compression, query["sendID"][0], false, query["token"][0], conn.RemoteAddr().String() + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))}
|
||||
userCount++
|
||||
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], newConn.connID, operationID)
|
||||
go ws.readMsg(newConn)
|
||||
}
|
||||
} else {
|
||||
log.Error(operationID, "headerCheck failed ")
|
||||
var (
|
||||
token string
|
||||
userID string
|
||||
platformID string
|
||||
exists bool
|
||||
compression bool
|
||||
compressor Compressor
|
||||
|
||||
)
|
||||
|
||||
token, exists = context.Query(TOKEN)
|
||||
if !exists {
|
||||
httpError(context, constant.ErrConnArgsErr)
|
||||
return
|
||||
}
|
||||
userID, exists = context.Query(USERID)
|
||||
if !exists {
|
||||
httpError(context, constant.ErrConnArgsErr)
|
||||
return
|
||||
}
|
||||
platformID, exists = context.Query(PLATFORM_ID)
|
||||
if !exists {
|
||||
httpError(context, constant.ErrConnArgsErr)
|
||||
return
|
||||
}
|
||||
err := tokenverify.WsVerifyToken(token, userID, platformID)
|
||||
if err != nil {
|
||||
httpError(context, err)
|
||||
return
|
||||
}
|
||||
wsLongConn:=newGWebSocket(constant.WebSocket,ws.handshakeTimeout,ws.readBufferSize)
|
||||
err = wsLongConn.GenerateLongConn(w, r)
|
||||
if err != nil {
|
||||
httpError(context, err)
|
||||
return
|
||||
}
|
||||
compressProtoc, exists := context.Query(COMPRESSION)
|
||||
if exists {
|
||||
if compressProtoc==GZIP_COMPRESSION_PROTOCAL{
|
||||
compression = true
|
||||
compressor = ws.gzipCompressor
|
||||
}
|
||||
}
|
||||
compressProtoc, exists = context.GetHeader(COMPRESSION)
|
||||
if exists {
|
||||
if compressProtoc==GZIP_COMPRESSION_PROTOCAL {
|
||||
compression = true
|
||||
compressor = ws.gzipCompressor
|
||||
}
|
||||
}
|
||||
client:=ws.clientPool.Get().(*Client)
|
||||
client.ResetClient(context,wsLongConn,compression,compressor,ws.encoder,ws.handler,ws.unregisterChan,ws.validate)
|
||||
ws.registerChan <- client
|
||||
go client.readMessage()
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ type configs struct {
|
||||
//长连接监听端口
|
||||
port int
|
||||
//长连接允许最大链接数
|
||||
maxConnNum int
|
||||
maxConnNum int64
|
||||
//连接握手超时时间
|
||||
handshakeTimeout time.Duration
|
||||
//允许消息最大长度
|
||||
@ -19,7 +19,7 @@ func WithPort(port int) Option {
|
||||
opt.port = port
|
||||
}
|
||||
}
|
||||
func WithMaxConnNum(num int) Option {
|
||||
func WithMaxConnNum(num int64) Option {
|
||||
return func(opt *configs) {
|
||||
opt.maxConnNum = num
|
||||
}
|
||||
|
@ -9,24 +9,24 @@ type UserMap struct {
|
||||
func newUserMap() *UserMap {
|
||||
return &UserMap{}
|
||||
}
|
||||
func (u *UserMap) GetAll(key string) []*Client {
|
||||
func (u *UserMap) GetAll(key string) ([]*Client, bool) {
|
||||
allClients, ok := u.m.Load(key)
|
||||
if ok {
|
||||
return allClients.([]*Client)
|
||||
return allClients.([]*Client), ok
|
||||
}
|
||||
return nil
|
||||
return nil, ok
|
||||
}
|
||||
func (u *UserMap) Get(key string, platformID int32) (*Client, bool) {
|
||||
allClients, existed := u.m.Load(key)
|
||||
if existed {
|
||||
func (u *UserMap) Get(key string, platformID int) (*Client, bool, bool) {
|
||||
allClients, userExisted := u.m.Load(key)
|
||||
if userExisted {
|
||||
for _, client := range allClients.([]*Client) {
|
||||
if client.PlatformID == platformID {
|
||||
return client, existed
|
||||
if client.platformID == platformID {
|
||||
return client, userExisted, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
return nil, userExisted, false
|
||||
}
|
||||
return nil, existed
|
||||
return nil, userExisted, false
|
||||
}
|
||||
func (u *UserMap) Set(key string, v *Client) {
|
||||
allClients, existed := u.m.Load(key)
|
||||
@ -40,24 +40,25 @@ func (u *UserMap) Set(key string, v *Client) {
|
||||
u.m.Store(key, clients)
|
||||
}
|
||||
}
|
||||
func (u *UserMap) delete(key string, platformID int32) {
|
||||
func (u *UserMap) delete(key string, platformID int) (isDeleteUser bool) {
|
||||
allClients, existed := u.m.Load(key)
|
||||
if existed {
|
||||
oldClients := allClients.([]*Client)
|
||||
|
||||
a := make([]*Client, len(oldClients))
|
||||
a := make([]*Client, 3)
|
||||
for _, client := range oldClients {
|
||||
if client.PlatformID != platformID {
|
||||
if client.platformID != platformID {
|
||||
a = append(a, client)
|
||||
}
|
||||
}
|
||||
if len(a) == 0 {
|
||||
u.m.Delete(key)
|
||||
return true
|
||||
} else {
|
||||
u.m.Store(key, a)
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
return existed
|
||||
}
|
||||
func (u *UserMap) DeleteAll(key string) {
|
||||
u.m.Delete(key)
|
||||
|
@ -12,15 +12,13 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gorilla/websocket"
|
||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type RPCServer struct {
|
||||
|
@ -3,9 +3,8 @@ package msggateway
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
prome "Open_IM/pkg/common/prometheus"
|
||||
prome "Open_IM/pkg/common/prome"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
|
235
internal/objstorage/controller.go
Normal file
235
internal/objstorage/controller.go
Normal file
@ -0,0 +1,235 @@
|
||||
package objstorage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewController(i Interface, kv KV) (*Controller, error) {
|
||||
if err := i.Init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Controller{
|
||||
i: i,
|
||||
kv: kv,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Controller struct {
|
||||
i Interface
|
||||
//i *minioImpl
|
||||
kv KV
|
||||
}
|
||||
|
||||
func (c *Controller) key(v string) string {
|
||||
return "OBJECT_STORAGE:" + c.i.Name() + ":" + v
|
||||
}
|
||||
|
||||
func (c *Controller) putKey(v string) string {
|
||||
return c.key("put:" + v)
|
||||
}
|
||||
|
||||
func (c *Controller) pathKey(v string) string {
|
||||
return c.key("path:" + v)
|
||||
}
|
||||
|
||||
func (c *Controller) ApplyPut(ctx context.Context, args *FragmentPutArgs) (*PutAddr, error) {
|
||||
if data, err := c.kv.Get(ctx, c.pathKey(args.Hash)); err == nil {
|
||||
// 服务器已存在
|
||||
var src BucketFile
|
||||
if err := json.Unmarshal([]byte(data), &src); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var bucket string
|
||||
if args.ClearTime <= 0 {
|
||||
bucket = c.i.PermanentBucket()
|
||||
} else {
|
||||
bucket = c.i.ClearBucket()
|
||||
}
|
||||
dst := &BucketFile{
|
||||
Bucket: bucket,
|
||||
Name: args.Name,
|
||||
}
|
||||
// 直接拷贝一份
|
||||
err := c.i.CopyObjetInfo(ctx, &src, dst)
|
||||
if err == nil {
|
||||
info, err := c.i.GetObjectInfo(ctx, dst)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PutAddr{
|
||||
ResourceURL: info.URL,
|
||||
}, nil
|
||||
} else if !c.i.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
} else if !c.kv.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
// 上传逻辑
|
||||
name := args.Name
|
||||
effective := time.Now().Add(args.EffectiveTime)
|
||||
prefix := c.Prefix(&args.PutArgs)
|
||||
if minSize := c.i.MinMultipartSize(); args.FragmentSize > 0 && args.FragmentSize < minSize {
|
||||
args.FragmentSize = minSize
|
||||
}
|
||||
var pack int64
|
||||
if args.FragmentSize <= 0 || args.Size <= args.FragmentSize {
|
||||
pack = 1
|
||||
} else {
|
||||
pack = args.Size / args.FragmentSize
|
||||
if args.Size%args.FragmentSize > 0 {
|
||||
pack++
|
||||
}
|
||||
}
|
||||
p := path.Join(path.Dir(args.Name), time.Now().Format("20060102"))
|
||||
info := putInfo{
|
||||
Bucket: c.i.UploadBucket(),
|
||||
Fragments: make([]string, 0, pack),
|
||||
FragmentSize: args.FragmentSize,
|
||||
Name: name,
|
||||
Hash: args.Hash,
|
||||
Size: args.Size,
|
||||
}
|
||||
if args.ClearTime > 0 {
|
||||
t := time.Now().Add(args.ClearTime).UnixMilli()
|
||||
info.ClearTime = &t
|
||||
}
|
||||
putURLs := make([]string, 0, pack)
|
||||
for i := int64(1); i <= pack; i++ {
|
||||
name := prefix + "_" + strconv.FormatInt(i, 10) + path.Ext(args.Name)
|
||||
name = path.Join(p, name)
|
||||
info.Fragments = append(info.Fragments, name)
|
||||
args.Name = name
|
||||
put, err := c.i.ApplyPut(ctx, &ApplyPutArgs{
|
||||
Bucket: info.Bucket,
|
||||
Name: name,
|
||||
Effective: args.EffectiveTime,
|
||||
Header: args.Header,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
putURLs = append(putURLs, put.URL)
|
||||
}
|
||||
data, err := json.Marshal(&info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.kv.Set(ctx, c.putKey(prefix), string(data), args.EffectiveTime); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var fragmentSize int64
|
||||
if pack == 1 {
|
||||
fragmentSize = args.Size
|
||||
} else {
|
||||
fragmentSize = args.FragmentSize
|
||||
}
|
||||
return &PutAddr{
|
||||
PutURLs: putURLs,
|
||||
FragmentSize: fragmentSize,
|
||||
PutID: prefix,
|
||||
EffectiveTime: effective,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Controller) ConfirmPut(ctx context.Context, putID string) (*ObjectInfo, error) {
|
||||
data, err := c.kv.Get(ctx, c.putKey(putID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var info putInfo
|
||||
if err := json.Unmarshal([]byte(data), &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var total int64
|
||||
src := make([]BucketFile, len(info.Fragments))
|
||||
for i, fragment := range info.Fragments {
|
||||
state, err := c.i.GetObjectInfo(ctx, &BucketFile{
|
||||
Bucket: info.Bucket,
|
||||
Name: fragment,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
total += state.Size
|
||||
src[i] = BucketFile{
|
||||
Bucket: info.Bucket,
|
||||
Name: fragment,
|
||||
}
|
||||
}
|
||||
if total != info.Size {
|
||||
return nil, fmt.Errorf("incomplete upload %d/%d", total, info.Size)
|
||||
}
|
||||
var dst *BucketFile
|
||||
if info.ClearTime == nil {
|
||||
dst = &BucketFile{
|
||||
Bucket: c.i.PermanentBucket(),
|
||||
Name: info.Name,
|
||||
}
|
||||
} else {
|
||||
dst = &BucketFile{
|
||||
Bucket: c.i.ClearBucket(),
|
||||
Name: info.Name,
|
||||
}
|
||||
}
|
||||
if err := c.i.MergeObjectInfo(ctx, src, dst); err != nil { // SourceInfo 0 is too small (2) and it is not the last part
|
||||
return nil, err
|
||||
}
|
||||
obj, err := c.i.GetObjectInfo(ctx, dst)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
go func() {
|
||||
err := c.kv.Del(ctx, c.putKey(putID))
|
||||
if err != nil {
|
||||
log.Println("del key:", err)
|
||||
}
|
||||
for _, b := range src {
|
||||
err = c.i.DeleteObjetInfo(ctx, &b)
|
||||
if err != nil {
|
||||
log.Println("del obj:", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
func (c *Controller) Prefix(args *PutArgs) string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
buf.WriteString(args.Name)
|
||||
buf.WriteString("~~~@~@~~~")
|
||||
buf.WriteString(strconv.FormatInt(args.Size, 10))
|
||||
buf.WriteString(",")
|
||||
buf.WriteString(args.Hash)
|
||||
buf.WriteString(",")
|
||||
buf.WriteString(strconv.FormatInt(int64(args.ClearTime), 10))
|
||||
buf.WriteString(",")
|
||||
buf.WriteString(strconv.FormatInt(int64(args.EffectiveTime), 10))
|
||||
buf.WriteString(",")
|
||||
buf.WriteString(c.i.Name())
|
||||
r := make([]byte, 16)
|
||||
rand.Read(r)
|
||||
buf.Write(r)
|
||||
md5v := md5.Sum(buf.Bytes())
|
||||
return hex.EncodeToString(md5v[:])
|
||||
}
|
||||
|
||||
type putInfo struct {
|
||||
Bucket string
|
||||
Fragments []string
|
||||
FragmentSize int64
|
||||
Size int64
|
||||
Name string
|
||||
Hash string
|
||||
ClearTime *int64
|
||||
}
|
49
internal/objstorage/kv.go
Normal file
49
internal/objstorage/kv.go
Normal file
@ -0,0 +1,49 @@
|
||||
package objstorage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type KV interface {
|
||||
Get(ctx context.Context, key string) (string, error)
|
||||
Set(ctx context.Context, key string, val string, expiration time.Duration) error
|
||||
Del(ctx context.Context, key string) error
|
||||
IsNotFound(err error) bool
|
||||
}
|
||||
|
||||
func NewKV() KV {
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: "",
|
||||
Username: "",
|
||||
Password: "",
|
||||
})
|
||||
return &redisImpl{
|
||||
rdb: rdb,
|
||||
}
|
||||
}
|
||||
|
||||
type redisImpl struct {
|
||||
rdb *redis.Client
|
||||
}
|
||||
|
||||
func (r *redisImpl) Del(ctx context.Context, key string) error {
|
||||
log.Println("redis del", key)
|
||||
return r.rdb.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
func (r *redisImpl) Get(ctx context.Context, key string) (string, error) {
|
||||
log.Println("redis get", key)
|
||||
return r.rdb.Get(ctx, key).Result()
|
||||
}
|
||||
|
||||
func (r *redisImpl) Set(ctx context.Context, key string, val string, expiration time.Duration) error {
|
||||
log.Println("redis set", key, val, expiration.String())
|
||||
return r.rdb.Set(ctx, key, val, expiration).Err()
|
||||
}
|
||||
|
||||
func (r *redisImpl) IsNotFound(err error) bool {
|
||||
return err == redis.Nil
|
||||
}
|
112
internal/objstorage/main.go
Normal file
112
internal/objstorage/main.go
Normal file
@ -0,0 +1,112 @@
|
||||
package objstorage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
)
|
||||
|
||||
func HttpPut(url string, body io.Reader) error {
|
||||
req, err := http.NewRequest(http.MethodPut, url, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("http [%s] %s", resp.Status, data)
|
||||
}
|
||||
if len(data) > 0 {
|
||||
log.Println("[http body]", string(data))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Md5(p []byte) string {
|
||||
t := md5.Sum(p)
|
||||
return hex.EncodeToString(t[:])
|
||||
}
|
||||
|
||||
func Main() {
|
||||
ctx := context.Background()
|
||||
c, err := NewController(&minioImpl{}, NewKV())
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
name := "hello.txt"
|
||||
data := []byte("hello world")
|
||||
|
||||
userID := "10000"
|
||||
|
||||
name = path.Join("user_"+userID, name)
|
||||
|
||||
addr, err := c.ApplyPut(ctx, &FragmentPutArgs{
|
||||
PutArgs: PutArgs{
|
||||
Name: name,
|
||||
Size: int64(len(data)),
|
||||
Hash: Md5(data),
|
||||
EffectiveTime: time.Second * 60 * 60,
|
||||
},
|
||||
FragmentSize: 2,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
|
||||
if addr.ResourceURL != "" {
|
||||
log.Println("服务器已经存在")
|
||||
return
|
||||
}
|
||||
var (
|
||||
start int
|
||||
end = int(addr.FragmentSize)
|
||||
)
|
||||
|
||||
for _, u := range addr.PutURLs {
|
||||
if start >= len(data) {
|
||||
break
|
||||
}
|
||||
if end > len(data) {
|
||||
end = len(data)
|
||||
}
|
||||
_ = u
|
||||
page := data[start:end]
|
||||
fmt.Print(string(page))
|
||||
start += int(addr.FragmentSize)
|
||||
end += int(addr.FragmentSize)
|
||||
err = HttpPut(u, bytes.NewReader(page))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
|
||||
fmt.Println("[PUT_ID]", addr.PutID)
|
||||
|
||||
info, err := c.ConfirmPut(ctx, addr.PutID)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
log.Printf("%+v\n", info)
|
||||
|
||||
log.Println("success")
|
||||
}
|
147
internal/objstorage/minio.go
Normal file
147
internal/objstorage/minio.go
Normal file
@ -0,0 +1,147 @@
|
||||
package objstorage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/minio/minio-go"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewMinio() Interface {
|
||||
return &minioImpl{}
|
||||
}
|
||||
|
||||
type minioImpl struct {
|
||||
uploadBucket string // 上传桶
|
||||
permanentBucket string // 永久桶
|
||||
clearBucket string // 自动清理桶
|
||||
client *minio.Client
|
||||
}
|
||||
|
||||
func (m *minioImpl) Init() error {
|
||||
client, err := minio.New("127.0.0.1:9000", "minioadmin", "minioadmin", false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("minio client error: %w", err)
|
||||
}
|
||||
m.client = client
|
||||
m.uploadBucket = "upload"
|
||||
m.permanentBucket = "permanent"
|
||||
m.clearBucket = "clear"
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *minioImpl) Name() string {
|
||||
return "minio"
|
||||
}
|
||||
|
||||
func (m *minioImpl) MinMultipartSize() int64 {
|
||||
return 1024 * 1024 * 5 // minio.absMinPartSize
|
||||
}
|
||||
|
||||
func (m *minioImpl) UploadBucket() string {
|
||||
return m.uploadBucket
|
||||
}
|
||||
|
||||
func (m *minioImpl) PermanentBucket() string {
|
||||
return m.permanentBucket
|
||||
}
|
||||
|
||||
func (m *minioImpl) ClearBucket() string {
|
||||
return m.clearBucket
|
||||
}
|
||||
|
||||
func (m *minioImpl) urlReplace(u *url.URL) {
|
||||
|
||||
}
|
||||
|
||||
func (m *minioImpl) ApplyPut(ctx context.Context, args *ApplyPutArgs) (*PutRes, error) {
|
||||
if args.Effective <= 0 {
|
||||
return nil, errors.New("EffectiveTime <= 0")
|
||||
}
|
||||
_, err := m.GetObjectInfo(ctx, &BucketFile{
|
||||
Bucket: m.uploadBucket,
|
||||
Name: args.Name,
|
||||
})
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("minio bucket %s name %s already exists", args.Bucket, args.Name)
|
||||
} else if !m.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
effective := time.Now().Add(args.Effective)
|
||||
u, err := m.client.PresignedPutObject(m.uploadBucket, args.Name, args.Effective)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("minio apply error: %w", err)
|
||||
}
|
||||
m.urlReplace(u)
|
||||
return &PutRes{
|
||||
URL: u.String(),
|
||||
Bucket: m.uploadBucket,
|
||||
Name: args.Name,
|
||||
EffectiveTime: effective,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *minioImpl) GetObjectInfo(ctx context.Context, args *BucketFile) (*ObjectInfo, error) {
|
||||
info, err := m.client.StatObject(args.Bucket, args.Name, minio.StatObjectOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ObjectInfo{
|
||||
URL: "", // todo
|
||||
Size: info.Size,
|
||||
Hash: info.ETag,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *minioImpl) CopyObjetInfo(ctx context.Context, src *BucketFile, dst *BucketFile) error {
|
||||
destination, err := minio.NewDestinationInfo(dst.Bucket, dst.Name, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return m.client.CopyObject(destination, minio.NewSourceInfo(src.Bucket, src.Name, nil))
|
||||
}
|
||||
|
||||
func (m *minioImpl) DeleteObjetInfo(ctx context.Context, info *BucketFile) error {
|
||||
return m.client.RemoveObject(info.Bucket, info.Name)
|
||||
}
|
||||
|
||||
func (m *minioImpl) MoveObjetInfo(ctx context.Context, src *BucketFile, dst *BucketFile) error {
|
||||
if err := m.CopyObjetInfo(ctx, src, dst); err != nil {
|
||||
return err
|
||||
}
|
||||
return m.DeleteObjetInfo(ctx, src)
|
||||
}
|
||||
|
||||
func (m *minioImpl) MergeObjectInfo(ctx context.Context, src []BucketFile, dst *BucketFile) error {
|
||||
switch len(src) {
|
||||
case 0:
|
||||
return errors.New("src empty")
|
||||
case 1:
|
||||
return m.CopyObjetInfo(ctx, &src[0], dst)
|
||||
}
|
||||
destination, err := minio.NewDestinationInfo(dst.Bucket, dst.Name, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sources := make([]minio.SourceInfo, len(src))
|
||||
for i, s := range src {
|
||||
sources[i] = minio.NewSourceInfo(s.Bucket, s.Name, nil)
|
||||
}
|
||||
return m.client.ComposeObject(destination, sources) // todo
|
||||
}
|
||||
|
||||
func (m *minioImpl) IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
switch e := err.(type) {
|
||||
case minio.ErrorResponse:
|
||||
return e.StatusCode == 404 && e.Code == "NoSuchKey"
|
||||
case *minio.ErrorResponse:
|
||||
return e.StatusCode == 404 && e.Code == "NoSuchKey"
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
19
internal/objstorage/oo.go
Normal file
19
internal/objstorage/oo.go
Normal file
@ -0,0 +1,19 @@
|
||||
package objstorage
|
||||
|
||||
import "context"
|
||||
|
||||
type Interface interface {
|
||||
Init() error
|
||||
Name() string
|
||||
MinMultipartSize() int64
|
||||
UploadBucket() string
|
||||
PermanentBucket() string
|
||||
ClearBucket() string
|
||||
ApplyPut(ctx context.Context, args *ApplyPutArgs) (*PutRes, error)
|
||||
GetObjectInfo(ctx context.Context, args *BucketFile) (*ObjectInfo, error)
|
||||
CopyObjetInfo(ctx context.Context, src *BucketFile, dst *BucketFile) error
|
||||
DeleteObjetInfo(ctx context.Context, info *BucketFile) error
|
||||
MoveObjetInfo(ctx context.Context, src *BucketFile, dst *BucketFile) error
|
||||
MergeObjectInfo(ctx context.Context, src []BucketFile, dst *BucketFile) error
|
||||
IsNotFound(err error) bool
|
||||
}
|
69
internal/objstorage/pub.go
Normal file
69
internal/objstorage/pub.go
Normal file
@ -0,0 +1,69 @@
|
||||
package objstorage
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PutRes struct {
|
||||
URL string
|
||||
Bucket string
|
||||
Name string
|
||||
EffectiveTime time.Time
|
||||
}
|
||||
|
||||
type FragmentPutArgs struct {
|
||||
PutArgs
|
||||
FragmentSize int64 // 分片大小
|
||||
}
|
||||
|
||||
type PutArgs struct {
|
||||
Name string // 文件名
|
||||
Size int64 // 大小
|
||||
Hash string // md5
|
||||
Prefix string // 前缀
|
||||
ClearTime time.Duration // 自动清理时间
|
||||
EffectiveTime time.Duration // 申请有效时间
|
||||
Header http.Header // header
|
||||
}
|
||||
|
||||
type BucketFile struct {
|
||||
Bucket string `json:"bucket"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ObjectInfo struct {
|
||||
URL string
|
||||
Size int64
|
||||
Hash string
|
||||
}
|
||||
|
||||
//type PutSpace struct {
|
||||
// URL string
|
||||
// EffectiveTime time.Time
|
||||
//}
|
||||
|
||||
type PutAddr struct {
|
||||
ResourceURL string
|
||||
PutID string
|
||||
FragmentSize int64
|
||||
EffectiveTime time.Time
|
||||
PutURLs []string
|
||||
}
|
||||
|
||||
type KVData struct {
|
||||
Bucket string `json:"bucket"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type PutResp struct {
|
||||
URL string
|
||||
Time *time.Time
|
||||
}
|
||||
|
||||
type ApplyPutArgs struct {
|
||||
Bucket string
|
||||
Name string
|
||||
Effective time.Duration // 申请有效时间
|
||||
Header http.Header // header
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
package push
|
||||
|
||||
import (
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/auth"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/common"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/req"
|
||||
"Open_IM/pkg/common/config"
|
||||
)
|
||||
|
||||
|
@ -2,137 +2,54 @@ package conversation
|
||||
|
||||
import (
|
||||
"Open_IM/internal/common/check"
|
||||
chat "Open_IM/internal/rpc/msg"
|
||||
"Open_IM/internal/common/notification"
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/controller"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
tableRelation "Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/prome"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/OpenIMSDK/openKeeper"
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type conversationServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
groupChecker *check.GroupChecker
|
||||
controller.ConversationInterface
|
||||
controller.ConversationDataBaseInterface
|
||||
notify *notification.Check
|
||||
}
|
||||
|
||||
func NewConversationServer(port int) *conversationServer {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
c := conversationServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImConversationName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
groupChecker: check.NewGroupChecker(),
|
||||
}
|
||||
var cDB relation.Conversation
|
||||
var cCache cache.ConversationCache
|
||||
//mysql init
|
||||
var mysql relation.Mysql
|
||||
err := mysql.InitConn().AutoMigrateModel(&tableRelation.ConversationModel{})
|
||||
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||
db, err := relation.NewGormDB()
|
||||
if err != nil {
|
||||
panic("db init err:" + err.Error())
|
||||
return err
|
||||
}
|
||||
if mysql.GormConn() != nil {
|
||||
//get gorm model
|
||||
cDB = relation.NewConversationGorm(mysql.GormConn())
|
||||
} else {
|
||||
panic("db init err:" + "conn is nil")
|
||||
if err := db.AutoMigrate(&tableRelation.ConversationModel{}); err != nil {
|
||||
return err
|
||||
}
|
||||
//redis init
|
||||
var redis cache.RedisClient
|
||||
redis.InitRedis()
|
||||
rcClient := rockscache.NewClient(redis.GetClient(), rockscache.Options{
|
||||
redis, err := cache.NewRedis()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pbConversation.RegisterConversationServer(server, &conversationServer{
|
||||
groupChecker: check.NewGroupChecker(client),
|
||||
ConversationDataBaseInterface: controller.NewConversationDatabase(relation.NewConversationGorm(db), cache.NewConversationRedis(redis.GetClient(), rockscache.Options{
|
||||
RandomExpireAdjustment: 0.2,
|
||||
DisableCacheRead: false,
|
||||
DisableCacheDelete: false,
|
||||
StrongConsistency: true,
|
||||
}), tx.NewGorm(db)),
|
||||
})
|
||||
cCache = cache.NewConversationRedis(rcClient)
|
||||
|
||||
database := controller.NewConversationDataBase(cDB, cCache)
|
||||
c.ConversationInterface = controller.NewConversationController(database)
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c *conversationServer) Run() {
|
||||
log.NewInfo("0", "rpc conversation start...")
|
||||
|
||||
listenIP := ""
|
||||
if config.Config.ListenIP == "" {
|
||||
listenIP = "0.0.0.0"
|
||||
} else {
|
||||
listenIP = config.Config.ListenIP
|
||||
}
|
||||
address := listenIP + ":" + strconv.Itoa(c.rpcPort)
|
||||
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
panic("listening err:" + err.Error() + c.rpcRegisterName)
|
||||
}
|
||||
log.NewInfo("0", "listen network success, ", address, listener)
|
||||
//grpc server
|
||||
var grpcOpts []grpc.ServerOption
|
||||
if config.Config.Prometheus.Enable {
|
||||
promePkg.NewGrpcRequestCounter()
|
||||
promePkg.NewGrpcRequestFailedCounter()
|
||||
promePkg.NewGrpcRequestSuccessCounter()
|
||||
grpcOpts = append(grpcOpts, []grpc.ServerOption{
|
||||
// grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme),
|
||||
grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor),
|
||||
grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor),
|
||||
}...)
|
||||
}
|
||||
srv := grpc.NewServer(grpcOpts...)
|
||||
defer srv.GracefulStop()
|
||||
|
||||
//service registers with etcd
|
||||
pbConversation.RegisterConversationServer(srv, c)
|
||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
||||
if config.Config.RpcRegisterIP == "" {
|
||||
rpcRegisterIP, err = utils.GetLocalIP()
|
||||
if err != nil {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = rpc.RegisterEtcd(c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName, 10, "")
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error(),
|
||||
c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName)
|
||||
panic(utils.Wrap(err, "register conversation module rpc to etcd err"))
|
||||
}
|
||||
log.NewInfo("0", "RegisterConversationServer ok ", c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName)
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "rpc conversation ok")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) GetConversation(ctx context.Context, req *pbConversation.GetConversationReq) (*pbConversation.GetConversationResp, error) {
|
||||
resp := &pbConversation.GetConversationResp{Conversation: &pbConversation.Conversation{}}
|
||||
conversations, err := c.ConversationInterface.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
||||
conversations, err := c.ConversationDataBaseInterface.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -147,7 +64,7 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbConvers
|
||||
|
||||
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbConversation.GetAllConversationsReq) (*pbConversation.GetAllConversationsResp, error) {
|
||||
resp := &pbConversation.GetAllConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
conversations, err := c.ConversationInterface.GetUserAllConversation(ctx, req.OwnerUserID)
|
||||
conversations, err := c.ConversationDataBaseInterface.GetUserAllConversation(ctx, req.OwnerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -159,7 +76,7 @@ func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbCon
|
||||
|
||||
func (c *conversationServer) GetConversations(ctx context.Context, req *pbConversation.GetConversationsReq) (*pbConversation.GetConversationsResp, error) {
|
||||
resp := &pbConversation.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
conversations, err := c.ConversationInterface.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
||||
conversations, err := c.ConversationDataBaseInterface.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -175,11 +92,11 @@ func (c *conversationServer) BatchSetConversations(ctx context.Context, req *pbC
|
||||
if err := utils.CopyStructFields(&conversations, req.Conversations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err := c.ConversationInterface.SetUserConversations(ctx, req.OwnerUserID, conversations)
|
||||
err := c.ConversationDataBaseInterface.SetUserConversations(ctx, req.OwnerUserID, conversations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chat.ConversationChangeNotification(ctx, req.OwnerUserID)
|
||||
c.notify.ConversationChangeNotification(ctx, req.OwnerUserID)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -196,7 +113,7 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p
|
||||
var err error
|
||||
isSyncConversation := true
|
||||
if req.Conversation.ConversationType == constant.GroupChatType {
|
||||
groupInfo, err := c.groupChecker.GetGroupInfo(req.Conversation.GroupID)
|
||||
groupInfo, err := c.groupChecker.GetGroupInfo(ctx, req.Conversation.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -209,14 +126,14 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p
|
||||
return nil, err
|
||||
}
|
||||
if req.FieldType == constant.FieldIsPrivateChat {
|
||||
err := c.ConversationInterface.SyncPeerUserPrivateConversationTx(ctx, &conversation)
|
||||
err := c.ConversationDataBaseInterface.SyncPeerUserPrivateConversationTx(ctx, &conversation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chat.ConversationSetPrivateNotification(ctx, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat)
|
||||
c.notify.ConversationSetPrivateNotification(ctx, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat)
|
||||
return resp, nil
|
||||
}
|
||||
//haveUserID, err := c.ConversationInterface.GetUserIDExistConversation(ctx, req.UserIDList, req.Conversation.ConversationID)
|
||||
//haveUserID, err := c.ConversationDataBaseInterface.GetUserIDExistConversation(ctx, req.UserIDList, req.Conversation.ConversationID)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
@ -240,18 +157,18 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p
|
||||
case constant.FieldBurnDuration:
|
||||
filedMap["burn_duration"] = req.Conversation.BurnDuration
|
||||
}
|
||||
err = c.ConversationInterface.SetUsersConversationFiledTx(ctx, req.UserIDList, &conversation, filedMap)
|
||||
err = c.ConversationDataBaseInterface.SetUsersConversationFiledTx(ctx, req.UserIDList, &conversation, filedMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if isSyncConversation {
|
||||
for _, v := range req.UserIDList {
|
||||
chat.ConversationChangeNotification(ctx, v)
|
||||
c.notify.ConversationChangeNotification(ctx, v)
|
||||
}
|
||||
} else {
|
||||
for _, v := range req.UserIDList {
|
||||
chat.ConversationUnreadChangeNotification(ctx, v, req.Conversation.ConversationID, req.Conversation.UpdateUnreadCountTime)
|
||||
c.notify.ConversationUnreadChangeNotification(ctx, v, req.Conversation.ConversationID, req.Conversation.UpdateUnreadCountTime)
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
|
@ -14,7 +14,7 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.Ge
|
||||
if err := s.userCheck.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blacks, total, err := s.BlackInterface.FindOwnerBlacks(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
blacks, total, err := s.BlackDatabase.FindOwnerBlacks(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -28,7 +28,7 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.Ge
|
||||
|
||||
func (s *friendServer) IsBlack(ctx context.Context, req *pbFriend.IsBlackReq) (*pbFriend.IsBlackResp, error) {
|
||||
resp := &pbFriend.IsBlackResp{}
|
||||
in1, in2, err := s.BlackInterface.CheckIn(ctx, req.UserID1, req.UserID2)
|
||||
in1, in2, err := s.BlackDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -42,7 +42,7 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlac
|
||||
if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.BlackInterface.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
||||
if err := s.BlackDatabase.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.BlackDeletedNotification(ctx, req)
|
||||
@ -55,7 +55,7 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
|
||||
return nil, err
|
||||
}
|
||||
black := relation.BlackModel{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID, OperatorUserID: tracelog.GetOpUserID(ctx)}
|
||||
if err := s.BlackInterface.Create(ctx, []*relation.BlackModel{&black}); err != nil {
|
||||
if err := s.BlackDatabase.Create(ctx, []*relation.BlackModel{&black}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.BlackAddedNotification(ctx, req)
|
||||
|
@ -4,13 +4,14 @@ import (
|
||||
"Open_IM/internal/common/check"
|
||||
"Open_IM/internal/common/convert"
|
||||
"Open_IM/internal/common/notification"
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/controller"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||
tablerelation "Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
registry "Open_IM/pkg/discoveryregistry"
|
||||
pbfriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@ -19,24 +20,24 @@ import (
|
||||
)
|
||||
|
||||
type friendServer struct {
|
||||
controller.FriendInterface
|
||||
controller.BlackInterface
|
||||
controller.FriendDatabase
|
||||
controller.BlackDatabase
|
||||
notification *notification.Check
|
||||
userCheck *check.UserCheck
|
||||
RegisterCenter discoveryRegistry.SvcDiscoveryRegistry
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||
mysql, err := relation.NewGormDB()
|
||||
db, err := relation.NewGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mysql.AutoMigrate(&relationTb.FriendModel{}, &relationTb.FriendRequestModel{}, &relationTb.BlackModel{}); err != nil {
|
||||
if err := db.AutoMigrate(&tablerelation.FriendModel{}, &tablerelation.FriendRequestModel{}, &tablerelation.BlackModel{}); err != nil {
|
||||
return err
|
||||
}
|
||||
pbfriend.RegisterFriendServer(server, &friendServer{
|
||||
FriendInterface: controller.NewFriendController(mysql),
|
||||
BlackInterface: controller.NewBlackController(mysql),
|
||||
FriendDatabase: controller.NewFriendDatabase(relation.NewFriendGorm(db), relation.NewFriendRequestGorm(db), tx.NewGorm(db)),
|
||||
BlackDatabase: controller.NewBlackDatabase(relation.NewBlackGorm(db)),
|
||||
notification: notification.NewCheck(client),
|
||||
userCheck: check.NewUserCheck(client),
|
||||
RegisterCenter: client,
|
||||
@ -59,14 +60,14 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
||||
if _, err := s.userCheck.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
||||
in1, in2, err := s.FriendDatabase.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in1 && in2 {
|
||||
return nil, constant.ErrRelationshipAlready.Wrap()
|
||||
}
|
||||
if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
|
||||
if err = s.FriendDatabase.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.FriendApplicationAddNotification(ctx, req)
|
||||
@ -90,7 +91,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
|
||||
return nil, constant.ErrArgs.Wrap("friend userID repeated")
|
||||
}
|
||||
|
||||
if err := s.FriendInterface.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport, tracelog.GetOpUserID(ctx)); err != nil {
|
||||
if err := s.FriendDatabase.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport, tracelog.GetOpUserID(ctx)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
@ -102,7 +103,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
|
||||
if err := s.userCheck.Access(ctx, req.ToUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friendRequest := relationTb.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult}
|
||||
friendRequest := tablerelation.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult}
|
||||
if req.HandleResult == constant.FriendResponseAgree {
|
||||
err := s.AgreeFriendRequest(ctx, &friendRequest)
|
||||
if err != nil {
|
||||
@ -132,7 +133,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil {
|
||||
if err := s.FriendDatabase.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.FriendDeletedNotification(ctx, req)
|
||||
@ -149,7 +150,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
|
||||
if err := s.FriendDatabase.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
|
||||
@ -158,20 +159,21 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
|
||||
|
||||
// ok
|
||||
func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.GetDesignatedFriendsReq) (resp *pbfriend.GetDesignatedFriendsResp, err error) {
|
||||
|
||||
resp = &pbfriend.GetDesignatedFriendsResp{}
|
||||
if err := s.userCheck.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, constant.ErrArgs.Wrap("friend userID repeated")
|
||||
}
|
||||
friends, total, err := s.FriendInterface.PageOwnerFriends(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
friends, err := s.FriendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends)
|
||||
if err != nil {
|
||||
if resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Total = int32(total)
|
||||
return resp, nil
|
||||
|
||||
}
|
||||
|
||||
// ok 获取接收到的好友申请(即别人主动申请的)
|
||||
@ -180,7 +182,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
|
||||
if err := s.userCheck.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friendRequests, total, err := s.FriendInterface.PageFriendRequestToMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
friendRequests, total, err := s.FriendDatabase.PageFriendRequestToMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -198,7 +200,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p
|
||||
if err := s.userCheck.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friendRequests, total, err := s.FriendInterface.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
friendRequests, total, err := s.FriendDatabase.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -213,7 +215,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p
|
||||
// ok
|
||||
func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq) (resp *pbfriend.IsFriendResp, err error) {
|
||||
resp = &pbfriend.IsFriendResp{}
|
||||
resp.InUser1Friends, resp.InUser2Friends, err = s.FriendInterface.CheckIn(ctx, req.UserID1, req.UserID2)
|
||||
resp.InUser1Friends, resp.InUser2Friends, err = s.FriendDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -223,15 +225,17 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq)
|
||||
// ok
|
||||
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
|
||||
resp = &pbfriend.GetPaginationFriendsResp{}
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, constant.ErrArgs.Wrap("friend userID repeated")
|
||||
if err := s.userCheck.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friends, err := s.FriendInterface.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
friends, total, err := s.FriendDatabase.PageOwnerFriends(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends); err != nil {
|
||||
resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Total = int32(total)
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package group
|
||||
import (
|
||||
"Open_IM/internal/common/check"
|
||||
"Open_IM/internal/common/notification"
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/controller"
|
||||
@ -44,7 +45,15 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||
return err
|
||||
}
|
||||
pbGroup.RegisterGroupServer(server, &groupServer{
|
||||
GroupInterface: controller.NewGroupInterface(controller.NewGroupDatabase(db, redis.GetClient(), mongo.GetClient())),
|
||||
GroupDatabase: controller.NewGroupDatabase(
|
||||
relation.NewGroupDB(db),
|
||||
relation.NewGroupMemberDB(db),
|
||||
relation.NewGroupRequest(db),
|
||||
tx.NewGorm(db),
|
||||
tx.NewMongo(mongo.GetClient()),
|
||||
unrelation.NewSuperGroupMongoDriver(mongo.GetClient()),
|
||||
redis.GetClient(),
|
||||
),
|
||||
UserCheck: check.NewUserCheck(client),
|
||||
ConversationChecker: check.NewConversationChecker(client),
|
||||
})
|
||||
@ -52,7 +61,7 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||
}
|
||||
|
||||
type groupServer struct {
|
||||
GroupInterface controller.GroupInterface
|
||||
GroupDatabase controller.GroupDatabase
|
||||
UserCheck *check.UserCheck
|
||||
Notification *notification.Check
|
||||
ConversationChecker *check.ConversationChecker
|
||||
@ -60,7 +69,7 @@ type groupServer struct {
|
||||
|
||||
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
groupMember, err := s.GroupInterface.TakeGroupMember(ctx, groupID, tracelog.GetOpUserID(ctx))
|
||||
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -90,7 +99,7 @@ func (s *groupServer) IsNotFound(err error) bool {
|
||||
|
||||
func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
|
||||
if *groupID != "" {
|
||||
_, err := s.GroupInterface.TakeGroup(ctx, *groupID)
|
||||
_, err := s.GroupDatabase.TakeGroup(ctx, *groupID)
|
||||
if err == nil {
|
||||
return constant.ErrGroupIDExisted.Wrap("group id existed " + *groupID)
|
||||
} else if s.IsNotFound(err) {
|
||||
@ -104,7 +113,7 @@ func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
|
||||
bi := big.NewInt(0)
|
||||
bi.SetString(id[0:8], 16)
|
||||
id = bi.String()
|
||||
_, err := s.GroupInterface.TakeGroup(ctx, id)
|
||||
_, err := s.GroupDatabase.TakeGroup(ctx, id)
|
||||
if err == nil {
|
||||
continue
|
||||
} else if s.IsNotFound(err) {
|
||||
@ -159,7 +168,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
return nil, err
|
||||
}
|
||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupInterface.CreateSuperGroup(ctx, group.GroupID, userIDs); err != nil {
|
||||
if err := s.GroupDatabase.CreateSuperGroup(ctx, group.GroupID, userIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
@ -174,7 +183,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := s.GroupInterface.CreateGroup(ctx, []*relationTb.GroupModel{group}, groupMembers); err != nil {
|
||||
if err := s.GroupDatabase.CreateGroup(ctx, []*relationTb.GroupModel{group}, groupMembers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.GroupInfo = DbToPbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
||||
@ -196,7 +205,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
total, members, err := s.GroupInterface.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -207,15 +216,15 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
groupIDs := utils.Slice(members, func(e *relationTb.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMemberNum, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs)
|
||||
groupMemberNum, err := s.GroupDatabase.MapGroupMemberNum(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -238,14 +247,14 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
if utils.Duplicate(req.InvitedUserIDs) {
|
||||
return nil, constant.ErrArgs.Wrap("userID duplicate")
|
||||
}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
return nil, constant.ErrDismissedAlready.Wrap()
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{group.GroupID}, nil, nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{group.GroupID}, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -276,7 +285,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
InviterUserID: opUserID,
|
||||
})
|
||||
}
|
||||
if err := s.GroupInterface.CreateGroupRequest(ctx, requests); err != nil {
|
||||
if err := s.GroupDatabase.CreateGroupRequest(ctx, requests); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, request := range requests {
|
||||
@ -292,7 +301,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
}
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupInterface.CreateSuperGroupMember(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
|
||||
if err := s.GroupDatabase.CreateSuperGroupMember(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, userID := range req.InvitedUserIDs {
|
||||
@ -314,7 +323,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
}
|
||||
groupMembers = append(groupMembers, member)
|
||||
}
|
||||
if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil {
|
||||
if err := s.GroupDatabase.CreateGroup(ctx, nil, groupMembers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs)
|
||||
@ -324,14 +333,14 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
|
||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
||||
resp := &pbGroup.GetGroupAllMemberResp{}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
return nil, constant.ErrArgs.Wrap("unsupported super group")
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, nil, nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.GroupID}, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -352,7 +361,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
|
||||
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) {
|
||||
resp := &pbGroup.GetGroupMemberListResp{}
|
||||
total, members, err := s.GroupInterface.PageGroupMember(ctx, []string{req.GroupID}, nil, utils.If(req.Filter >= 0, []int32{req.Filter}, nil), req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
total, members, err := s.GroupDatabase.PageGroupMember(ctx, []string{req.GroupID}, nil, utils.If(req.Filter >= 0, []int32{req.Filter}, nil), req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -374,7 +383,7 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
|
||||
|
||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
|
||||
resp := &pbGroup.KickGroupMemberResp{}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -389,7 +398,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
return nil, constant.ErrArgs.Wrap("opUserID in KickedUserIDs")
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, req.KickedUserIDs); err != nil {
|
||||
if err := s.GroupDatabase.DeleteSuperGroupMember(ctx, req.GroupID, req.KickedUserIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
go func() {
|
||||
@ -398,7 +407,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, append(req.KickedUserIDs, opUserID), nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.GroupID}, append(req.KickedUserIDs, opUserID), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -431,7 +440,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
return nil, constant.ErrNoPermission.Wrap("opUserID is OrdinaryUser")
|
||||
}
|
||||
}
|
||||
if err := s.GroupInterface.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil {
|
||||
if err := s.GroupDatabase.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.MemberKickedNotification(ctx, req, req.KickedUserIDs)
|
||||
@ -447,7 +456,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
||||
if req.GroupID == "" {
|
||||
return nil, constant.ErrArgs.Wrap("groupID empty")
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, req.Members, nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.GroupID}, req.Members, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -468,7 +477,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
||||
|
||||
func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
|
||||
resp := &pbGroup.GetGroupApplicationListResp{}
|
||||
total, groupRequests, err := s.GroupInterface.PageGroupRequestUser(ctx, req.FromUserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
total, groupRequests, err := s.GroupDatabase.PageGroupRequestUser(ctx, req.FromUserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -490,7 +499,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, utils.Distinct(groupIDs))
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, utils.Distinct(groupIDs))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -500,11 +509,11 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
||||
return nil, constant.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
|
||||
}
|
||||
groupMemberNumMap, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs)
|
||||
groupMemberNumMap, err := s.GroupDatabase.MapGroupMemberNum(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -522,15 +531,15 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, constant.ErrArgs.Wrap("groupID is empty")
|
||||
}
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, req.GroupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMemberNumMap, err := s.GroupInterface.MapGroupMemberNum(ctx, req.GroupIDs)
|
||||
groupMemberNumMap, err := s.GroupDatabase.MapGroupMemberNum(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -538,7 +547,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
return e.GroupID
|
||||
})
|
||||
resp.GroupInfos = utils.Slice(groups, func(e *relationTb.GroupModel) *sdkws.GroupInfo {
|
||||
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID]))
|
||||
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID])
|
||||
})
|
||||
return resp, nil
|
||||
}
|
||||
@ -549,7 +558,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
return nil, constant.ErrArgs.Wrap("HandleResult unknown")
|
||||
}
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
groupMember, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.FromUserID)
|
||||
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.FromUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -557,11 +566,11 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
return nil, constant.ErrNoPermission.Wrap("no group owner or admin")
|
||||
}
|
||||
}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupRequest, err := s.GroupInterface.TakeGroupRequest(ctx, req.GroupID, req.FromUserID)
|
||||
groupRequest, err := s.GroupDatabase.TakeGroupRequest(ctx, req.GroupID, req.FromUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -569,7 +578,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
return nil, constant.ErrArgs.Wrap("group request already processed")
|
||||
}
|
||||
var join bool
|
||||
if _, err = s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil {
|
||||
if _, err = s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil {
|
||||
join = true // 已经在群里了
|
||||
} else if !s.IsNotFound(err) {
|
||||
return nil, err
|
||||
@ -596,7 +605,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err := s.GroupInterface.HandlerGroupRequest(ctx, req.GroupID, req.FromUserID, req.HandledMsg, req.HandleResult, member); err != nil {
|
||||
if err := s.GroupDatabase.HandlerGroupRequest(ctx, req.GroupID, req.FromUserID, req.HandledMsg, req.HandleResult, member); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !join {
|
||||
@ -615,7 +624,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
if _, err := s.UserCheck.GetPublicUserInfo(ctx, tracelog.GetOpUserID(ctx)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -626,7 +635,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
return nil, constant.ErrGroupTypeNotSupport.Wrap()
|
||||
}
|
||||
user, err := relation.GetUserByUserID(tracelog.GetOpUserID(ctx))
|
||||
user, err := s.UserCheck.GetUsersInfo(ctx, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -639,7 +648,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
||||
if err := s.GroupDatabase.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.MemberEnterDirectlyNotification(ctx, req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx))
|
||||
@ -652,7 +661,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
JoinSource: req.JoinSource,
|
||||
ReqTime: time.Now(),
|
||||
}
|
||||
if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil {
|
||||
if err := s.GroupDatabase.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
||||
@ -661,17 +670,17 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
|
||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) (*pbGroup.QuitGroupResp, error) {
|
||||
resp := &pbGroup.QuitGroupResp{}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil {
|
||||
if err := s.GroupDatabase.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.SuperGroupNotification(ctx, tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx))
|
||||
} else {
|
||||
_, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||
_, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -683,7 +692,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
|
||||
resp := &pbGroup.SetGroupInfoResp{}
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
groupMember, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, tracelog.GetOpUserID(ctx))
|
||||
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -691,14 +700,14 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
return nil, constant.ErrNoPermission.Wrap("no group owner or admin")
|
||||
}
|
||||
}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
return nil, utils.Wrap(constant.ErrDismissedAlready, "")
|
||||
}
|
||||
userIDs, err := s.GroupInterface.FindGroupMemberUserID(ctx, group.GroupID)
|
||||
userIDs, err := s.GroupDatabase.FindGroupMemberUserID(ctx, group.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -706,10 +715,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if len(data) > 0 {
|
||||
return resp, nil
|
||||
}
|
||||
if err := s.GroupInterface.UpdateGroup(ctx, group.GroupID, data); err != nil {
|
||||
if err := s.GroupDatabase.UpdateGroup(ctx, group.GroupID, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
group, err = s.GroupInterface.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
group, err = s.GroupDatabase.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -734,7 +743,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
|
||||
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (*pbGroup.TransferGroupOwnerResp, error) {
|
||||
resp := &pbGroup.TransferGroupOwnerResp{}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -744,7 +753,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
||||
if req.OldOwnerUserID == req.NewOwnerUserID {
|
||||
return nil, constant.ErrArgs.Wrap("OldOwnerUserID == NewOwnerUserID")
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, []string{req.OldOwnerUserID, req.NewOwnerUserID}, nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.GroupID}, []string{req.OldOwnerUserID, req.NewOwnerUserID}, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -759,7 +768,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
||||
oldOwner := memberMap[req.OldOwnerUserID]
|
||||
if tokenverify.IsAppManagerUid(ctx) {
|
||||
if oldOwner == nil {
|
||||
oldOwner, err = s.GroupInterface.TakeGroupOwner(ctx, req.OldOwnerUserID)
|
||||
oldOwner, err = s.GroupDatabase.TakeGroupOwner(ctx, req.OldOwnerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -772,7 +781,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
||||
return nil, constant.ErrNoPermission.Wrap(fmt.Sprintf("user %s no permission transfer group owner", tracelog.GetOpUserID(ctx)))
|
||||
}
|
||||
}
|
||||
if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil {
|
||||
if err := s.GroupDatabase.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.GroupOwnerTransferredNotification(ctx, req)
|
||||
@ -786,10 +795,10 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
err error
|
||||
)
|
||||
if req.GroupID != "" {
|
||||
groups, err = s.GroupInterface.FindGroup(ctx, []string{req.GroupID})
|
||||
groups, err = s.GroupDatabase.FindGroup(ctx, []string{req.GroupID})
|
||||
resp.Total = uint32(len(groups))
|
||||
} else {
|
||||
resp.Total, groups, err = s.GroupInterface.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
resp.Total, groups, err = s.GroupDatabase.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -797,7 +806,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
groupIDs := utils.Slice(groups, func(e *relationTb.GroupModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
ownerMembers, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
ownerMembers, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -807,7 +816,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 {
|
||||
return nil, constant.ErrDB.Wrap("group not owner " + strings.Join(ids, ","))
|
||||
}
|
||||
groupMemberNumMap, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs)
|
||||
groupMemberNumMap, err := s.GroupDatabase.MapGroupMemberNum(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -820,7 +829,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
|
||||
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
||||
total, members, err := s.GroupInterface.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
total, members, err := s.GroupDatabase.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -846,7 +855,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
total, requests, err := s.GroupInterface.PageGroupRequestUser(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
total, requests, err := s.GroupDatabase.PageGroupRequestUser(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -857,7 +866,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationTb.GroupRequestModel) string {
|
||||
return e.GroupID
|
||||
}))
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -867,7 +876,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
||||
return nil, constant.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
|
||||
}
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -877,7 +886,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
||||
return nil, constant.ErrData.Wrap("group no owner", strings.Join(ids, ","))
|
||||
}
|
||||
groupMemberNum, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs)
|
||||
groupMemberNum, err := s.GroupDatabase.MapGroupMemberNum(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -892,18 +901,18 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
return nil, constant.ErrArgs.Wrap("group status is dismissed")
|
||||
}
|
||||
if err := s.GroupInterface.DismissGroup(ctx, req.GroupID); err != nil {
|
||||
if err := s.GroupDatabase.DismissGroup(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupInterface.DeleteSuperGroup(ctx, group.GroupID); err != nil {
|
||||
if err := s.GroupDatabase.DeleteSuperGroup(ctx, group.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
@ -914,12 +923,12 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
|
||||
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
||||
resp := &pbGroup.MuteGroupMemberResp{}
|
||||
member, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !(tracelog.GetOpUserID(ctx) == req.UserID || tokenverify.IsAppManagerUid(ctx)) {
|
||||
opMember, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
opMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -928,7 +937,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
}
|
||||
}
|
||||
data := UpdateGroupMemberMutedTimeMap(time.Now().Add(time.Second * time.Duration(req.MutedSeconds)))
|
||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
if err := s.GroupDatabase.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds)
|
||||
@ -937,12 +946,12 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
|
||||
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
||||
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
||||
member, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !(tracelog.GetOpUserID(ctx) == req.UserID || tokenverify.IsAppManagerUid(ctx)) {
|
||||
opMember, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||
opMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -951,7 +960,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
||||
}
|
||||
}
|
||||
data := UpdateGroupMemberMutedTimeMap(time.Unix(0, 0))
|
||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
if err := s.GroupDatabase.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.GroupMemberCancelMutedNotification(ctx, req.GroupID, req.UserID)
|
||||
@ -963,7 +972,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil {
|
||||
if err := s.GroupDatabase.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.GroupMutedNotification(ctx, req.GroupID)
|
||||
@ -975,7 +984,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil {
|
||||
if err := s.GroupDatabase.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.GroupCancelMutedNotification(ctx, req.GroupID)
|
||||
@ -1001,7 +1010,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
}
|
||||
groupIDs := utils.Keys(groupIDMap)
|
||||
userIDs := utils.Keys(userIDMap)
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, append(userIDs, tracelog.GetOpUserID(ctx)), nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, append(userIDs, tracelog.GetOpUserID(ctx)), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1044,7 +1053,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = s.GroupInterface.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbGroup.SetGroupMemberInfo) *relationTb.BatchUpdateGroupMember {
|
||||
err = s.GroupDatabase.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbGroup.SetGroupMemberInfo) *relationTb.BatchUpdateGroupMember {
|
||||
return &relationTb.BatchUpdateGroupMember{
|
||||
GroupID: e.GroupID,
|
||||
UserID: e.UserID,
|
||||
@ -1068,7 +1077,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
|
||||
if utils.Duplicate(req.GroupIDs) {
|
||||
return nil, constant.ErrArgs.Wrap("groupIDs duplicate")
|
||||
}
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, req.GroupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1077,7 +1086,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
|
||||
})); len(ids) > 0 {
|
||||
return nil, constant.ErrGroupIDNotFound.Wrap("not found group " + strings.Join(ids, ","))
|
||||
}
|
||||
groupUserMap, err := s.GroupInterface.MapGroupMemberUserID(ctx, req.GroupIDs)
|
||||
groupUserMap, err := s.GroupDatabase.MapGroupMemberUserID(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1096,7 +1105,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, constant.ErrArgs.Wrap("groupIDs empty")
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.UserID}, req.GroupIDs, nil)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.UserID}, req.GroupIDs, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1118,7 +1127,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
|
||||
func (s *groupServer) GetGroupMemberUserID(ctx context.Context, req *pbGroup.GetGroupMemberUserIDReq) (*pbGroup.GetGroupMemberUserIDResp, error) {
|
||||
resp := &pbGroup.GetGroupMemberUserIDResp{}
|
||||
var err error
|
||||
resp.UserIDs, err = s.GroupInterface.FindGroupMemberUserID(ctx, req.GroupID)
|
||||
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1130,7 +1139,7 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.
|
||||
if len(req.RoleLevels) == 0 {
|
||||
return nil, constant.ErrArgs.Wrap("RoleLevels empty")
|
||||
}
|
||||
members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, nil, req.RoleLevels)
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, []string{req.GroupID}, nil, req.RoleLevels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -14,14 +14,14 @@ import (
|
||||
|
||||
func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{}
|
||||
joinSuperGroup, err := s.GroupInterface.FindJoinSuperGroup(ctx, req.UserID)
|
||||
joinSuperGroup, err := s.GroupDatabase.FindJoinSuperGroup(ctx, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(joinSuperGroup.GroupIDs) == 0 {
|
||||
return resp, nil
|
||||
}
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, joinSuperGroup.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, joinSuperGroup.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -31,7 +31,7 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
|
||||
if ids := utils.Single(joinSuperGroup.GroupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
||||
return nil, constant.ErrData.Wrap(fmt.Sprintf("super group %s not owner", strings.Join(ids, ",")))
|
||||
}
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, joinSuperGroup.GroupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, joinSuperGroup.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,7 +41,7 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
|
||||
if ids := utils.Single(joinSuperGroup.GroupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
||||
return nil, constant.ErrData.Wrap(fmt.Sprintf("super group info %s not found", strings.Join(ids, ",")))
|
||||
}
|
||||
superGroupMembers, err := s.GroupInterface.FindSuperGroup(ctx, joinSuperGroup.GroupIDs)
|
||||
superGroupMembers, err := s.GroupDatabase.FindSuperGroup(ctx, joinSuperGroup.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -59,18 +59,18 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, constant.ErrArgs.Wrap("groupIDs empty")
|
||||
}
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, req.GroupIDs)
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
superGroupMembers, err := s.GroupInterface.FindSuperGroup(ctx, req.GroupIDs)
|
||||
superGroupMembers, err := s.GroupDatabase.FindSuperGroup(ctx, req.GroupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) {
|
||||
return e.GroupID, e.MemberIDs
|
||||
})
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
owners, err := s.GroupDatabase.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func toCommonCallback(ctx context.Context, msg *pbChat.SendMsgReq, command strin
|
||||
AtUserIDList: msg.MsgData.AtUserIDList,
|
||||
SenderFaceURL: msg.MsgData.SenderFaceURL,
|
||||
Content: utils.GetContent(msg.MsgData),
|
||||
Seq: msg.MsgData.Seq,
|
||||
Seq: uint32(msg.MsgData.Seq),
|
||||
Ex: msg.MsgData.Ex,
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
func (m *msgServer) DelMsgList(ctx context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) {
|
||||
resp := &common.DelMsgListResp{}
|
||||
if err := m.MsgInterface.DelMsgFromCache(ctx, req.UserID, req.SeqList); err != nil {
|
||||
if _, err := m.MsgInterface.DelMsgBySeqs(ctx, req.UserID, req.SeqList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
DeleteMessageNotification(ctx, req.UserID, req.SeqList)
|
||||
@ -21,11 +21,14 @@ func (m *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroup
|
||||
if err := tokenverify.CheckAdmin(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
maxSeq, err := m.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := m.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil {
|
||||
//maxSeq, err := m.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//if err := m.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
if err := m.MsgInterface.DeleteUserSuperGroupMsgsAndSetMinSeq(ctx, req.GroupID, req.UserID, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
@ -36,8 +39,11 @@ func (m *msgServer) ClearMsg(ctx context.Context, req *msg.ClearMsgReq) (*msg.Cl
|
||||
if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := m.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil {
|
||||
if err := m.MsgInterface.CleanUpUserMsg(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//if err := m.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package msg
|
||||
import (
|
||||
"Open_IM/internal/common/notification"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
|
@ -5,10 +5,8 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
@ -29,7 +27,7 @@ func CallbackSetMessageReactionExtensions(ctx context.Context, setReq *msg.SetMe
|
||||
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeSetMessageReactionExtResp{}
|
||||
return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
}
|
||||
|
||||
func CallbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) error {
|
||||
@ -48,52 +46,39 @@ func CallbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReacti
|
||||
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
|
||||
}
|
||||
resp := &cbapi.CallbackDeleteMessageReactionExtResp{}
|
||||
defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||
return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
}
|
||||
|
||||
//func CallbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) error {
|
||||
// if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
|
||||
// return nil
|
||||
// }
|
||||
// req := cbapi.CallbackGetMessageListReactionExtReq{
|
||||
// OperationID: getReq.OperationID,
|
||||
// CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand,
|
||||
// SourceID: getReq.SourceID,
|
||||
// OpUserID: getReq.OpUserID,
|
||||
// SessionType: getReq.SessionType,
|
||||
// TypeKeyList: getReq.TypeKeyList,
|
||||
// MessageKeyList: getReq.MessageReactionKeyList,
|
||||
// }
|
||||
// resp := &cbApi.CallbackGetMessageListReactionExtResp{CommonCallbackResp: &callbackResp}
|
||||
// defer log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||
// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackGetMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
||||
// callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
// callbackResp.ErrMsg = err.Error()
|
||||
// }
|
||||
// return resp
|
||||
//}
|
||||
//func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cb.CallbackAddMessageReactionExtResp {
|
||||
// callbackResp := cbapi.CommonCallbackResp{OperationID: setReq.OperationID}
|
||||
// log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String())
|
||||
// req := cbapi.CallbackAddMessageReactionExtReq{
|
||||
// OperationID: setReq.OperationID,
|
||||
// CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand,
|
||||
// SourceID: setReq.SourceID,
|
||||
// OpUserID: setReq.OpUserID,
|
||||
// SessionType: setReq.SessionType,
|
||||
// ReactionExtensionList: setReq.ReactionExtensionList,
|
||||
// ClientMsgID: setReq.ClientMsgID,
|
||||
// IsReact: setReq.IsReact,
|
||||
// IsExternalExtensions: setReq.IsExternalExtensions,
|
||||
// MsgFirstModifyTime: setReq.MsgFirstModifyTime,
|
||||
// }
|
||||
// resp := &cbapi.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp}
|
||||
// defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime)
|
||||
// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
||||
// callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
// callbackResp.ErrMsg = err.Error()
|
||||
// }
|
||||
// return resp
|
||||
//
|
||||
//}
|
||||
func CallbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) error {
|
||||
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
|
||||
return nil
|
||||
}
|
||||
req := &cbapi.CallbackGetMessageListReactionExtReq{
|
||||
OperationID: getReq.OperationID,
|
||||
CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand,
|
||||
SourceID: getReq.SourceID,
|
||||
OpUserID: getReq.OpUserID,
|
||||
SessionType: getReq.SessionType,
|
||||
TypeKeyList: getReq.TypeKeyList,
|
||||
MessageKeyList: getReq.MessageReactionKeyList,
|
||||
}
|
||||
resp := &cbapi.CallbackGetMessageListReactionExtResp{}
|
||||
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
}
|
||||
|
||||
func CallbackAddMessageReactionExtensions(setReq *msg.ModifyMessageReactionExtensionsReq) error {
|
||||
req := &cbapi.CallbackAddMessageReactionExtReq{
|
||||
OperationID: setReq.OperationID,
|
||||
CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand,
|
||||
SourceID: setReq.SourceID,
|
||||
OpUserID: setReq.OpUserID,
|
||||
SessionType: setReq.SessionType,
|
||||
ReactionExtensionList: setReq.ReactionExtensionList,
|
||||
ClientMsgID: setReq.ClientMsgID,
|
||||
IsReact: setReq.IsReact,
|
||||
IsExternalExtensions: setReq.IsExternalExtensions,
|
||||
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
|
||||
}
|
||||
resp := &cbapi.CallbackAddMessageReactionExtResp{}
|
||||
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -165,14 +165,14 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
|
||||
}
|
||||
|
||||
if revokeMessage.RevokerID != revokeMessage.SourceMessageSendID {
|
||||
resp, err := m.MsgInterface.GetSuperGroupMsg(ctx, data.MsgData.GroupID, revokeMessage.Seq)
|
||||
resp, err := m.MsgInterface.GetSuperGroupMsgBySeqs(ctx, data.MsgData.GroupID, []int64{int64(revokeMessage.Seq)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.ClientMsgID == revokeMessage.ClientMsgID && resp.Seq == revokeMessage.Seq {
|
||||
revokeMessage.SourceMessageSendTime = resp.SendTime
|
||||
revokeMessage.SourceMessageSenderNickname = resp.SenderNickname
|
||||
revokeMessage.SourceMessageSendID = resp.SendID
|
||||
if resp[0].ClientMsgID == revokeMessage.ClientMsgID && resp[0].Seq == int64(revokeMessage.Seq) {
|
||||
revokeMessage.SourceMessageSendTime = resp[0].SendTime
|
||||
revokeMessage.SourceMessageSenderNickname = resp[0].SenderNickname
|
||||
revokeMessage.SourceMessageSendID = resp[0].SendID
|
||||
data.MsgData.Content = []byte(utils.StructToJsonString(revokeMessage))
|
||||
} else {
|
||||
return nil, constant.ErrData.Wrap("MsgData")
|
||||
|
@ -2,7 +2,7 @@ package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
promePkg "Open_IM/pkg/common/prome"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
@ -67,7 +67,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *msg.SendMsgReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
isSend, err := modifyMessageByUserMessageReceiveOpt(req.MsgData.RecvID, req.MsgData.SendID, constant.SingleChatType, req)
|
||||
isSend, err := m.modifyMessageByUserMessageReceiveOpt(ctx, req.MsgData.RecvID, req.MsgData.SendID, constant.SingleChatType, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/openKeeper"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
promePkg "Open_IM/pkg/common/prome"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -4,13 +4,14 @@ import (
|
||||
"Open_IM/internal/common/check"
|
||||
"Open_IM/internal/common/convert"
|
||||
"Open_IM/internal/common/notification"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/controller"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
tablerelation "Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
registry "Open_IM/pkg/discoveryregistry"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
pbuser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
@ -20,27 +21,37 @@ import (
|
||||
)
|
||||
|
||||
type userServer struct {
|
||||
controller.UserInterface
|
||||
controller.UserDatabase
|
||||
notification *notification.Check
|
||||
userCheck *check.UserCheck
|
||||
ConversationChecker *check.ConversationChecker
|
||||
RegisterCenter discoveryRegistry.SvcDiscoveryRegistry
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
friendCheck *check.FriendChecker
|
||||
}
|
||||
|
||||
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||
mysql, err := relation.NewGormDB()
|
||||
gormDB, err := relation.NewGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mysql.AutoMigrate(&tablerelation.UserModel{}); err != nil {
|
||||
if err := gormDB.AutoMigrate(&tablerelation.UserModel{}); err != nil {
|
||||
return err
|
||||
}
|
||||
pbuser.RegisterUserServer(server, &userServer{
|
||||
UserInterface: controller.NewUserController(mysql),
|
||||
u := &userServer{
|
||||
UserDatabase: controller.NewUserDatabase(relation.NewUserGorm(gormDB)),
|
||||
notification: notification.NewCheck(client),
|
||||
userCheck: check.NewUserCheck(client),
|
||||
RegisterCenter: client,
|
||||
})
|
||||
}
|
||||
pbuser.RegisterUserServer(server, u)
|
||||
users := make([]*tablerelation.UserModel, 0)
|
||||
if len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname) {
|
||||
return constant.ErrConfig.Wrap("len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname)")
|
||||
}
|
||||
for k, v := range config.Config.Manager.AppManagerUid {
|
||||
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.Config.Manager.Nickname[k]})
|
||||
}
|
||||
u.UserDatabase.InitOnce(context.Background(), users)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -58,10 +69,6 @@ func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesig
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetAllPageFriends(ctx context.Context, ownerUserID string) (resp []*sdkws.FriendInfo, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// ok
|
||||
func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserInfoReq) (resp *pbuser.UpdateUserInfoResp, err error) {
|
||||
resp = &pbuser.UpdateUserInfoResp{}
|
||||
@ -69,14 +76,6 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//oldNickname := ""
|
||||
//if req.UserInfo.Nickname != "" {
|
||||
// u, err := s.FindWithError(ctx, []string{req.UserInfo.UserID})
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// oldNickname = u[0].Nickname
|
||||
//}
|
||||
user, err := convert.NewPBUser(req.UserInfo).Convert()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -85,7 +84,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friends, err := s.GetAllPageFriends(ctx, req.UserInfo.UserID)
|
||||
friends, err := s.friendCheck.GetAllPageFriends(ctx, req.UserInfo.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -94,9 +93,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
||||
s.notification.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
|
||||
}
|
||||
}()
|
||||
|
||||
s.notification.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -184,3 +181,13 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.GetGlobalRecvMessageOptReq) (resp *pbuser.GetGlobalRecvMessageOptResp, err error) {
|
||||
resp = &pbuser.GetGlobalRecvMessageOptResp{}
|
||||
user, err := s.FindWithError(ctx, []string{req.UserID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.GlobalRecvMsgOpt = user[0].GlobalRecvMsgOpt
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/middleware"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
promePkg "Open_IM/pkg/common/prome"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/OpenIMSDK/openKeeper"
|
||||
|
19
internal/tx/gorm.go
Normal file
19
internal/tx/gorm.go
Normal file
@ -0,0 +1,19 @@
|
||||
package tx
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func NewGorm(db *gorm.DB) Tx {
|
||||
return &_Gorm{tx: db}
|
||||
}
|
||||
|
||||
type _Gorm struct {
|
||||
tx *gorm.DB
|
||||
}
|
||||
|
||||
func (g *_Gorm) Transaction(fn func(tx any) error) error {
|
||||
return g.tx.Transaction(func(tx *gorm.DB) error {
|
||||
return fn(tx)
|
||||
})
|
||||
}
|
31
internal/tx/mongo.go
Normal file
31
internal/tx/mongo.go
Normal file
@ -0,0 +1,31 @@
|
||||
package tx
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
func NewMongo(client *mongo.Client) CtxTx {
|
||||
return &_Mongo{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
type _Mongo struct {
|
||||
client *mongo.Client
|
||||
}
|
||||
|
||||
func (m *_Mongo) Transaction(ctx context.Context, fn func(ctx context.Context) error) error {
|
||||
sess, err := m.client.StartSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sCtx := mongo.NewSessionContext(ctx, sess)
|
||||
defer sess.EndSession(sCtx)
|
||||
if err := fn(sCtx); err != nil {
|
||||
_ = sess.AbortTransaction(sCtx)
|
||||
return err
|
||||
}
|
||||
return utils.Wrap(sess.CommitTransaction(sCtx), "")
|
||||
}
|
11
internal/tx/tx.go
Normal file
11
internal/tx/tx.go
Normal file
@ -0,0 +1,11 @@
|
||||
package tx
|
||||
|
||||
import "context"
|
||||
|
||||
type Tx interface {
|
||||
Transaction(fn func(tx any) error) error
|
||||
}
|
||||
|
||||
type CtxTx interface {
|
||||
Transaction(ctx context.Context, fn func(ctx context.Context) error) error
|
||||
}
|
@ -99,3 +99,38 @@ type CallbackDeleteMessageReactionExtResp struct {
|
||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
||||
type CallbackGetMessageListReactionExtReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
SourceID string `json:"sourceID"`
|
||||
OpUserID string `json:"opUserID"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
TypeKeyList []string `json:"typeKeyList"`
|
||||
MessageKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageKeyList"`
|
||||
}
|
||||
|
||||
type CallbackGetMessageListReactionExtResp struct {
|
||||
CommonCallbackResp
|
||||
MessageResultList []*msg.SingleMessageExtensionResult `json:"messageResultList"`
|
||||
}
|
||||
|
||||
type CallbackAddMessageReactionExtReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
SourceID string `json:"sourceID"`
|
||||
OpUserID string `json:"opUserID"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
ReactionExtensionList map[string]*sdkws.KeyValue `json:"reactionExtensionList"`
|
||||
ClientMsgID string `json:"clientMsgID"`
|
||||
IsReact bool `json:"isReact"`
|
||||
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
||||
type CallbackAddMessageReactionExtResp struct {
|
||||
CommonCallbackResp
|
||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||
IsReact bool `json:"isReact"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
@ -213,8 +213,8 @@ type config struct {
|
||||
}
|
||||
Manager struct {
|
||||
AppManagerUid []string `yaml:"appManagerUid"`
|
||||
Secrets []string `yaml:"secrets"`
|
||||
AppSysNotificationName string `yaml:"appSysNotificationName"`
|
||||
// AppSysNotificationName string `yaml:"appSysNotificationName"`
|
||||
Nickname []string `yaml:"nickname"`
|
||||
}
|
||||
|
||||
Kafka struct {
|
||||
|
@ -202,6 +202,8 @@ const (
|
||||
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
|
||||
CallbackBeforeSetMessageReactionExtensionCommand = "callbackBeforeSetMessageReactionExtensionCommand"
|
||||
CallbackBeforeDeleteMessageReactionExtensionsCommand = "callbackBeforeDeleteMessageReactionExtensionsCommand"
|
||||
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
|
||||
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
|
||||
|
||||
//callback actionCode
|
||||
ActionAllow = 0
|
||||
@ -315,16 +317,8 @@ func GroupIsBanPrivateChat(status int32) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const (
|
||||
TokenKicked = 1001
|
||||
)
|
||||
|
||||
const BigVersion = "v2"
|
||||
|
||||
const LogFileName = "OpenIM.log"
|
||||
|
||||
const StatisticsTimeInterval = 60
|
||||
|
||||
const MaxNotificationNum = 500
|
||||
|
||||
const CurrentVersion = "v2.3.4-rc0"
|
||||
|
@ -14,7 +14,6 @@ var (
|
||||
ErrUserIDNotFound = &ErrInfo{UserIDNotFoundError, "UserIDNotFoundError", ""}
|
||||
ErrGroupIDNotFound = &ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError", ""}
|
||||
ErrGroupIDExisted = &ErrInfo{GroupIDNotFoundError, "GroupIDExisted", ""} // todo group id 已存在
|
||||
ErrGroupIDExisted = &ErrInfo{GroupIDNotFoundError, "GroupIDExisted", ""} // todo group id 已存在
|
||||
|
||||
ErrRecordNotFound = &ErrInfo{RecordNotFoundError, "RecordNotFoundError", ""}
|
||||
|
||||
@ -54,6 +53,13 @@ var (
|
||||
//
|
||||
ErrMutedInGroup = &ErrInfo{MutedInGroup, "MutedInGroup", ""}
|
||||
ErrMutedGroup = &ErrInfo{MutedGroup, "MutedGroup", ""}
|
||||
|
||||
ErrConnOverMaxNumLimit = &ErrInfo{ConnOverMaxNumLimit, "ConnOverMaxNumLimit", ""}
|
||||
|
||||
ErrConnArgsErr = &ErrInfo{ConnArgsErr, "args err, need token, sendID, platformID", ""}
|
||||
ErrConnUpdateErr = &ErrInfo{ConnArgsErr, "upgrade http conn err", ""}
|
||||
|
||||
ErrConfig = &ErrInfo{ConfigError, "ConfigError", ""}
|
||||
)
|
||||
|
||||
const (
|
||||
@ -87,6 +93,8 @@ const (
|
||||
DataError = 90007 //数据错误
|
||||
|
||||
IdentityError = 90008 // 身份错误 非管理员token,且token中userID与请求userID不一致
|
||||
|
||||
ConfigError = 90009
|
||||
)
|
||||
|
||||
// 账号错误码
|
||||
@ -142,6 +150,13 @@ const (
|
||||
MessageHasReadDisable = 96001
|
||||
)
|
||||
|
||||
// 长连接网关错误码
|
||||
const (
|
||||
ConnOverMaxNumLimit = 970001
|
||||
ConnArgsErr = 970002
|
||||
ConnUpdateErr = 970003
|
||||
)
|
||||
|
||||
// temp
|
||||
|
||||
var (
|
||||
|
@ -2,4 +2,6 @@ package constant
|
||||
|
||||
const (
|
||||
ShowNumber = 1000
|
||||
StatisticsTimeInterval = 60
|
||||
MaxNotificationNum = 500
|
||||
)
|
||||
|
28
pkg/common/db/cache/black.go
vendored
28
pkg/common/db/cache/black.go
vendored
@ -1,10 +1,10 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"time"
|
||||
@ -26,6 +26,7 @@ type BlackCache interface {
|
||||
type BlackCacheRedis struct {
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
black *relation.BlackGorm
|
||||
}
|
||||
|
||||
func NewBlackCacheRedis(rdb redis.UniversalClient, blackDB BlackCache, options rockscache.Options) *BlackCacheRedis {
|
||||
@ -40,31 +41,14 @@ func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
|
||||
}
|
||||
|
||||
func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
|
||||
getBlackIDList := func() (string, error) {
|
||||
blackIDs, err := b.blackDB.GetBlackIDs(ctx, userID)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(blackIDs)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "blackIDList", blackIDs)
|
||||
}()
|
||||
blackIDListStr, err := b.rcClient.Fetch(blackListCache+userID, b.expireTime, getBlackIDList)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
err = json.Unmarshal([]byte(blackIDListStr), &blackIDs)
|
||||
return blackIDs, utils.Wrap(err, "")
|
||||
return GetCache(ctx, b.rcClient, b.getBlackIDsKey(userID), b.expireTime, func(ctx context.Context) ([]string, error) {
|
||||
return b.black.FindBlackUserIDs(ctx, userID)
|
||||
})
|
||||
}
|
||||
|
||||
func (b *BlackCacheRedis) DelBlackIDs(ctx context.Context, userID string) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
|
||||
}()
|
||||
return b.rcClient.TagAsDeleted(blackListCache + userID)
|
||||
return b.rcClient.TagAsDeleted(b.getBlackIDsKey(userID))
|
||||
}
|
||||
|
269
pkg/common/db/cache/conversation.go
vendored
269
pkg/common/db/cache/conversation.go
vendored
@ -6,10 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"golang.org/x/tools/go/ssa/testdata/src/strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -20,6 +18,7 @@ const (
|
||||
superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
||||
conversationExpireTime = time.Second * 60 * 60 * 12
|
||||
)
|
||||
|
||||
type FuncDB func() (string, error)
|
||||
|
||||
// arg fn will exec when no data in cache
|
||||
@ -28,13 +27,13 @@ type ConversationCache interface {
|
||||
GetUserConversationIDs(ctx context.Context, userID string, fn FuncDB) ([]string, error)
|
||||
// del user's conversationIDs from cache, call when a user add or reduce a conversation
|
||||
DelUserConversationIDs(ctx context.Context, userID string) error
|
||||
DelUsersConversationIDs(ctx context.Context,userIDList []string)error
|
||||
DelUsersConversationIDs(ctx context.Context, userIDList []string) error
|
||||
// get one conversation from cache
|
||||
GetConversation(ctx context.Context, ownerUserID, conversationID string, fn FuncDB) (*relationTb.ConversationModel, error)
|
||||
// get one conversation from cache
|
||||
GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB)([]*relationTb.ConversationModel, error)
|
||||
GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error)
|
||||
// get one user's all conversations from cache
|
||||
GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB ) ([]*relationTb.ConversationModel, error)
|
||||
GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error)
|
||||
// del one conversation from cache, call when one user's conversation Info changed
|
||||
DelConversation(ctx context.Context, ownerUserID, conversationID string) error
|
||||
DelUserConversations(ctx context.Context, ownerUserID string, conversationIDList []string) error
|
||||
@ -51,11 +50,47 @@ type ConversationCache interface {
|
||||
//DelSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string)
|
||||
}
|
||||
|
||||
type ConversationRedis struct {
|
||||
rcClient *rockscache.Client
|
||||
func NewConversationRedis(rdb redis.UniversalClient, opts rockscache.Options) ConversationCache {
|
||||
return &ConversationRedis{rcClient: rockscache.NewClient(rdb, opts)}
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) ([]string, error) {
|
||||
type ConversationRedis struct {
|
||||
rcClient *rockscache.Client
|
||||
expireTime time.Duration
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, userID string, fn FuncDB) ([]string, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string, fn FuncDB) (*relationTb.ConversationModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) DelUserConversations(ctx context.Context, ownerUserID string, conversationIDList []string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (opt int, err error)) (opt int, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (userIDs []string, err error)) (userIDs []string, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
@ -63,34 +98,10 @@ func (c *ConversationRedis) DelUsersConversationIDs(ctx context.Context, userIDL
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error)) (*relationTb.ConversationModel, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) DelUsersConversation(ctx context.Context, ownerUserIDList []string, conversationID string) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (opt int, err error)) (opt int, err error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (userIDs []string, err error)) (userIDs []string, err error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func NewConversationRedis(rcClient *rockscache.Client) *ConversationRedis {
|
||||
return &ConversationRedis{rcClient: rcClient}
|
||||
}
|
||||
|
||||
func NewNewConversationRedis(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) *ConversationRedis {
|
||||
return &ConversationRedis{rcClient: rockscache.NewClient(rdb, options)}
|
||||
}
|
||||
@ -111,31 +122,31 @@ func (c *ConversationRedis) getSuperGroupRecvNotNotifyUserIDsKey(groupID string)
|
||||
return superGroupRecvMsgNotNotifyUserIDsKey + groupID
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(userID string) ([]string, error)) (conversationIDs []string, err error) {
|
||||
//getConversationIDs := func() (string, error) {
|
||||
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// bytes, err := json.Marshal(conversationIDs)
|
||||
// if err != nil {
|
||||
// return "", utils.Wrap(err, "")
|
||||
// }
|
||||
// return string(bytes), nil
|
||||
//}
|
||||
//defer func() {
|
||||
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs)
|
||||
//}()
|
||||
//conversationIDsStr, err := c.rcClient.Fetch(c.getConversationIDsKey(ownerUserID), time.Second*30*60, getConversationIDs)
|
||||
//err = json.Unmarshal([]byte(conversationIDsStr), &conversationIDs)
|
||||
//if err != nil {
|
||||
// return nil, utils.Wrap(err, "")
|
||||
//}
|
||||
//return conversationIDs, nil
|
||||
return GetCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, func(ctx context.Context) ([]string, error) {
|
||||
return f(ownerUserID)
|
||||
})
|
||||
}
|
||||
//func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, ownerUserID string) (conversationIDs []string, err error) {
|
||||
// //getConversationIDs := func() (string, error) {
|
||||
// // conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
||||
// // if err != nil {
|
||||
// // return "", err
|
||||
// // }
|
||||
// // bytes, err := json.Marshal(conversationIDs)
|
||||
// // if err != nil {
|
||||
// // return "", utils.Wrap(err, "")
|
||||
// // }
|
||||
// // return string(bytes), nil
|
||||
// //}
|
||||
// //defer func() {
|
||||
// // tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs)
|
||||
// //}()
|
||||
// //conversationIDsStr, err := c.rcClient.Fetch(c.getConversationIDsKey(ownerUserID), time.Second*30*60, getConversationIDs)
|
||||
// //err = json.Unmarshal([]byte(conversationIDsStr), &conversationIDs)
|
||||
// //if err != nil {
|
||||
// // return nil, utils.Wrap(err, "")
|
||||
// //}
|
||||
// //return conversationIDs, nil
|
||||
// return GetCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, func(ctx context.Context) ([]string, error) {
|
||||
// panic("implement me")
|
||||
// })
|
||||
//}
|
||||
|
||||
func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUserID string) (conversationIDs []string, err error) {
|
||||
//getConversationIDs := func() (string, error) {
|
||||
@ -158,7 +169,11 @@ func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUs
|
||||
// return nil, utils.Wrap(err, "")
|
||||
//}
|
||||
//return conversationIDs, nil
|
||||
return GetCache1[[]string](c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, fn)
|
||||
//return GetCache1[[]string](c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, fn)
|
||||
|
||||
return GetCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, func(ctx context.Context) ([]string, error) {
|
||||
panic("")
|
||||
})
|
||||
}
|
||||
|
||||
//func GetCache1[T any](rcClient *rockscache.Client, key string, expire time.Duration, fn func() (any, error)) (T, error) {
|
||||
@ -191,29 +206,11 @@ func (c *ConversationRedis) DelUserConversationIDs(ctx context.Context, ownerUse
|
||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationIDsKey(ownerUserID)), "DelUserConversationIDs err")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string) (conversation *relationTb.Conversation, err error) {
|
||||
getConversation := func() (string, error) {
|
||||
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
bytes, err := json.Marshal(conversation)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "conversation Marshal failed")
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID, "conversation", *conversation)
|
||||
}()
|
||||
conversationStr, err := c.rcClient.Fetch(c.getConversationKey(ownerUserID, conversationID), c.expireTime, getConversation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conversation = &relationTb.ConversationModel{}
|
||||
err = json.Unmarshal([]byte(conversationStr), &conversation)
|
||||
return conversation, utils.Wrap(err, "Unmarshal failed")
|
||||
}
|
||||
//func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string) (conversation *relationTb.ConversationModel, err error) {
|
||||
// return GetCache(ctx, c.rcClient, c.getConversationKey(ownerUserID, conversationID), c.expireTime, func(ctx context.Context) (*relationTb.ConversationModel, error) {
|
||||
// panic("implement me")
|
||||
// })
|
||||
//}
|
||||
|
||||
func (c *ConversationRedis) DelConversation(ctx context.Context, ownerUserID, conversationID string) (err error) {
|
||||
defer func() {
|
||||
@ -222,73 +219,73 @@ func (c *ConversationRedis) DelConversation(ctx context.Context, ownerUserID, co
|
||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelConversation err")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []relationTb.ConversationModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
|
||||
}()
|
||||
for _, conversationID := range conversationIDs {
|
||||
conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conversations = append(conversations, *conversation)
|
||||
}
|
||||
return conversations, nil
|
||||
}
|
||||
//func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []relationTb.ConversationModel, err error) {
|
||||
// defer func() {
|
||||
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
|
||||
// }()
|
||||
// for _, conversationID := range conversationIDs {
|
||||
// conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// conversations = append(conversations, *conversation)
|
||||
// }
|
||||
// return conversations, nil
|
||||
//}
|
||||
|
||||
func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string) (conversations []relationTb.ConversationModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
|
||||
}()
|
||||
IDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var conversationIDs []relationTb.ConversationModel
|
||||
for _, conversationID := range IDs {
|
||||
conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conversationIDs = append(conversationIDs, *conversation)
|
||||
}
|
||||
return conversationIDs, nil
|
||||
}
|
||||
//func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string) (conversations []relationTb.ConversationModel, err error) {
|
||||
// defer func() {
|
||||
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
|
||||
// }()
|
||||
// IDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// var conversationIDs []relationTb.ConversationModel
|
||||
// for _, conversationID := range IDs {
|
||||
// conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// conversationIDs = append(conversationIDs, *conversation)
|
||||
// }
|
||||
// return conversationIDs, nil
|
||||
//}
|
||||
|
||||
func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
|
||||
getConversation := func() (string, error) {
|
||||
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strconv.Itoa(int(conversation.RecvMsgOpt)), nil
|
||||
}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID, "opt", opt)
|
||||
}()
|
||||
optStr, err := c.rcClient.Fetch(c.getConversationKey(ownerUserID, conversationID), c.expireTime, getConversation)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return strconv.Atoi(optStr)
|
||||
}
|
||||
//func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
|
||||
// //getConversation := func() (string, error) {
|
||||
// // conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
||||
// // if err != nil {
|
||||
// // return "", err
|
||||
// // }
|
||||
// // return strconv.Itoa(int(conversation.RecvMsgOpt)), nil
|
||||
// //}
|
||||
// //defer func() {
|
||||
// // tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID, "opt", opt)
|
||||
// //}()
|
||||
// //optStr, err := c.rcClient.Fetch(c.getConversationKey(ownerUserID, conversationID), c.expireTime, getConversation)
|
||||
// //if err != nil {
|
||||
// // return 0, err
|
||||
// //}
|
||||
// //return strconv.Atoi(optStr)
|
||||
// // panic("implement me")
|
||||
// return GetCache(ctx, c.rcClient, c.getConversationKey(ownerUserID, conversationID), c.expireTime, func(ctx context.Context) (int, error) {
|
||||
// panic("implement me")
|
||||
// })
|
||||
//}
|
||||
|
||||
func (c *ConversationRedis) DelUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) error {
|
||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelUserRecvMsgOpt failed")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) DelSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (err error) {
|
||||
return nil
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint32, err error) {
|
||||
return
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *ConversationRedis) DelSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) {
|
||||
return
|
||||
panic("implement me")
|
||||
}
|
||||
|
56
pkg/common/db/cache/extend_msg_set.go
vendored
56
pkg/common/db/cache/extend_msg_set.go
vendored
@ -19,34 +19,42 @@ type ExtendMsgSetCache struct {
|
||||
rcClient *rockscache.Client
|
||||
}
|
||||
|
||||
func (e *ExtendMsgSetCache) GetExtendMsg(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, firstModifyTime int64) (extendMsg *unrelation.ExtendMsg, err error) {
|
||||
getExtendMsg := func() (string, error) {
|
||||
extendMsg, err := db.DB.GetExtendMsg(sourceID, sessionType, clientMsgID, firstModifyTime)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "GetExtendMsgList failed")
|
||||
}
|
||||
bytes, err := json.Marshal(extendMsg)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "Marshal failed")
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sourceID", sourceID, "sessionType",
|
||||
sessionType, "clientMsgID", clientMsgID, "firstModifyTime", firstModifyTime, "extendMsg", extendMsg)
|
||||
}()
|
||||
extendMsgStr, err := db.DB.Rc.Fetch(extendMsgCache+clientMsgID, time.Second*30*60, getExtendMsg)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "Fetch failed")
|
||||
}
|
||||
extendMsg = &mongoDB.ExtendMsg{}
|
||||
err = json.Unmarshal([]byte(extendMsgStr), extendMsg)
|
||||
return extendMsg, utils.Wrap(err, "Unmarshal failed")
|
||||
func (e *ExtendMsgSetCache) getKey(clientMsgID string) string {
|
||||
return extendMsgCache + clientMsgID
|
||||
}
|
||||
|
||||
func (e *ExtendMsgSetCache) GetExtendMsg(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, firstModifyTime int64) (extendMsg *unrelation.ExtendMsgModel, err error) {
|
||||
//getExtendMsg := func() (string, error) {
|
||||
// extendMsg, err := db.DB.GetExtendMsg(sourceID, sessionType, clientMsgID, firstModifyTime)
|
||||
// if err != nil {
|
||||
// return "", utils.Wrap(err, "GetExtendMsgList failed")
|
||||
// }
|
||||
// bytes, err := json.Marshal(extendMsg)
|
||||
// if err != nil {
|
||||
// return "", utils.Wrap(err, "Marshal failed")
|
||||
// }
|
||||
// return string(bytes), nil
|
||||
//}
|
||||
//defer func() {
|
||||
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sourceID", sourceID, "sessionType",
|
||||
// sessionType, "clientMsgID", clientMsgID, "firstModifyTime", firstModifyTime, "extendMsg", extendMsg)
|
||||
//}()
|
||||
//extendMsgStr, err := db.DB.Rc.Fetch(extendMsgCache+clientMsgID, time.Second*30*60, getExtendMsg)
|
||||
//if err != nil {
|
||||
// return nil, utils.Wrap(err, "Fetch failed")
|
||||
//}
|
||||
//extendMsg = &mongoDB.ExtendMsg{}
|
||||
//err = json.Unmarshal([]byte(extendMsgStr), extendMsg)
|
||||
//return extendMsg, utils.Wrap(err, "Unmarshal failed")
|
||||
return GetCache(ctx, e.rcClient, e.getKey(clientMsgID), e.expireTime, func(ctx context.Context) (*unrelation.ExtendMsgModel, error) {
|
||||
panic("")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (e *ExtendMsgSetCache) DelExtendMsg(ctx context.Context, clientMsgID string) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "clientMsgID", clientMsgID)
|
||||
}()
|
||||
return utils.Wrap(db.DB.Rc.TagAsDeleted(extendMsgCache+clientMsgID), "DelExtendMsg err")
|
||||
return utils.Wrap(e.rcClient.TagAsDeleted(e.getKey(clientMsgID)), "DelExtendMsg err")
|
||||
}
|
||||
|
25
pkg/common/db/cache/friend.go
vendored
25
pkg/common/db/cache/friend.go
vendored
@ -56,27 +56,10 @@ func (f *FriendCacheRedis) getFriendKey(ownerUserID, friendUserID string) string
|
||||
return friendKey + ownerUserID + "-" + friendUserID
|
||||
}
|
||||
|
||||
func (f *FriendCacheRedis) GetFriendIDs(ctx context.Context, ownerUserID string, fn func(ctx context.Context, ownerUserID string) (friendIDs []string, err error)) (friendIDs []string, err error) {
|
||||
getFriendIDs := func() (string, error) {
|
||||
friendIDs, err := f.friendDB.GetFriendIDs(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
bytes, err := json.Marshal(friendIDs)
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendIDs", friendIDs)
|
||||
}()
|
||||
friendIDsStr, err := f.rcClient.Fetch(f.getFriendIDsKey(ownerUserID), f.expireTime, getFriendIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal([]byte(friendIDsStr), &friendIDs)
|
||||
return friendIDs, utils.Wrap(err, "")
|
||||
func (f *FriendCacheRedis) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
|
||||
return GetCache(ctx, f.rcClient, f.getFriendIDsKey(ownerUserID), f.expireTime, func(ctx context.Context) ([]string, error) {
|
||||
return f.friendDB.FindFriendUserIDs(ctx, ownerUserID)
|
||||
})
|
||||
}
|
||||
|
||||
func (f *FriendCacheRedis) DelFriendIDs(ctx context.Context, ownerUserID string) (err error) {
|
||||
|
25
pkg/common/db/cache/group.go
vendored
25
pkg/common/db/cache/group.go
vendored
@ -2,7 +2,7 @@ package cache
|
||||
|
||||
import (
|
||||
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/db/unrelation"
|
||||
unrelation2 "Open_IM/pkg/common/db/table/unrelation"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@ -51,17 +51,36 @@ type GroupCache interface {
|
||||
DelGroupMemberNum(ctx context.Context, groupID string) (err error)
|
||||
}
|
||||
|
||||
type GroupCacheRedisInterface interface {
|
||||
GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
BatchDelJoinedSuperGroupIDs(ctx context.Context, userIDs []string) (err error)
|
||||
DelJoinedSuperGroupIDs(ctx context.Context, userID string) (err error)
|
||||
GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error)
|
||||
GetGroupMembersHash(ctx context.Context, groupID string) (hashCodeUint64 uint64, err error)
|
||||
GetGroupMemberHash1(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||
DelGroupMembersHash(ctx context.Context, groupID string) (err error)
|
||||
GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)
|
||||
DelGroupMemberIDs(ctx context.Context, groupID string) (err error)
|
||||
DelJoinedGroupID(ctx context.Context, userID string) (err error)
|
||||
GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
DelGroupMemberInfo(ctx context.Context, groupID, userID string) (err error)
|
||||
DelGroupMemberNum(ctx context.Context, groupID string) (err error)
|
||||
DelGroupInfo(ctx context.Context, groupID string) (err error)
|
||||
DelGroupsInfo(ctx context.Context, groupIDs []string) error
|
||||
}
|
||||
|
||||
type GroupCacheRedis struct {
|
||||
group relationTb.GroupModelInterface
|
||||
groupMember relationTb.GroupMemberModelInterface
|
||||
groupRequest relationTb.GroupRequestModelInterface
|
||||
mongoDB *unrelation.SuperGroupMongoDriver
|
||||
mongoDB unrelation2.SuperGroupModelInterface
|
||||
expireTime time.Duration
|
||||
redisClient *RedisClient
|
||||
rcClient *rockscache.Client
|
||||
}
|
||||
|
||||
func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModelInterface, groupMemberDB relationTb.GroupMemberModelInterface, groupRequestDB relationTb.GroupRequestModelInterface, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCacheRedis {
|
||||
func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModelInterface, groupMemberDB relationTb.GroupMemberModelInterface, groupRequestDB relationTb.GroupRequestModelInterface, mongoClient unrelation2.SuperGroupModelInterface, opts rockscache.Options) GroupCacheRedisInterface {
|
||||
return &GroupCacheRedis{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
||||
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
||||
mongoDB: mongoClient,
|
||||
|
37
pkg/common/db/cache/redis.go
vendored
37
pkg/common/db/cache/redis.go
vendored
@ -35,6 +35,8 @@ const (
|
||||
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
|
||||
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
|
||||
exTypeKeyLocker = "EX_LOCK:"
|
||||
|
||||
uidPidToken = "UID_PID_TOKEN_STATUS:"
|
||||
)
|
||||
|
||||
type Cache interface {
|
||||
@ -52,7 +54,9 @@ type Cache interface {
|
||||
SetGroupMinSeq(ctx context.Context, groupID string, minSeq int64) error
|
||||
|
||||
AddTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error
|
||||
GetTokenMapByUidPid(ctx context.Context, userID, platformID string) (map[string]int, error)
|
||||
|
||||
GetTokensWithoutError(ctx context.Context, userID, platformID string) (map[string]int, error)
|
||||
|
||||
SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error
|
||||
DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error
|
||||
GetMessageListBySeq(ctx context.Context, userID string, seqList []int64) (seqMsg []*sdkws.MsgData, failedSeqList []int64, err error)
|
||||
@ -139,6 +143,10 @@ func NewRedisClient(rdb redis.UniversalClient) *RedisClient {
|
||||
return &RedisClient{rdb: rdb}
|
||||
}
|
||||
|
||||
func (r *RedisClient) GetClient() redis.UniversalClient {
|
||||
return r.rdb
|
||||
}
|
||||
|
||||
// Perform seq auto-increment operation of user messages
|
||||
func (r *RedisClient) IncrUserSeq(ctx context.Context, uid string) (int64, error) {
|
||||
key := userIncrSeq + uid
|
||||
@ -205,11 +213,12 @@ func (r *RedisClient) SetGroupMinSeq(ctx context.Context, groupID string, minSeq
|
||||
}
|
||||
|
||||
// Store userid and platform class to redis
|
||||
func (r *RedisClient) AddTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
func (r *RedisClient) AddTokenFlag(ctx context.Context, userID string, platform string, token string, flag int) error {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
return r.rdb.HSet(context.Background(), key, token, flag).Err()
|
||||
}
|
||||
|
||||
//key:userID+platform-> <token, flag>
|
||||
func (r *RedisClient) GetTokenMapByUidPid(ctx context.Context, userID, platformID string) (map[string]int, error) {
|
||||
key := uidPidToken + userID + ":" + platformID
|
||||
m, err := r.rdb.HGetAll(context.Background(), key).Result()
|
||||
@ -219,8 +228,22 @@ func (r *RedisClient) GetTokenMapByUidPid(ctx context.Context, userID, platformI
|
||||
}
|
||||
return mm, err
|
||||
}
|
||||
func (r *RedisClient) SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
|
||||
func (r *RedisClient) GetTokensWithoutError(ctx context.Context, userID, platform string) (map[string]int, error) {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
m, err := r.rdb.HGetAll(context.Background(), key).Result()
|
||||
if err != nil && err == redis.Nil {
|
||||
return nil, nil
|
||||
}
|
||||
mm := make(map[string]int)
|
||||
for k, v := range m {
|
||||
mm[k] = utils.StringToInt(v)
|
||||
}
|
||||
return mm, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func (r *RedisClient) SetTokenMapByUidPid(ctx context.Context, userID string, platform string, m map[string]int) error {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
mm := make(map[string]interface{})
|
||||
for k, v := range m {
|
||||
mm[k] = v
|
||||
@ -228,8 +251,8 @@ func (r *RedisClient) SetTokenMapByUidPid(ctx context.Context, userID string, pl
|
||||
return r.rdb.HSet(context.Background(), key, mm).Err()
|
||||
}
|
||||
|
||||
func (r *RedisClient) DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
func (r *RedisClient) DeleteTokenByUidPid(ctx context.Context, userID string, platform string, fields []string) error {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
return r.rdb.HDel(context.Background(), key, fields...).Err()
|
||||
}
|
||||
|
||||
|
62
pkg/common/db/cache/rockscache.go
vendored
62
pkg/common/db/cache/rockscache.go
vendored
@ -10,38 +10,36 @@ import (
|
||||
|
||||
const scanCount = 3000
|
||||
|
||||
|
||||
func (rc *RcClient) DelKeys() {
|
||||
for _, key := range []string{"GROUP_CACHE:", "FRIEND_RELATION_CACHE", "BLACK_LIST_CACHE:", "USER_INFO_CACHE:", "GROUP_INFO_CACHE", groupOwnerIDCache, joinedGroupListCache,
|
||||
groupMemberInfoCache, groupAllMemberInfoCache, "ALL_FRIEND_INFO_CACHE:"} {
|
||||
fName := utils.GetSelfFuncName()
|
||||
var cursor uint64
|
||||
var n int
|
||||
for {
|
||||
var keys []string
|
||||
var err error
|
||||
keys, cursor, err = rc.rdb.Scan(context.Background(), cursor, key+"*", scanCount).Result()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
n += len(keys)
|
||||
// for each for redis cluster
|
||||
for _, key := range keys {
|
||||
if err = rc.rdb.Del(context.Background(), key).Err(); err != nil {
|
||||
log.NewError("", fName, key, err.Error())
|
||||
err = rc.rdb.Del(context.Background(), key).Err()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
if cursor == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//func (rc *RcClient) DelKeys() {
|
||||
// for _, key := range []string{"GROUP_CACHE:", "FRIEND_RELATION_CACHE", "BLACK_LIST_CACHE:", "USER_INFO_CACHE:", "GROUP_INFO_CACHE", groupOwnerIDCache, joinedGroupListCache,
|
||||
// groupMemberInfoCache, groupAllMemberInfoCache, "ALL_FRIEND_INFO_CACHE:"} {
|
||||
// fName := utils.GetSelfFuncName()
|
||||
// var cursor uint64
|
||||
// var n int
|
||||
// for {
|
||||
// var keys []string
|
||||
// var err error
|
||||
// keys, cursor, err = rc.rdb.Scan(context.Background(), cursor, key+"*", scanCount).Result()
|
||||
// if err != nil {
|
||||
// panic(err.Error())
|
||||
// }
|
||||
// n += len(keys)
|
||||
// // for each for redis cluster
|
||||
// for _, key := range keys {
|
||||
// if err = rc.rdb.Del(context.Background(), key).Err(); err != nil {
|
||||
// log.NewError("", fName, key, err.Error())
|
||||
// err = rc.rdb.Del(context.Background(), key).Err()
|
||||
// if err != nil {
|
||||
// panic(err.Error())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if cursor == 0 {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, expire time.Duration, fn func(ctx context.Context) (T, error)) (T, error) {
|
||||
var t T
|
||||
|
34
pkg/common/db/cache/token.go
vendored
34
pkg/common/db/cache/token.go
vendored
@ -5,14 +5,9 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
uidPidToken = "UID_PID_TOKEN_STATUS:"
|
||||
)
|
||||
|
||||
type Token interface {
|
||||
//结果为空 不返回错误
|
||||
GetTokensWithoutError(ctx context.Context, userID, platform string) (map[string]int, error)
|
||||
@ -21,9 +16,9 @@ type Token interface {
|
||||
}
|
||||
|
||||
type TokenRedis struct {
|
||||
RedisClient *RedisClient
|
||||
AccessSecret string
|
||||
AccessExpire int64
|
||||
redisClient *RedisClient
|
||||
accessSecret string
|
||||
accessExpire int64
|
||||
}
|
||||
|
||||
func NewTokenRedis(redisClient *RedisClient, accessSecret string, accessExpire int64) *TokenRedis {
|
||||
@ -32,21 +27,12 @@ func NewTokenRedis(redisClient *RedisClient, accessSecret string, accessExpire i
|
||||
|
||||
// 结果为空 不返回错误
|
||||
func (t *TokenRedis) GetTokensWithoutError(ctx context.Context, userID, platform string) (map[string]int, error) {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
m, err := t.RedisClient.GetClient().HGetAll(context.Background(), key).Result()
|
||||
if err != nil && err == redis.Nil {
|
||||
return nil, nil
|
||||
}
|
||||
mm := make(map[string]int)
|
||||
for k, v := range m {
|
||||
mm[k] = utils.StringToInt(v)
|
||||
}
|
||||
return mm, utils.Wrap(err, "")
|
||||
return t.redisClient.GetTokensWithoutError(ctx, userID, platform)
|
||||
}
|
||||
|
||||
// 创建token
|
||||
func (t *TokenRedis) CreateToken(ctx context.Context, userID string, platform string) (string, error) {
|
||||
tokens, err := t.GetTokensWithoutError(ctx, userID, platform)
|
||||
tokens, err := t.redisClient.GetTokensWithoutError(ctx, userID, platform)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -58,18 +44,16 @@ func (t *TokenRedis) CreateToken(ctx context.Context, userID string, platform st
|
||||
}
|
||||
}
|
||||
if len(deleteTokenKey) != 0 {
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
err := t.RedisClient.GetClient().HDel(context.Background(), key, deleteTokenKey...).Err()
|
||||
err := t.redisClient.DeleteTokenByUidPid(ctx, userID, platform, deleteTokenKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
claims := tokenverify.BuildClaims(userID, platform, t.AccessExpire)
|
||||
claims := tokenverify.BuildClaims(userID, platform, t.accessExpire)
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
tokenString, err := token.SignedString([]byte(t.AccessSecret))
|
||||
tokenString, err := token.SignedString([]byte(t.accessSecret))
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
key := uidPidToken + userID + ":" + platform
|
||||
return "", utils.Wrap(t.RedisClient.GetClient().HSet(context.Background(), key, tokenString, constant.NormalToken).Err(), "")
|
||||
return tokenString, t.redisClient.AddTokenFlag(ctx, userID, platform, tokenString, constant.NormalToken)
|
||||
}
|
||||
|
14
pkg/common/db/cache/user.go
vendored
14
pkg/common/db/cache/user.go
vendored
@ -73,13 +73,13 @@ func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userIn
|
||||
|
||||
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error) {
|
||||
var users []*relationTb.UserModel
|
||||
for _, userID := range userIDs {
|
||||
user, err := GetUserInfoFromCache(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
users = append(users, user)
|
||||
}
|
||||
//for _, userID := range userIDs {
|
||||
// user, err := GetUserInfoFromCache(ctx, userID)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// users = append(users, user)
|
||||
//}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
type AuthInterface interface {
|
||||
//结果为空 不返回错误
|
||||
GetTokensWithoutError(ctx context.Context, userID, platform string) (map[string]int, error)
|
||||
|
||||
//创建token
|
||||
CreateToken(ctx context.Context, userID string, platform string) (string, error)
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
relation2 "Open_IM/pkg/common/db/relation"
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BlackInterface interface {
|
||||
type BlackDatabase interface {
|
||||
// Create 增加黑名单
|
||||
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||
// Delete 删除黑名单
|
||||
@ -19,75 +19,32 @@ type BlackInterface interface {
|
||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||
}
|
||||
|
||||
type BlackController struct {
|
||||
database BlackDatabaseInterface
|
||||
type blackDatabase struct {
|
||||
black relation.BlackModelInterface
|
||||
}
|
||||
|
||||
func NewBlackController(db *gorm.DB) *BlackController {
|
||||
return &BlackController{database: NewBlackDatabase(db)}
|
||||
func NewBlackDatabase(black relation.BlackModelInterface) BlackDatabase {
|
||||
return &blackDatabase{black}
|
||||
}
|
||||
|
||||
// Create 增加黑名单
|
||||
func (b *BlackController) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.database.Create(ctx, blacks)
|
||||
func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.black.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
// Delete 删除黑名单
|
||||
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.database.Delete(ctx, blacks)
|
||||
func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.black.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
func (b *BlackController) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.BlackModel, total int64, err error) {
|
||||
return b.database.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
|
||||
func (b *blackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
|
||||
return b.black.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||
func (b *BlackController) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
|
||||
return b.database.CheckIn(ctx, userID1, userID2)
|
||||
}
|
||||
|
||||
type BlackDatabaseInterface interface {
|
||||
// Create 增加黑名单
|
||||
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||
// Delete 删除黑名单
|
||||
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error)
|
||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||
}
|
||||
|
||||
type BlackDatabase struct {
|
||||
sqlDB *relation2.BlackGorm
|
||||
}
|
||||
|
||||
func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
|
||||
sqlDB := relation2.NewBlackGorm(db)
|
||||
database := &BlackDatabase{
|
||||
sqlDB: sqlDB,
|
||||
}
|
||||
return database
|
||||
}
|
||||
|
||||
// Create 增加黑名单
|
||||
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.sqlDB.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
// Delete 删除黑名单
|
||||
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.sqlDB.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
|
||||
return b.sqlDB.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||
func (b *BlackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
|
||||
_, err = b.sqlDB.Take(ctx, userID1, userID2)
|
||||
func (b *blackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
|
||||
_, err = b.black.Take(ctx, userID1, userID2)
|
||||
if err != nil {
|
||||
if errors.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||
return
|
||||
@ -98,9 +55,9 @@ func (b *BlackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (i
|
||||
}
|
||||
|
||||
inUser2Blacks = true
|
||||
_, err = b.sqlDB.Take(ctx, userID2, userID1)
|
||||
_, err = b.black.Take(ctx, userID2, userID1)
|
||||
if err != nil {
|
||||
if errors.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||
if utils.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||
return
|
||||
}
|
||||
inUser2Blacks = false
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type ChatLogInterface interface {
|
||||
CreateChatLog(msg pbMsg.MsgDataToMQ) error
|
||||
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error)
|
||||
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error)
|
||||
}
|
||||
|
||||
func NewChatLogController(db *gorm.DB) ChatLogInterface {
|
||||
@ -24,17 +24,17 @@ func (c *ChatLogController) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
return c.database.CreateChatLog(msg)
|
||||
}
|
||||
|
||||
func (c *ChatLogController) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error) {
|
||||
func (c *ChatLogController) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) {
|
||||
return c.database.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
|
||||
}
|
||||
|
||||
type ChatLogDataBaseInterface interface {
|
||||
CreateChatLog(msg pbMsg.MsgDataToMQ) error
|
||||
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error)
|
||||
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error)
|
||||
}
|
||||
|
||||
type ChatLogDataBase struct {
|
||||
chatLogDB *relationTb.ChatLogModelInterface
|
||||
chatLogDB relationTb.ChatLogModelInterface
|
||||
}
|
||||
|
||||
func NewChatLogDataBase(db *gorm.DB) ChatLogDataBaseInterface {
|
||||
@ -45,6 +45,6 @@ func (c *ChatLogDataBase) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
return c.chatLogDB.Create(msg)
|
||||
}
|
||||
|
||||
func (c *ChatLogDataBase) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error) {
|
||||
func (c *ChatLogDataBase) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) {
|
||||
return c.chatLogDB.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
@ -8,68 +9,8 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ConversationInterface interface {
|
||||
//GetUserIDExistConversation 获取拥有该会话的的用户ID列表
|
||||
GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error)
|
||||
//UpdateUserConversationFiled 更新用户该会话的属性信息
|
||||
UpdateUsersConversationFiled(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}) error
|
||||
//CreateConversation 创建一批新的会话
|
||||
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error
|
||||
//FindConversations 根据会话ID获取某个用户的多个会话
|
||||
FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error)
|
||||
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
||||
SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
||||
}
|
||||
type ConversationController struct {
|
||||
database ConversationDataBaseInterface
|
||||
}
|
||||
|
||||
func (c *ConversationController) SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error {
|
||||
return c.database.SetUsersConversationFiledTx(ctx, userIDList, conversation, filedMap)
|
||||
}
|
||||
|
||||
func NewConversationController(database ConversationDataBaseInterface) *ConversationController {
|
||||
return &ConversationController{database: database}
|
||||
}
|
||||
|
||||
func (c *ConversationController) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) {
|
||||
return c.database.GetUserIDExistConversation(ctx, userIDList, conversationID)
|
||||
}
|
||||
|
||||
func (c ConversationController) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error {
|
||||
return c.database.UpdateUsersConversationFiled(ctx, UserIDList, conversationID, args)
|
||||
}
|
||||
|
||||
func (c ConversationController) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||
return c.database.CreateConversation(ctx, conversations)
|
||||
}
|
||||
|
||||
func (c ConversationController) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error {
|
||||
return c.database.SyncPeerUserPrivateConversationTx(ctx, conversation)
|
||||
}
|
||||
|
||||
func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
|
||||
return c.database.FindConversations(ctx, ownerUserID, conversationIDs)
|
||||
}
|
||||
|
||||
func (c ConversationController) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||
return c.database.GetUserAllConversation(ctx, ownerUserID)
|
||||
}
|
||||
func (c ConversationController) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||
return c.database.SetUserConversations(ctx, ownerUserID, conversations)
|
||||
}
|
||||
|
||||
var _ ConversationInterface = (*ConversationController)(nil)
|
||||
|
||||
type ConversationDataBaseInterface interface {
|
||||
//GetUserIDExistConversation 获取拥有该会话的的用户ID列表
|
||||
GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error)
|
||||
@ -89,22 +30,29 @@ type ConversationDataBaseInterface interface {
|
||||
SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
||||
}
|
||||
|
||||
var _ ConversationDataBaseInterface = (*ConversationDataBase)(nil)
|
||||
func NewConversationDatabase(conversation relation.Conversation, cache cache.ConversationCache, tx tx.Tx) ConversationDataBaseInterface {
|
||||
return &ConversationDataBase{
|
||||
conversationDB: conversation,
|
||||
cache: cache,
|
||||
tx: tx,
|
||||
}
|
||||
}
|
||||
|
||||
type ConversationDataBase struct {
|
||||
conversationDB relation.Conversation
|
||||
cache cache.ConversationCache
|
||||
db *gorm.DB
|
||||
tx tx.Tx
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error {
|
||||
return c.db.Transaction(func(tx *gorm.DB) error {
|
||||
haveUserID, err := c.conversationDB.FindUserID(ctx, userIDList, conversation.ConversationID, tx)
|
||||
func (c *ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error {
|
||||
return c.tx.Transaction(func(tx any) error {
|
||||
conversationTx := c.conversationDB.NewTx(tx)
|
||||
haveUserID, err := conversationTx.FindUserID(ctx, userIDList, conversation.ConversationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(haveUserID) > 0 {
|
||||
err = c.conversationDB.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap, tx)
|
||||
err = conversationTx.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -119,7 +67,7 @@ func (c ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, u
|
||||
temp.OwnerUserID = v
|
||||
cList = append(cList, temp)
|
||||
}
|
||||
err = c.conversationDB.Create(ctx, cList)
|
||||
err = conversationTx.Create(ctx, cList)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -137,37 +85,39 @@ func (c ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, u
|
||||
})
|
||||
}
|
||||
|
||||
func NewConversationDataBase(db relation.Conversation, cache cache.ConversationCache) *ConversationDataBase {
|
||||
return &ConversationDataBase{conversationDB: db, cache: cache}
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) {
|
||||
func (c *ConversationDataBase) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error {
|
||||
func (c *ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||
panic("implement me")
|
||||
func (c *ConversationDataBase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||
return c.tx.Transaction(func(tx any) error {
|
||||
if err := c.conversationDB.NewTx(tx).Create(ctx, conversations); err != nil {
|
||||
return err
|
||||
}
|
||||
// clear cache
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error {
|
||||
return c.db.Transaction(func(tx *gorm.DB) error {
|
||||
func (c *ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error {
|
||||
return c.tx.Transaction(func(tx any) error {
|
||||
userIDList := []string{conversation.OwnerUserID, conversation.UserID}
|
||||
haveUserID, err := c.conversationDB.FindUserID(ctx, userIDList, conversation.ConversationID, tx)
|
||||
conversationTx := c.conversationDB.NewTx(tx)
|
||||
haveUserID, err := conversationTx.FindUserID(ctx, userIDList, conversation.ConversationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filedMap := map[string]interface{}{"is_private_chat": conversation.IsPrivateChat}
|
||||
if len(haveUserID) > 0 {
|
||||
err = c.conversationDB.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap, tx)
|
||||
err = conversationTx.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
NotUserID := utils.DifferenceString(haveUserID, userIDList)
|
||||
var cList []*relationTb.ConversationModel
|
||||
for _, v := range NotUserID {
|
||||
@ -204,7 +154,7 @@ func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Cont
|
||||
})
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
|
||||
func (c *ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
|
||||
getConversation := func() (string, error) {
|
||||
conversationList, err := c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
|
||||
if err != nil {
|
||||
@ -219,7 +169,7 @@ func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID
|
||||
return c.cache.GetConversations(ctx, ownerUserID, conversationIDs, getConversation)
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) {
|
||||
func (c *ConversationDataBase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) {
|
||||
getConversation := func() (string, error) {
|
||||
conversationList, err := c.conversationDB.Take(ctx, ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
@ -234,7 +184,7 @@ func (c ConversationDataBase) GetConversation(ctx context.Context, ownerUserID s
|
||||
return c.cache.GetConversation(ctx, ownerUserID, conversationID, getConversation)
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||
func (c *ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||
getConversationIDList := func() (string, error) {
|
||||
conversationIDList, err := c.conversationDB.FindUserIDAllConversationID(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
@ -252,27 +202,28 @@ func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerU
|
||||
}
|
||||
var conversations []*relationTb.ConversationModel
|
||||
for _, conversationID := range conversationIDList {
|
||||
conversation, tErr := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
if tErr != nil {
|
||||
return nil, utils.Wrap(tErr, "GetConversation failed")
|
||||
conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "GetConversation failed")
|
||||
}
|
||||
conversations = append(conversations, conversation)
|
||||
}
|
||||
return conversations, nil
|
||||
}
|
||||
|
||||
func (c ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||
return c.db.Transaction(func(tx *gorm.DB) error {
|
||||
func (c *ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||
return c.tx.Transaction(func(tx any) error {
|
||||
var conversationIDList []string
|
||||
for _, conversation := range conversations {
|
||||
conversationIDList = append(conversationIDList, conversation.ConversationID)
|
||||
}
|
||||
haveConversations, err := c.conversationDB.Find(ctx, ownerUserID, conversationIDList, tx)
|
||||
conversationTx := c.conversationDB.NewTx(tx)
|
||||
haveConversations, err := conversationTx.Find(ctx, ownerUserID, conversationIDList)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(haveConversations) > 0 {
|
||||
err = c.conversationDB.Update(ctx, conversations, tx)
|
||||
err = conversationTx.Update(ctx, conversations)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,12 +88,12 @@ func (e *ExtendMsgDatabase) InsertExtendMsg(ctx context.Context, sourceID string
|
||||
}
|
||||
|
||||
func (e *ExtendMsgDatabase) InsertOrUpdateReactionExtendMsgSet(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*sdkws.KeyValue) error {
|
||||
return e.InsertOrUpdateReactionExtendMsgSet(ctx, sourceID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
|
||||
return e.model.InsertOrUpdateReactionExtendMsgSet(ctx, sourceID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
|
||||
}
|
||||
func (e *ExtendMsgDatabase) DeleteReactionExtendMsgSet(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*sdkws.KeyValue) error {
|
||||
return e.DeleteReactionExtendMsgSet(ctx, sourceID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
|
||||
return e.model.DeleteReactionExtendMsgSet(ctx, sourceID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
|
||||
}
|
||||
|
||||
func (e *ExtendMsgDatabase) GetExtendMsg(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
|
||||
return e.GetExtendMsg(ctx, sourceID, sessionType, clientMsgID, maxMsgUpdateTime)
|
||||
return e.model.TakeExtendMsg(ctx, sourceID, sessionType, clientMsgID, maxMsgUpdateTime)
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
relation1 "Open_IM/pkg/common/db/relation"
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@ -10,102 +10,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FriendInterface interface {
|
||||
// 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
|
||||
CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error)
|
||||
// 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增
|
||||
AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error)
|
||||
// (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可
|
||||
BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error)
|
||||
// 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝
|
||||
RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
|
||||
// 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 不是好友则建立双向好友关系 (4)修改申请记录 已同意
|
||||
AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
|
||||
// 删除好友 外部判断是否好友关系
|
||||
Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error)
|
||||
// 更新好友备注 零值也支持
|
||||
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
|
||||
// 获取ownerUserID的好友列表 无结果不返回错误
|
||||
PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
// friendUserID在哪些人的好友列表中
|
||||
PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
// 获取我发出去的好友申请 无结果不返回错误
|
||||
PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
// 获取我收到的的好友申请 无结果不返回错误
|
||||
PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
// 获取某人指定好友的信息 如果有一个不存在也返回错误
|
||||
FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
|
||||
}
|
||||
|
||||
type FriendController struct {
|
||||
database FriendDatabaseInterface
|
||||
}
|
||||
|
||||
func NewFriendController(db *gorm.DB) *FriendController {
|
||||
return &FriendController{database: NewFriendDatabase(db)}
|
||||
}
|
||||
|
||||
// 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
|
||||
func (f *FriendController) CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error) {
|
||||
return f.database.CheckIn(ctx, user1, user2)
|
||||
}
|
||||
|
||||
// AddFriendRequest 增加或者更新好友申请
|
||||
func (f *FriendController) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
|
||||
return f.database.AddFriendRequest(ctx, fromUserID, toUserID, reqMsg, ex)
|
||||
}
|
||||
|
||||
// BecomeFriend 先判断是否在好友表,如果在则不插入
|
||||
func (f *FriendController) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) {
|
||||
return f.database.BecomeFriends(ctx, ownerUserID, friendUserIDs, addSource, OperatorUserID)
|
||||
}
|
||||
|
||||
// RefuseFriendRequest 拒绝好友申请
|
||||
func (f *FriendController) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
return f.database.RefuseFriendRequest(ctx, friendRequest)
|
||||
}
|
||||
|
||||
// AgreeFriendRequest 同意好友申请
|
||||
func (f *FriendController) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
return f.database.AgreeFriendRequest(ctx, friendRequest)
|
||||
}
|
||||
|
||||
// Delete 删除好友
|
||||
func (f *FriendController) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
|
||||
return f.database.Delete(ctx, ownerUserID, friendUserIDs)
|
||||
}
|
||||
|
||||
// UpdateRemark 更新好友备注
|
||||
func (f *FriendController) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
|
||||
return f.database.UpdateRemark(ctx, ownerUserID, friendUserID, remark)
|
||||
}
|
||||
|
||||
// FindOwnerFriends 获取ownerUserID的好友列表
|
||||
func (f *FriendController) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.PageOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindInWhoseFriends friendUserID在哪些人的好友列表中
|
||||
func (f *FriendController) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.PageInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriendRequestFromMe 获取我发出去的好友申请
|
||||
func (f *FriendController) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.PageFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriendRequestToMe 获取我收到的的好友申请
|
||||
func (f *FriendController) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.PageFriendRequestToMe(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriends 获取某人指定好友的信息
|
||||
func (f *FriendController) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
return f.database.FindFriendsWithError(ctx, ownerUserID, friendUserIDs)
|
||||
}
|
||||
|
||||
type FriendDatabaseInterface interface {
|
||||
type FriendDatabase interface {
|
||||
// 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
|
||||
CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error)
|
||||
// 增加或者更新好友申请
|
||||
@ -132,17 +37,18 @@ type FriendDatabaseInterface interface {
|
||||
FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
|
||||
}
|
||||
|
||||
type FriendDatabase struct {
|
||||
friend *relation1.FriendGorm
|
||||
friendRequest *relation1.FriendRequestGorm
|
||||
type friendDatabase struct {
|
||||
friend relation.FriendModelInterface
|
||||
friendRequest relation.FriendRequestModelInterface
|
||||
tx tx.Tx
|
||||
}
|
||||
|
||||
func NewFriendDatabase(db *gorm.DB) *FriendDatabase {
|
||||
return &FriendDatabase{friend: relation1.NewFriendGorm(db), friendRequest: relation1.NewFriendRequestGorm(db)}
|
||||
func NewFriendDatabase(friend relation.FriendModelInterface, friendRequest relation.FriendRequestModelInterface, tx tx.Tx) FriendDatabase {
|
||||
return &friendDatabase{friend: friend, friendRequest: friendRequest, tx: tx}
|
||||
}
|
||||
|
||||
// ok 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
|
||||
func (f *FriendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Friends bool, inUser2Friends bool, err error) {
|
||||
func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Friends bool, inUser2Friends bool, err error) {
|
||||
friends, err := f.friend.FindUserState(ctx, userID1, userID2)
|
||||
if err != nil {
|
||||
return false, false, err
|
||||
@ -159,9 +65,9 @@ func (f *FriendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (
|
||||
}
|
||||
|
||||
// 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增
|
||||
func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
|
||||
return f.friendRequest.DB.Transaction(func(tx *gorm.DB) error {
|
||||
_, err := f.friendRequest.Take(ctx, fromUserID, toUserID, tx)
|
||||
func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
|
||||
return f.tx.Transaction(func(tx any) error {
|
||||
_, err := f.friendRequest.NewTx(tx).Take(ctx, fromUserID, toUserID)
|
||||
//有db错误
|
||||
if err != nil && errors.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||
return err
|
||||
@ -173,13 +79,13 @@ func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUse
|
||||
m["handle_msg"] = ""
|
||||
m["req_msg"] = reqMsg
|
||||
m["ex"] = ex
|
||||
if err := f.friendRequest.UpdateByMap(ctx, fromUserID, toUserID, m, tx); err != nil {
|
||||
if err := f.friendRequest.NewTx(tx).UpdateByMap(ctx, fromUserID, toUserID, m); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
//gorm.ErrRecordNotFound 错误,则新增
|
||||
if err := f.friendRequest.Create(ctx, []*relation.FriendRequestModel{&relation.FriendRequestModel{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex}}, tx); err != nil {
|
||||
if err := f.friendRequest.NewTx(tx).Create(ctx, []*relation.FriendRequestModel{&relation.FriendRequestModel{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex}}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -187,10 +93,10 @@ func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUse
|
||||
}
|
||||
|
||||
// (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可
|
||||
func (f *FriendDatabase) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) {
|
||||
return f.friend.DB.Transaction(func(tx *gorm.DB) error {
|
||||
func (f *friendDatabase) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) {
|
||||
return f.tx.Transaction(func(tx any) error {
|
||||
//先find 找出重复的 去掉重复的
|
||||
fs1, err := f.friend.FindFriends(ctx, ownerUserID, friendUserIDs, tx)
|
||||
fs1, err := f.friend.NewTx(tx).FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -201,12 +107,12 @@ func (f *FriendDatabase) BecomeFriends(ctx context.Context, ownerUserID string,
|
||||
return e.FriendUserID
|
||||
})
|
||||
|
||||
err = f.friend.Create(ctx, fs11, tx)
|
||||
err = f.friend.NewTx(tx).Create(ctx, fs11)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fs2, err := f.friend.FindReversalFriends(ctx, ownerUserID, friendUserIDs, tx)
|
||||
fs2, err := f.friend.NewTx(tx).FindReversalFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -216,7 +122,7 @@ func (f *FriendDatabase) BecomeFriends(ctx context.Context, ownerUserID string,
|
||||
fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string {
|
||||
return e.OwnerUserID
|
||||
})
|
||||
err = f.friend.Create(ctx, fs22, tx)
|
||||
err = f.friend.NewTx(tx).Create(ctx, fs22)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -225,7 +131,7 @@ func (f *FriendDatabase) BecomeFriends(ctx context.Context, ownerUserID string,
|
||||
}
|
||||
|
||||
// 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝
|
||||
func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
_, err = f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -239,15 +145,15 @@ func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest
|
||||
}
|
||||
|
||||
// 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 不是好友则建立双向好友关系 (4)修改申请记录 已同意
|
||||
func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
return f.friend.DB.Transaction(func(tx *gorm.DB) error {
|
||||
_, err = f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
||||
func (f *friendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
|
||||
return f.tx.Transaction(func(tx any) error {
|
||||
_, err = f.friendRequest.NewTx(tx).Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
friendRequest.HandlerUserID = friendRequest.FromUserID
|
||||
friendRequest.HandleResult = constant.FriendResponseAgree
|
||||
err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest}, tx)
|
||||
err = f.friendRequest.NewTx(tx).Update(ctx, []*relation.FriendRequestModel{friendRequest})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -257,7 +163,7 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
|
||||
addSource := int32(constant.BecomeFriendByApply)
|
||||
OperatorUserID := friendRequest.FromUserID
|
||||
//先find 找出重复的 去掉重复的
|
||||
fs1, err := f.friend.FindFriends(ctx, ownerUserID, friendUserIDs, tx)
|
||||
fs1, err := f.friend.NewTx(tx).FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -268,12 +174,12 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
|
||||
return e.FriendUserID
|
||||
})
|
||||
|
||||
err = f.friend.Create(ctx, fs11, tx)
|
||||
err = f.friend.NewTx(tx).Create(ctx, fs11)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fs2, err := f.friend.FindReversalFriends(ctx, ownerUserID, friendUserIDs, tx)
|
||||
fs2, err := f.friend.NewTx(tx).FindReversalFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -283,7 +189,7 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
|
||||
fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string {
|
||||
return e.OwnerUserID
|
||||
})
|
||||
err = f.friend.Create(ctx, fs22, tx)
|
||||
err = f.friend.NewTx(tx).Create(ctx, fs22)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -292,37 +198,37 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
|
||||
}
|
||||
|
||||
// 删除好友 外部判断是否好友关系
|
||||
func (f *FriendDatabase) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
|
||||
func (f *friendDatabase) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
|
||||
return f.friend.Delete(ctx, ownerUserID, friendUserIDs)
|
||||
}
|
||||
|
||||
// 更新好友备注 零值也支持
|
||||
func (f *FriendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
|
||||
func (f *friendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
|
||||
return f.friend.UpdateRemark(ctx, ownerUserID, friendUserID, remark)
|
||||
}
|
||||
|
||||
// 获取ownerUserID的好友列表 无结果不返回错误
|
||||
func (f *FriendDatabase) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *friendDatabase) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// friendUserID在哪些人的好友列表中
|
||||
func (f *FriendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *friendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取我发出去的好友申请 无结果不返回错误
|
||||
func (f *FriendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
func (f *friendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取我收到的的好友申请 无结果不返回错误
|
||||
func (f *FriendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取某人指定好友的信息 如果有好友不存在,也返回错误
|
||||
func (f *FriendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -1,25 +1,21 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"Open_IM/internal/tx"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||
unRelationTb "Open_IM/pkg/common/db/table/unrelation"
|
||||
"Open_IM/pkg/common/db/unrelation"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/dtm-labs/rockscache"
|
||||
_ "github.com/dtm-labs/rockscache"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
//type GroupInterface GroupDataBaseInterface
|
||||
|
||||
type GroupInterface interface {
|
||||
type GroupDatabase interface {
|
||||
// Group
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
@ -45,217 +41,7 @@ type GroupInterface interface {
|
||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
// SuperGroup
|
||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error)
|
||||
FindJoinSuperGroup(ctx context.Context, userID string) (superGroup *unRelationTb.UserToSuperGroupModel, err error)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
}
|
||||
|
||||
var _ GroupInterface = (*GroupController)(nil)
|
||||
|
||||
func NewGroupInterface(database GroupDataBaseInterface) GroupInterface {
|
||||
return &GroupController{database: database}
|
||||
}
|
||||
|
||||
type GroupController struct {
|
||||
database GroupDataBaseInterface
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error) {
|
||||
return g.database.FindGroupMemberUserID(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error {
|
||||
return g.database.CreateGroup(ctx, groups, groupMembers)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
return g.database.TakeGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||
return g.database.FindGroup(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error) {
|
||||
return g.database.SearchGroup(ctx, keyword, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupController) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
|
||||
return g.database.UpdateGroup(ctx, groupID, data)
|
||||
}
|
||||
|
||||
func (g *GroupController) DismissGroup(ctx context.Context, groupID string) error {
|
||||
return g.database.DismissGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
||||
return g.database.GetGroupIDsByGroupType(ctx, groupType)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||
return g.database.TakeGroupMember(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) {
|
||||
return g.database.TakeGroupOwner(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) {
|
||||
return g.database.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
||||
}
|
||||
|
||||
func (g *GroupController) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
return g.database.PageGroupMember(ctx, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupController) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
return g.database.SearchGroupMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupController) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error {
|
||||
return g.database.HandlerGroupRequest(ctx, groupID, userID, handledMsg, handleResult, member)
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.database.DeleteGroupMember(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||
return g.database.MapGroupMemberUserID(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
|
||||
return g.database.MapGroupMemberNum(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error {
|
||||
return g.database.TransferGroupOwner(ctx, groupID, oldOwnerUserID, newOwnerUserID, roleLevel)
|
||||
}
|
||||
|
||||
func (g *GroupController) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error {
|
||||
return g.database.UpdateGroupMembers(ctx, data)
|
||||
}
|
||||
|
||||
func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
|
||||
return g.database.UpdateGroupMember(ctx, groupID, userID, data)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
||||
return g.database.CreateGroupRequest(ctx, requests)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) {
|
||||
return g.database.TakeGroupRequest(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||
return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error) {
|
||||
return g.database.FindSuperGroup(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string) (*unRelationTb.UserToSuperGroupModel, error) {
|
||||
return g.database.FindJoinSuperGroup(ctx, userID)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList)
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
return g.database.DeleteSuperGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.database.DeleteSuperGroupMember(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.database.CreateSuperGroupMember(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
type Group interface {
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error)
|
||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
||||
}
|
||||
|
||||
type GroupMember interface {
|
||||
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error
|
||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
|
||||
}
|
||||
|
||||
type GroupRequest interface {
|
||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
}
|
||||
|
||||
type SuperGroup interface {
|
||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error)
|
||||
FindJoinSuperGroup(ctx context.Context, userID string) (*unrelationTb.UserToSuperGroupModel, error)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
}
|
||||
|
||||
type GroupDataBase1 interface {
|
||||
Group
|
||||
GroupMember
|
||||
GroupRequest
|
||||
SuperGroup
|
||||
}
|
||||
|
||||
type GroupDataBaseInterface interface {
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error)
|
||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
||||
|
||||
// GroupMember
|
||||
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error
|
||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
|
||||
// GroupRequest
|
||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
// SuperGroup
|
||||
// SuperGroupModelInterface
|
||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error)
|
||||
FindJoinSuperGroup(ctx context.Context, userID string) (*unRelationTb.UserToSuperGroupModel, error)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
@ -264,42 +50,47 @@ type GroupDataBaseInterface interface {
|
||||
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
}
|
||||
|
||||
func NewGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface {
|
||||
groupDB := relation.NewGroupDB(db)
|
||||
groupMemberDB := relation.NewGroupMemberDB(db)
|
||||
groupRequestDB := relation.NewGroupRequest(db)
|
||||
newDB := *db
|
||||
SuperGroupMongoDriver := unrelation.NewSuperGroupMongoDriver(mgoClient)
|
||||
database := &GroupDataBase{
|
||||
groupDB: groupDB,
|
||||
groupMemberDB: groupMemberDB,
|
||||
groupRequestDB: groupRequestDB,
|
||||
db: &newDB,
|
||||
cache: cache.NewGroupCacheRedis(rdb, groupDB, groupMemberDB, groupRequestDB, SuperGroupMongoDriver, rockscache.Options{
|
||||
func NewGroupDatabase(
|
||||
group relationTb.GroupModelInterface,
|
||||
member relationTb.GroupMemberModelInterface,
|
||||
request relationTb.GroupRequestModelInterface,
|
||||
tx tx.Tx,
|
||||
ctxTx tx.CtxTx,
|
||||
super unRelationTb.SuperGroupModelInterface,
|
||||
client redis.UniversalClient,
|
||||
) GroupDatabase {
|
||||
database := &groupDatabase{
|
||||
groupDB: group,
|
||||
groupMemberDB: member,
|
||||
groupRequestDB: request,
|
||||
tx: tx,
|
||||
ctxTx: ctxTx,
|
||||
cache: cache.NewGroupCacheRedis(client, group, member, request, super, rockscache.Options{
|
||||
RandomExpireAdjustment: 0.2,
|
||||
DisableCacheRead: false,
|
||||
DisableCacheDelete: false,
|
||||
StrongConsistency: true,
|
||||
}),
|
||||
mongoDB: SuperGroupMongoDriver,
|
||||
mongoDB: super,
|
||||
}
|
||||
return database
|
||||
}
|
||||
|
||||
var _ GroupDataBaseInterface = (*GroupDataBase)(nil)
|
||||
|
||||
type GroupDataBase struct {
|
||||
type groupDatabase struct {
|
||||
groupDB relationTb.GroupModelInterface
|
||||
groupMemberDB relationTb.GroupMemberModelInterface
|
||||
groupRequestDB relationTb.GroupRequestModelInterface
|
||||
db *gorm.DB
|
||||
|
||||
//cache cache.GroupCache
|
||||
cache *cache.GroupCacheRedis
|
||||
mongoDB *unrelation.SuperGroupMongoDriver
|
||||
tx tx.Tx
|
||||
ctxTx tx.CtxTx
|
||||
cache cache.GroupCacheRedisInterface
|
||||
mongoDB unRelationTb.SuperGroupModelInterface
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) delGroupMemberCache(ctx context.Context, groupID string, userIDs []string) error {
|
||||
func (g *groupDatabase) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
||||
return g.groupDB.GetGroupIDsByGroupType(ctx, groupType)
|
||||
}
|
||||
|
||||
func (g *groupDatabase) delGroupMemberCache(ctx context.Context, groupID string, userIDs []string) error {
|
||||
for _, userID := range userIDs {
|
||||
if err := g.cache.DelJoinedGroupID(ctx, userID); err != nil {
|
||||
return err
|
||||
@ -320,49 +111,41 @@ func (g *GroupDataBase) delGroupMemberCache(ctx context.Context, groupID string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error) {
|
||||
func (g *groupDatabase) FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error) {
|
||||
return g.cache.GetGroupMemberIDs(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
func (g *groupDatabase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if len(groups) > 0 {
|
||||
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
|
||||
if err := g.groupDB.NewTx(tx).Create(ctx, groups); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(groupMembers) > 0 {
|
||||
if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil {
|
||||
if err := g.groupMemberDB.NewTx(tx).Create(ctx, groupMembers); err != nil {
|
||||
return err
|
||||
}
|
||||
//if err := g.cache.DelJoinedGroupIDs(ctx, utils.Slice(groupMembers, func(e *relationTb.GroupMemberModel) string {
|
||||
// return e.UserID
|
||||
//})); err != nil {
|
||||
// return err
|
||||
//}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
//return g.cache.GetGroupInfo(ctx, groupID)
|
||||
return cache.GetCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||
return g.group.Take(ctx, groupID)
|
||||
})
|
||||
func (g *groupDatabase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
return g.cache.GetGroupInfo(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||
func (g *groupDatabase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error) {
|
||||
func (g *groupDatabase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error) {
|
||||
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupDB.UpdateMap(ctx, groupID, data, tx); err != nil {
|
||||
func (g *groupDatabase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if err := g.groupDB.NewTx(tx).UpdateMap(ctx, groupID, data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.cache.DelGroupInfo(ctx, groupID); err != nil {
|
||||
@ -372,12 +155,12 @@ func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data ma
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupDB.UpdateStatus(ctx, groupID, constant.GroupStatusDismissed, tx); err != nil {
|
||||
func (g *groupDatabase) DismissGroup(ctx context.Context, groupID string) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if err := g.groupDB.NewTx(tx).UpdateStatus(ctx, groupID, constant.GroupStatusDismissed); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.groupMemberDB.DeleteGroup(ctx, []string{groupID}, tx); err != nil {
|
||||
if err := g.groupMemberDB.NewTx(tx).DeleteGroup(ctx, []string{groupID}); err != nil {
|
||||
return err
|
||||
}
|
||||
userIDs, err := g.cache.GetGroupMemberIDs(ctx, groupID)
|
||||
@ -391,33 +174,33 @@ func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||
func (g *groupDatabase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||
return g.cache.GetGroupMemberInfo(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) {
|
||||
func (g *groupDatabase) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.TakeOwner(ctx, groupID) // todo cache group owner
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) {
|
||||
func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels) // todo cache group find
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
func (g *groupDatabase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.SearchMember(ctx, "", groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
func (g *groupDatabase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupRequestDB.UpdateHandler(ctx, groupID, userID, handledMsg, handleResult, tx); err != nil {
|
||||
func (g *groupDatabase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if err := g.groupRequestDB.NewTx(tx).UpdateHandler(ctx, groupID, userID, handledMsg, handleResult); err != nil {
|
||||
return err
|
||||
}
|
||||
if member != nil {
|
||||
if err := g.groupMemberDB.Create(ctx, []*relationTb.GroupMemberModel{member}, tx); err != nil {
|
||||
if err := g.groupMemberDB.NewTx(tx).Create(ctx, []*relationTb.GroupMemberModel{member}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.delGroupMemberCache(ctx, groupID, []string{userID}); err != nil {
|
||||
@ -428,9 +211,9 @@ func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string,
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupMemberDB.Delete(ctx, groupID, userIDs, tx); err != nil {
|
||||
func (g *groupDatabase) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if err := g.groupMemberDB.NewTx(tx).Delete(ctx, groupID, userIDs); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.delGroupMemberCache(ctx, groupID, userIDs); err != nil {
|
||||
@ -440,24 +223,24 @@ func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, u
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||
func (g *groupDatabase) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||
return g.cache.GetGroupMemberHash1(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
|
||||
func (g *groupDatabase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
|
||||
return g.groupMemberDB.MapGroupMemberNum(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
rowsAffected, err := g.groupMemberDB.UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel, tx)
|
||||
func (g *groupDatabase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
rowsAffected, err := g.groupMemberDB.NewTx(tx).UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if rowsAffected != 1 {
|
||||
return utils.Wrap(fmt.Errorf("oldOwnerUserID %s rowsAffected = %d", oldOwnerUserID, rowsAffected), "")
|
||||
}
|
||||
rowsAffected, err = g.groupMemberDB.UpdateRoleLevel(ctx, groupID, newOwnerUserID, constant.GroupOwner, tx)
|
||||
rowsAffected, err = g.groupMemberDB.NewTx(tx).UpdateRoleLevel(ctx, groupID, newOwnerUserID, constant.GroupOwner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -471,9 +254,9 @@ func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string,
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupMemberDB.Update(ctx, groupID, userID, data, tx); err != nil {
|
||||
func (g *groupDatabase) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
if err := g.groupMemberDB.NewTx(tx).Update(ctx, groupID, userID, data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.cache.DelGroupMemberInfo(ctx, groupID, userID); err != nil {
|
||||
@ -483,10 +266,10 @@ func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID string, u
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error {
|
||||
return g.tx.Transaction(func(tx any) error {
|
||||
for _, item := range data {
|
||||
if err := g.groupMemberDB.Update(ctx, item.GroupID, item.UserID, item.Map, tx); err != nil {
|
||||
if err := g.groupMemberDB.NewTx(tx).Update(ctx, item.GroupID, item.UserID, item.Map); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.cache.DelGroupMemberInfo(ctx, item.GroupID, item.UserID); err != nil {
|
||||
@ -497,46 +280,46 @@ func (g *GroupDataBase) UpdateGroupMembers(ctx context.Context, data []*relation
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
||||
func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
||||
return g.groupRequestDB.Create(ctx, requests)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) {
|
||||
func (g *groupDatabase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) {
|
||||
return g.groupRequestDB.Take(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||
func (g *groupDatabase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*table.SuperGroupModel, error) {
|
||||
func (g *groupDatabase) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error) {
|
||||
return g.mongoDB.FindSuperGroup(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string) (*table.UserToSuperGroupModel, error) {
|
||||
func (g *groupDatabase) FindJoinSuperGroup(ctx context.Context, userID string) (*unRelationTb.UserToSuperGroupModel, error) {
|
||||
return g.mongoDB.GetSuperGroupByUserID(ctx, userID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
return unrelation.MongoTransaction(ctx, g.mongoDB.MgoClient, func(tx mongo.SessionContext) error {
|
||||
return g.mongoDB.CreateSuperGroup(ctx, groupID, initMemberIDList, tx)
|
||||
func (g *groupDatabase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
return g.ctxTx.Transaction(ctx, func(ctx context.Context) error {
|
||||
return g.mongoDB.CreateSuperGroup(ctx, groupID, initMemberIDList)
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
return unrelation.MongoTransaction(ctx, g.mongoDB.MgoClient, func(tx mongo.SessionContext) error {
|
||||
return g.mongoDB.DeleteSuperGroup(ctx, groupID, tx)
|
||||
func (g *groupDatabase) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
return g.ctxTx.Transaction(ctx, func(ctx context.Context) error {
|
||||
return g.mongoDB.DeleteSuperGroup(ctx, groupID)
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return unrelation.MongoTransaction(ctx, g.mongoDB.MgoClient, func(tx mongo.SessionContext) error {
|
||||
return g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs, tx)
|
||||
func (g *groupDatabase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.ctxTx.Transaction(ctx, func(ctx context.Context) error {
|
||||
return g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs)
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return unrelation.MongoTransaction(ctx, g.mongoDB.MgoClient, func(tx mongo.SessionContext) error {
|
||||
return g.mongoDB.AddUserToSuperGroup(ctx, groupID, userIDs, tx)
|
||||
func (g *groupDatabase) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.ctxTx.Transaction(ctx, func(ctx context.Context) error {
|
||||
return g.mongoDB.AddUserToSuperGroup(ctx, groupID, userIDs)
|
||||
})
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ type MsgInterface interface {
|
||||
DelMsgBySeqs(ctx context.Context, userID string, seqs []int64) (totalUnExistSeqs []int64, err error)
|
||||
// 通过seqList获取db中写扩散消息
|
||||
GetMsgBySeqs(ctx context.Context, userID string, seqs []int64) (seqMsg []*sdkws.MsgData, err error)
|
||||
// 通过seqList获取大群在db里面的消息
|
||||
// 通过seqList获取大群在db里面的消息 没找到返回错误
|
||||
GetSuperGroupMsgBySeqs(ctx context.Context, groupID string, seqs []int64) (seqMsg []*sdkws.MsgData, err error)
|
||||
// 删除用户所有消息/cache/db然后重置seq
|
||||
CleanUpUserMsg(ctx context.Context, userID string) error
|
||||
@ -49,6 +49,8 @@ type MsgInterface interface {
|
||||
SetGroupUserMinSeq(ctx context.Context, groupID, userID string, minSeq int64) (err error)
|
||||
// 设置用户最小seq 直接调用cache
|
||||
SetUserMinSeq(ctx context.Context, userID string, minSeq int64) (err error)
|
||||
|
||||
MsgToMQ(ctx context.Context, key string, data *pbMsg.MsgDataToMQ) (err error)
|
||||
}
|
||||
|
||||
func NewMsgController(mgo *mongo.Client, rdb redis.UniversalClient) MsgInterface {
|
||||
@ -337,7 +339,7 @@ func (db *MsgDatabase) GetMsgAndIndexBySeqsInOneDoc(ctx context.Context, docID s
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
if utils.Contain(msgPb.Seq, seqs) {
|
||||
if utils.Contain(msgPb.Seq, seqs...) {
|
||||
indexes = append(indexes, i)
|
||||
seqMsgs = append(seqMsgs, msgPb)
|
||||
hasSeqList = append(hasSeqList, msgPb.Seq)
|
||||
@ -348,7 +350,7 @@ func (db *MsgDatabase) GetMsgAndIndexBySeqsInOneDoc(ctx context.Context, docID s
|
||||
}
|
||||
}
|
||||
for _, i := range seqs {
|
||||
if utils.Contain(i, hasSeqList) {
|
||||
if utils.Contain(i, hasSeqList...) {
|
||||
continue
|
||||
}
|
||||
unExistSeqs = append(unExistSeqs, i)
|
||||
@ -398,7 +400,7 @@ func (db *MsgDatabase) getMsgBySeqs(ctx context.Context, sourceID string, seqs [
|
||||
//log.NewError(operationID, "Unmarshal err", seqUid, value, uid, seqList, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
if utils.Contain(msgPb.Seq, value) {
|
||||
if utils.Contain(msgPb.Seq, value...) {
|
||||
seqMsg = append(seqMsg, msgPb)
|
||||
hasSeqs = append(hasSeqs, msgPb.Seq)
|
||||
singleCount++
|
||||
|
@ -2,105 +2,60 @@ package controller
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserInterface interface {
|
||||
type UserDatabase interface {
|
||||
//获取指定用户的信息 如有userID未找到 也返回错误
|
||||
FindWithError(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
FindWithError(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error)
|
||||
//获取指定用户的信息 如有userID未找到 不返回错误
|
||||
Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error)
|
||||
//插入多条 外部保证userID 不重复 且在db中不存在
|
||||
Create(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
Create(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
//更新(非零值) 外部保证userID存在
|
||||
Update(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
Update(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
//更新(零值) 外部保证userID存在
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
//如果没找到,不返回错误
|
||||
Page(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error)
|
||||
Page(ctx context.Context, pageNumber, showNumber int32) (users []*relation.UserModel, count int64, err error)
|
||||
//只要有一个存在就为true
|
||||
IsExist(ctx context.Context, userIDs []string) (exist bool, err error)
|
||||
//获取所有用户ID
|
||||
GetAllUserID(ctx context.Context) ([]string, error)
|
||||
//函数内部先查询db中是否存在,存在则什么都不做;不存在则插入
|
||||
InitOnce(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
}
|
||||
|
||||
type UserController struct {
|
||||
database UserDatabaseInterface
|
||||
type userDatabase struct {
|
||||
userDB relation.UserModelInterface
|
||||
}
|
||||
|
||||
// 获取指定用户的信息 如有userID未找到 也返回错误
|
||||
func (u *UserController) FindWithError(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
return u.database.FindWithError(ctx, userIDs)
|
||||
func NewUserDatabase(userDB relation.UserModelInterface) UserDatabase {
|
||||
return &userDatabase{userDB: userDB}
|
||||
}
|
||||
|
||||
func (u *UserController) Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
return u.database.Find(ctx, userIDs)
|
||||
}
|
||||
func (u *UserController) Create(ctx context.Context, users []*relationTb.UserModel) error {
|
||||
return u.database.Create(ctx, users)
|
||||
}
|
||||
|
||||
func (u *UserController) Update(ctx context.Context, users []*relationTb.UserModel) (err error) {
|
||||
return u.database.Update(ctx, users)
|
||||
}
|
||||
func (u *UserController) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
|
||||
return u.database.UpdateByMap(ctx, userID, args)
|
||||
}
|
||||
|
||||
func (u *UserController) Page(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error) {
|
||||
return u.database.Page(ctx, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (u *UserController) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) {
|
||||
return u.database.IsExist(ctx, userIDs)
|
||||
}
|
||||
|
||||
func (u *UserController) GetAllUserID(ctx context.Context) ([]string, error) {
|
||||
return u.database.GetAllUserID(ctx)
|
||||
}
|
||||
|
||||
func NewUserController(db *gorm.DB) *UserController {
|
||||
controller := &UserController{database: newUserDatabase(db)}
|
||||
return controller
|
||||
}
|
||||
|
||||
type UserDatabaseInterface interface {
|
||||
//获取指定用户的信息 如有userID未找到 也返回错误
|
||||
FindWithError(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
//获取指定用户的信息 如有userID未找到 不返回错误
|
||||
Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
//插入多条 外部保证userID 不重复 且在db中不存在
|
||||
Create(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
//更新(非零值) 外部保证userID存在
|
||||
Update(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
//更新(零值) 外部保证userID存在
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
//如果没找到,不返回错误
|
||||
Page(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error)
|
||||
//只要有一个存在就为true
|
||||
IsExist(ctx context.Context, userIDs []string) (exist bool, err error)
|
||||
//获取所有用户ID
|
||||
GetAllUserID(ctx context.Context) ([]string, error)
|
||||
}
|
||||
|
||||
type UserDatabase struct {
|
||||
user *relation.UserGorm
|
||||
}
|
||||
|
||||
func newUserDatabase(db *gorm.DB) *UserDatabase {
|
||||
sqlDB := relation.NewUserGorm(db)
|
||||
database := &UserDatabase{
|
||||
user: sqlDB,
|
||||
func (u *userDatabase) InitOnce(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
userIDs := utils.Slice(users, func(e *relation.UserModel) string {
|
||||
return e.UserID
|
||||
})
|
||||
result, err := u.userDB.Find(ctx, userIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return database
|
||||
miss := utils.SliceAnySub(users, result, func(e *relation.UserModel) string { return e.UserID })
|
||||
if len(miss) > 0 {
|
||||
u.userDB.Create(ctx, miss)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取指定用户的信息 如有userID未找到 也返回错误
|
||||
func (u *UserDatabase) FindWithError(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
users, err = u.user.Find(ctx, userIDs)
|
||||
func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
|
||||
|
||||
users, err = u.userDB.Find(ctx, userIDs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -111,34 +66,34 @@ func (u *UserDatabase) FindWithError(ctx context.Context, userIDs []string) (use
|
||||
}
|
||||
|
||||
// 获取指定用户的信息 如有userID未找到 不返回错误
|
||||
func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
users, err = u.user.Find(ctx, userIDs)
|
||||
func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
|
||||
users, err = u.userDB.Find(ctx, userIDs)
|
||||
return
|
||||
}
|
||||
|
||||
// 插入多条 外部保证userID 不重复 且在db中不存在
|
||||
func (u *UserDatabase) Create(ctx context.Context, users []*relationTb.UserModel) (err error) {
|
||||
return u.user.Create(ctx, users)
|
||||
func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
return u.userDB.Create(ctx, users)
|
||||
}
|
||||
|
||||
// 更新(非零值) 外部保证userID存在
|
||||
func (u *UserDatabase) Update(ctx context.Context, users []*relationTb.UserModel) (err error) {
|
||||
return u.user.Update(ctx, users)
|
||||
func (u *userDatabase) Update(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
return u.userDB.Update(ctx, users)
|
||||
}
|
||||
|
||||
// 更新(零值) 外部保证userID存在
|
||||
func (u *UserDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
|
||||
return u.user.UpdateByMap(ctx, userID, args)
|
||||
func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
|
||||
return u.userDB.UpdateByMap(ctx, userID, args)
|
||||
}
|
||||
|
||||
// 获取,如果没找到,不返回错误
|
||||
func (u *UserDatabase) Page(ctx context.Context, showNumber, pageNumber int32) (users []*relationTb.UserModel, count int64, err error) {
|
||||
return u.user.Page(ctx, showNumber, pageNumber)
|
||||
func (u *userDatabase) Page(ctx context.Context, pageNumber, showNumber int32) (users []*relation.UserModel, count int64, err error) {
|
||||
return u.userDB.Page(ctx, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// userIDs是否存在 只要有一个存在就为true
|
||||
func (u *UserDatabase) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) {
|
||||
users, err := u.user.Find(ctx, userIDs)
|
||||
func (u *userDatabase) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) {
|
||||
users, err := u.userDB.Find(ctx, userIDs)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -148,6 +103,21 @@ func (u *UserDatabase) IsExist(ctx context.Context, userIDs []string) (exist boo
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (u *UserDatabase) GetAllUserID(ctx context.Context) ([]string, error) {
|
||||
return u.user.GetAllUserID(ctx)
|
||||
func (u *userDatabase) GetAllUserID(ctx context.Context) (userIDs []string, err error) {
|
||||
pageNumber := int32(0)
|
||||
for {
|
||||
tmp, total, err := u.userDB.PageUserID(ctx, pageNumber, constant.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(tmp) == 0 {
|
||||
if total == int64(len(userIDs)) {
|
||||
return userIDs, nil
|
||||
}
|
||||
return nil, constant.ErrData.Wrap("The total number of results and expectations are different, but result is nil")
|
||||
}
|
||||
userIDs = append(userIDs, tmp...)
|
||||
pageNumber++
|
||||
}
|
||||
return userIDs, nil
|
||||
}
|
||||
|
@ -12,10 +12,8 @@ type BlackGorm struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewBlackGorm(db *gorm.DB) *BlackGorm {
|
||||
var black BlackGorm
|
||||
black.DB = db
|
||||
return &black
|
||||
func NewBlackGorm(db *gorm.DB) relation.BlackModelInterface {
|
||||
return &BlackGorm{db}
|
||||
}
|
||||
|
||||
func (b *BlackGorm) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
@ -76,3 +74,10 @@ func (b *BlackGorm) FindOwnerBlacks(ctx context.Context, ownerUserID string, pag
|
||||
err = utils.Wrap(b.DB.Model(&relation.BlackModel{}).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&blacks).Error, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (b *BlackGorm) FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "blackUserIDs", blackUserIDs)
|
||||
}()
|
||||
return blackUserIDs, utils.Wrap(b.DB.Model(&relation.BlackModel{}).Where("owner_user_id = ?", blackUserIDs).Pluck("block_user_id", &blackUserIDs).Error, "")
|
||||
}
|
@ -1,123 +1,95 @@
|
||||
package relation
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var ConversationDB *gorm.DB
|
||||
|
||||
//type Conversation struct {
|
||||
// OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
|
||||
// ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
|
||||
// ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
|
||||
// UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
|
||||
// GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
|
||||
// RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
|
||||
// UnreadCount int32 `gorm:"column:unread_count" json:"unreadCount"`
|
||||
// DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
|
||||
// IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
|
||||
// IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
||||
// BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
|
||||
// GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
|
||||
// IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"`
|
||||
// UpdateUnreadCountTime int64 `gorm:"column:update_unread_count_time" json:"updateUnreadCountTime"`
|
||||
// AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
||||
// Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||
//}
|
||||
|
||||
func (Conversation) TableName() string {
|
||||
return "conversations"
|
||||
type Conversation interface {
|
||||
Create(ctx context.Context, conversations []*relation.ConversationModel) (err error)
|
||||
Delete(ctx context.Context, groupIDs []string) (err error)
|
||||
UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}) (err error)
|
||||
Update(ctx context.Context, conversations []*relation.ConversationModel) (err error)
|
||||
Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*relation.ConversationModel, err error)
|
||||
FindUserID(ctx context.Context, userIDList []string, conversationID string) ([]string, error)
|
||||
FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)
|
||||
Take(ctx context.Context, userID, conversationID string) (conversation *relation.ConversationModel, err error)
|
||||
FindConversationID(ctx context.Context, userID string, conversationIDList []string) (existConversationID []string, err error)
|
||||
NewTx(tx any) Conversation
|
||||
}
|
||||
type ConversationGorm struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func SetConversation(conversation Conversation) (bool, error) {
|
||||
var isUpdate bool
|
||||
newConversation := conversation
|
||||
if ConversationDB.Model(&Conversation{}).Find(&newConversation).RowsAffected == 0 {
|
||||
return isUpdate, ConversationDB.Model(&Conversation{}).Create(&conversation).Error
|
||||
// if exist, then update record
|
||||
} else {
|
||||
//force update
|
||||
isUpdate = true
|
||||
return isUpdate, ConversationDB.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||
Updates(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt, "is_pinned": conversation.IsPinned, "is_private_chat": conversation.IsPrivateChat,
|
||||
"group_at_type": conversation.GroupAtType, "is_not_in_group": conversation.IsNotInGroup}).Error
|
||||
}
|
||||
}
|
||||
func SetOneConversation(conversation Conversation) error {
|
||||
return ConversationDB.Model(&Conversation{}).Create(&conversation).Error
|
||||
|
||||
func NewConversationGorm(DB *gorm.DB) Conversation {
|
||||
return &ConversationGorm{DB: DB}
|
||||
}
|
||||
|
||||
func PeerUserSetConversation(conversation Conversation) error {
|
||||
newConversation := conversation
|
||||
if ConversationDB.Model(&Conversation{}).Find(&newConversation).RowsAffected == 0 {
|
||||
return ConversationDB.Model(&Conversation{}).Create(&conversation).Error
|
||||
// if exist, then update record
|
||||
}
|
||||
//force update
|
||||
return ConversationDB.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||
Updates(map[string]interface{}{"is_private_chat": conversation.IsPrivateChat}).Error
|
||||
|
||||
func (c *ConversationGorm) NewTx(tx any) Conversation {
|
||||
return &ConversationGorm{DB: tx.(*gorm.DB)}
|
||||
}
|
||||
|
||||
func SetRecvMsgOpt(conversation Conversation) (bool, error) {
|
||||
var isUpdate bool
|
||||
newConversation := conversation
|
||||
if ConversationDB.Model(&Conversation{}).Find(&newConversation).RowsAffected == 0 {
|
||||
return isUpdate, ConversationDB.Model(&Conversation{}).Create(&conversation).Error
|
||||
// if exist, then update record
|
||||
} else {
|
||||
//force update
|
||||
isUpdate = true
|
||||
return isUpdate, ConversationDB.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||
Updates(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt}).Error
|
||||
}
|
||||
func (c *ConversationGorm) Create(ctx context.Context, conversations []*relation.ConversationModel) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations)
|
||||
}()
|
||||
return utils.Wrap(c.DB.Create(&conversations).Error, "")
|
||||
}
|
||||
|
||||
func GetUserAllConversations(ownerUserID string) ([]Conversation, error) {
|
||||
var conversations []Conversation
|
||||
err := ConversationDB.Where("owner_user_id=?", ownerUserID).Find(&conversations).Error
|
||||
return conversations, err
|
||||
}
|
||||
func GetMultipleUserConversationByConversationID(ownerUserIDList []string, conversationID string) ([]Conversation, error) {
|
||||
var conversations []Conversation
|
||||
err := ConversationDB.Where("owner_user_id IN ? and conversation_id=?", ownerUserIDList, conversationID).Find(&conversations).Error
|
||||
return conversations, err
|
||||
}
|
||||
func GetExistConversationUserIDList(ownerUserIDList []string, conversationID string) ([]string, error) {
|
||||
var resultArr []string
|
||||
err := ConversationDB.Table("conversations").Where(" owner_user_id IN (?) and conversation_id=?", ownerUserIDList, conversationID).Pluck("owner_user_id", &resultArr).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resultArr, nil
|
||||
func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
|
||||
}()
|
||||
return utils.Wrap(c.DB.Where("group_id in (?)", groupIDs).Delete(&relation.ConversationModel{}).Error, "")
|
||||
}
|
||||
|
||||
func GetConversation(OwnerUserID, conversationID string) (Conversation, error) {
|
||||
var conversation Conversation
|
||||
err := ConversationDB.Table("conversations").Where("owner_user_id=? and conversation_id=?", OwnerUserID, conversationID).Take(&conversation).Error
|
||||
return conversation, err
|
||||
func (c *ConversationGorm) UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDList", userIDList, "conversationID", conversationID)
|
||||
}()
|
||||
return utils.Wrap(c.DB.Model(&relation.ConversationModel{}).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args).Error, "")
|
||||
}
|
||||
|
||||
func GetConversations(OwnerUserID string, conversationIDs []string) ([]Conversation, error) {
|
||||
var conversations []Conversation
|
||||
err := ConversationDB.Model(&Conversation{}).Where("conversation_id IN (?) and owner_user_id=?", conversationIDs, OwnerUserID).Find(&conversations).Error
|
||||
func (c *ConversationGorm) Update(ctx context.Context, conversations []*relation.ConversationModel) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations)
|
||||
}()
|
||||
return utils.Wrap(c.DB.Updates(&conversations).Error, "")
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*relation.ConversationModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "groups", conversations)
|
||||
}()
|
||||
err = utils.Wrap(c.DB.Where("owner_user_id=? and conversation_id IN (?)", ownerUserID, conversationIDs).Find(&conversations).Error, "")
|
||||
return conversations, err
|
||||
}
|
||||
|
||||
func GetConversationsByConversationIDMultipleOwner(OwnerUserIDList []string, conversationID string) ([]Conversation, error) {
|
||||
var conversations []Conversation
|
||||
err := ConversationDB.Model(&Conversation{}).Where("owner_user_id IN (?) and conversation_id=?", OwnerUserIDList, conversationID).Find(&conversations).Error
|
||||
return conversations, err
|
||||
func (c *ConversationGorm) Take(ctx context.Context, userID, conversationID string) (conversation *relation.ConversationModel, err error) {
|
||||
cc := &relation.ConversationModel{}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversation", *conversation)
|
||||
}()
|
||||
return cc, utils.Wrap(c.DB.Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error, "")
|
||||
}
|
||||
|
||||
func UpdateColumnsConversations(ownerUserIDList []string, conversationID string, args map[string]interface{}) error {
|
||||
return ConversationDB.Model(&Conversation{}).Where("owner_user_id IN (?) and conversation_id=?", ownerUserIDList, conversationID).Updates(args).Error
|
||||
|
||||
func (c *ConversationGorm) FindUserID(ctx context.Context, userIDList []string, conversationID string) (existUserID []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userIDList, "existUserID", existUserID)
|
||||
}()
|
||||
return existUserID, utils.Wrap(c.DB.Where(" owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Pluck("owner_user_id", &existUserID).Error, "")
|
||||
}
|
||||
|
||||
func GetConversationIDListByUserID(userID string) ([]string, error) {
|
||||
var IDList []string
|
||||
err := ConversationDB.Model(&Conversation{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &IDList).Error
|
||||
return IDList, err
|
||||
func (c *ConversationGorm) FindConversationID(ctx context.Context, userID string, conversationIDList []string) (existConversationID []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "existConversationIDList", existConversationID)
|
||||
}()
|
||||
return existConversationID, utils.Wrap(c.DB.Where(" conversation_id IN (?) and owner_user_id=?", conversationIDList, userID).Pluck("conversation_id", &existConversationID).Error, "")
|
||||
}
|
||||
func (c *ConversationGorm) FindUserIDAllConversationID(ctx context.Context, userID string) (conversationIDList []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversationIDList", conversationIDList)
|
||||
}()
|
||||
return conversationIDList, utils.Wrap(c.DB.Model(&relation.ConversationModel{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &conversationIDList).Error, "")
|
||||
}
|
||||
|
@ -1,100 +0,0 @@
|
||||
package relation
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Conversation interface {
|
||||
TableName() string
|
||||
Create(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error)
|
||||
Delete(ctx context.Context, groupIDs []string) (err error)
|
||||
UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}, tx ...any) (err error)
|
||||
Update(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error)
|
||||
Find(ctx context.Context, ownerUserID string, conversationIDs []string, tx ...any) (conversations []*relation.ConversationModel, err error)
|
||||
FindUserID(ctx context.Context, userIDList []string, conversationID string, tx ...any) ([]string, error)
|
||||
FindUserIDAllConversationID(ctx context.Context, userID string, tx ...any) ([]string, error)
|
||||
Take(ctx context.Context, userID, conversationID string, tx ...any) (conversation *relation.ConversationModel, err error)
|
||||
FindConversationID(ctx context.Context, userID string, conversationIDList []string, tx ...any) (existConversationID []string, err error)
|
||||
}
|
||||
type ConversationGorm struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) TableName() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func NewConversationGorm(DB *gorm.DB) Conversation {
|
||||
return &ConversationGorm{DB: DB}
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Create(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations)
|
||||
}()
|
||||
return utils.Wrap(getDBConn(c.DB, tx).Create(&conversations).Error, "")
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
|
||||
}()
|
||||
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.ConversationModel{}).Error, "")
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDList", userIDList, "conversationID", conversationID)
|
||||
}()
|
||||
return utils.Wrap(getDBConn(c.DB, tx).Model(&relation.ConversationModel{}).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args).Error, "")
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Update(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations)
|
||||
}()
|
||||
return utils.Wrap(getDBConn(c.DB, tx).Updates(&conversations).Error, "")
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Find(ctx context.Context, ownerUserID string, conversationIDs []string, tx ...any) (conversations []*relation.ConversationModel, err error) {
|
||||
var newConversations []relation.ConversationModel
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "groups", conversations)
|
||||
}()
|
||||
err = utils.Wrap(getDBConn(c.DB, tx).Where("owner_user_id=? and conversation_id IN (?)", ownerUserID, conversationIDs).Find(&newConversations).Error, "")
|
||||
for _, v := range newConversations {
|
||||
v1 := v
|
||||
conversations = append(conversations, &v1)
|
||||
}
|
||||
return conversations, err
|
||||
}
|
||||
|
||||
func (c *ConversationGorm) Take(ctx context.Context, userID, conversationID string, tx ...any) (conversation *relation.ConversationModel, err error) {
|
||||
cc := &relation.ConversationModel{}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversation", *conversation)
|
||||
}()
|
||||
return cc, utils.Wrap(getDBConn(c.DB, tx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error, "")
|
||||
}
|
||||
func (c *ConversationGorm) FindUserID(ctx context.Context, userIDList []string, conversationID string, tx ...any) (existUserID []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userIDList, "existUserID", existUserID)
|
||||
}()
|
||||
return existUserID, utils.Wrap(getDBConn(c.DB, tx).Where(" owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Pluck("owner_user_id", &existUserID).Error, "")
|
||||
}
|
||||
func (c *ConversationGorm) FindConversationID(ctx context.Context, userID string, conversationIDList []string, tx ...any) (existConversationID []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "existConversationIDList", existConversationID)
|
||||
}()
|
||||
return existConversationID, utils.Wrap(getDBConn(c.DB, tx).Where(" conversation_id IN (?) and owner_user_id=?", conversationIDList, userID).Pluck("conversation_id", &existConversationID).Error, "")
|
||||
}
|
||||
func (c *ConversationGorm) FindUserIDAllConversationID(ctx context.Context, userID string, tx ...any) (conversationIDList []string, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversationIDList", conversationIDList)
|
||||
}()
|
||||
return conversationIDList, utils.Wrap(getDBConn(c.DB, tx).Model(&relation.ConversationModel{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &conversationIDList).Error, "")
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package relation
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var RegisterDB *gorm.DB
|
||||
|
||||
type Register struct {
|
||||
Account string `gorm:"column:account;primary_key;type:char(255)" json:"account"`
|
||||
Password string `gorm:"column:password;type:varchar(255)" json:"password"`
|
||||
Ex string `gorm:"column:ex;size:1024" json:"ex"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(255)" json:"userID"`
|
||||
AreaCode string `gorm:"column:area_code;type:varchar(255)"`
|
||||
InvitationCode string `gorm:"column:invitation_code;type:varchar(255)"`
|
||||
RegisterIP string `gorm:"column:register_ip;type:varchar(255)"`
|
||||
}
|
||||
|
||||
func GetRegister(account, areaCode, userID string) (*Register, error) {
|
||||
var r Register
|
||||
return &r, RegisterDB.Table("registers").Where("user_id = ? and user_id != ? or account = ? or account =? and area_code=?",
|
||||
userID, "", account, account, areaCode).Take(&r).Error
|
||||
}
|
||||
|
||||
func SetPassword(account, password, ex, userID, areaCode, ip string) error {
|
||||
r := Register{
|
||||
Account: account,
|
||||
Password: password,
|
||||
Ex: ex,
|
||||
UserID: userID,
|
||||
RegisterIP: ip,
|
||||
AreaCode: areaCode,
|
||||
}
|
||||
return RegisterDB.Table("registers").Create(&r).Error
|
||||
}
|
||||
|
||||
func ResetPassword(account, password string) error {
|
||||
r := Register{
|
||||
Password: password,
|
||||
}
|
||||
return RegisterDB.Table("registers").Where("account = ?", account).Updates(&r).Error
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user