feat: Add light mode and dark mode.(#89) (#558)

* feat: Add light mode and dark mode.(#89)

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* fix: make file code len

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* feat: fix scripts support win

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* fix: make build issue

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* fix: golint and format

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* feat: add scripts sudo limits of authority

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* fix: docker images fix

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

* fix: docker images fix

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>

---------

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
pull/565/head
Xinwei Xiong 1 year ago committed by GitHub
parent 70d8ae4c19
commit b85c5ad84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,46 +28,46 @@ jobs:
- name: Start Docker Compose - name: Start Docker Compose
run: | run: |
docker compose stop sudo docker compose stop
sleep 30 sudo sleep 30
docker compose up -d sudo docker compose up -d
sleep 60 sudo sleep 60
continue-on-error: true continue-on-error: true
- name: Stop all services - name: Stop all services
run: | run: |
chmod +x ./scripts/stop_all.sh sudo chmod +x ./scripts/stop_all.sh
./scripts/stop_all.sh sudo ./scripts/stop_all.sh
cat logs/openIM.log 2>/dev/null sudo cat logs/openIM.log 2>/dev/null
shell: bash shell: bash
continue-on-error: true continue-on-error: true
- name: Build all services - name: Build all services
run: | run: |
chmod +x ./scripts/build_all_service.sh sudo chmod +x ./scripts/build_all_service.sh
./scripts/build_all_service.sh sudo ./scripts/build_all_service.sh
cat logs/openIM.log 2>/dev/null sudo cat logs/openIM.log 2>/dev/null
shell: bash shell: bash
continue-on-error: true continue-on-error: true
- name: Start all services - name: Start all services
run: | run: |
chmod +x ./scripts/start_all.sh sudo chmod +x ./scripts/start_all.sh
./scripts/start_all.sh sudo ./scripts/start_all.sh
cat logs/openIM.log 2>/dev/null sudo cat logs/openIM.log 2>/dev/null
continue-on-error: true continue-on-error: true
shell: bash shell: bash
- name: Check all services - name: Check all services
run: | run: |
chmod +x ./scripts/check_all.sh sudo chmod +x ./scripts/check_all.sh
./scripts/check_all.sh sudo ./scripts/check_all.sh
cat logs/openIM.log 2>/dev/null sudo cat logs/openIM.log 2>/dev/null
shell: bash shell: bash
- name: Print openIM.log - name: Print openIM.log
run: | run: |
cat logs/* 2>/dev/null sudo cat logs/* 2>/dev/null
cat logs/* 2>/dev/null >> "$GITHUB_OUTPUT" sudo cat logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
shell: bash shell: bash
continue-on-error: true continue-on-error: true

@ -1,5 +1,9 @@
# Build Stage # Build Stage
FROM golang as build FROM golang:1.20 AS builder
LABEL org.opencontainers.image.source=https://github.com/OpenIMSDK/Open-IM-Server
LABEL org.opencontainers.image.description="OpenIM Server image"
LABEL org.opencontainers.image.licenses="Apache 2.0"
# Set go mod installation source and proxy # Set go mod installation source and proxy
ARG GO111MODULE=on ARG GO111MODULE=on
@ -24,9 +28,9 @@ RUN apk --no-cache add tzdata
VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"] VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"]
# Copy scripts and binary files to the production image # Copy scripts and binary files to the production image
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts COPY --from=builder /Open-IM-Server/scripts /Open-IM-Server/scripts
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/arm64 /Open-IM-Server/_output/bin/platforms/linux/arm64 COPY --from=builder /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64
WORKDIR /Open-IM-Server/scripts WORKDIR /Open-IM-Server/scripts
CMD ["./docker_start_all.sh"] CMD ["docker_start_all.sh"]

@ -18,12 +18,12 @@ import (
"context" "context"
"fmt" "fmt"
"net" "net"
"net/http"
"os" "os"
"runtime" "runtime"
"strconv" "strconv"
"time" "time"
"net/http"
_ "net/http/pprof" _ "net/http/pprof"
"github.com/OpenIMSDK/Open-IM-Server/internal/api" "github.com/OpenIMSDK/Open-IM-Server/internal/api"

@ -100,7 +100,7 @@ services:
openim_server: openim_server:
image: ghcr.io/openimsdk/openim-server:v3.0.0-rc.2 image: ghcr.io/openimsdk/openim-server:v3.0.1
container_name: openim-server container_name: openim-server
volumes: volumes:
- ./logs:/Open-IM-Server/logs - ./logs:/Open-IM-Server/logs

@ -131,6 +131,7 @@ func (o *GroupApi) GetSuperGroupsInfo(c *gin.Context) {
func (o *GroupApi) GroupCreateCount(c *gin.Context) { func (o *GroupApi) GroupCreateCount(c *gin.Context) {
a2r.Call(group.GroupClient.GroupCreateCount, o.Client, c) a2r.Call(group.GroupClient.GroupCreateCount, o.Client, c)
} }
func (o *GroupApi) GetGroups(c *gin.Context) { func (o *GroupApi) GetGroups(c *gin.Context) {
a2r.Call(group.GroupClient.GetGroups, o.Client, c) a2r.Call(group.GroupClient.GetGroups, o.Client, c)
} }

@ -160,7 +160,6 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
} }
} }
} }
} }
for p, tokens := range m { for p, tokens := range m {
t := new(msggateway.SinglePlatformToken) t := new(msggateway.SinglePlatformToken)
@ -176,5 +175,4 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
} }
apiresp.GinSuccess(c, respResult) apiresp.GinSuccess(c, respResult)
} }

@ -31,10 +31,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
) )
var ErrConnClosed = errors.New("conn has closed") var (
var ErrNotSupportMessageProtocol = errors.New("not support message protocol") ErrConnClosed = errors.New("conn has closed")
var ErrClientClosed = errors.New("client actively close the connection") ErrNotSupportMessageProtocol = errors.New("not support message protocol")
var ErrPanic = errors.New("panic error") ErrClientClosed = errors.New("client actively close the connection")
ErrPanic = errors.New("panic error")
)
const ( const (
// MessageText is for UTF-8 encoded text messages like JSON. // MessageText is for UTF-8 encoded text messages like JSON.
@ -102,10 +104,12 @@ func (c *Client) ResetClient(
c.closedErr = nil c.closedErr = nil
c.token = token c.token = token
} }
func (c *Client) pongHandler(_ string) error { func (c *Client) pongHandler(_ string) error {
c.conn.SetReadDeadline(pongWait) c.conn.SetReadDeadline(pongWait)
return nil return nil
} }
func (c *Client) readMessage() { func (c *Client) readMessage() {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
@ -148,8 +152,8 @@ func (c *Client) readMessage() {
default: default:
} }
} }
} }
func (c *Client) handleMessage(message []byte) error { func (c *Client) handleMessage(message []byte) error {
if c.IsCompress { if c.IsCompress {
var decompressErr error var decompressErr error
@ -198,8 +202,8 @@ func (c *Client) handleMessage(message []byte) error {
} }
c.replyMessage(ctx, &binaryReq, messageErr, resp) c.replyMessage(ctx, &binaryReq, messageErr, resp)
return nil return nil
} }
func (c *Client) setAppBackgroundStatus(ctx context.Context, req Req) ([]byte, error) { func (c *Client) setAppBackgroundStatus(ctx context.Context, req Req) ([]byte, error) {
resp, isBackground, messageErr := c.longConnServer.SetUserDeviceBackground(ctx, req) resp, isBackground, messageErr := c.longConnServer.SetUserDeviceBackground(ctx, req)
if messageErr != nil { if messageErr != nil {
@ -208,16 +212,16 @@ func (c *Client) setAppBackgroundStatus(ctx context.Context, req Req) ([]byte, e
c.IsBackground = isBackground c.IsBackground = isBackground
// todo callback // todo callback
return resp, nil return resp, nil
} }
func (c *Client) close() { func (c *Client) close() {
c.w.Lock() c.w.Lock()
defer c.w.Unlock() defer c.w.Unlock()
c.closed = true c.closed = true
c.conn.Close() c.conn.Close()
c.longConnServer.UnRegister(c) c.longConnServer.UnRegister(c)
} }
func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, resp []byte) { func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, resp []byte) {
errResp := apiresp.ParseError(err) errResp := apiresp.ParseError(err)
mReply := Resp{ mReply := Resp{
@ -234,6 +238,7 @@ func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, re
log.ZWarn(ctx, "wireBinaryMsg replyMessage", err, "resp", mReply.String()) log.ZWarn(ctx, "wireBinaryMsg replyMessage", err, "resp", mReply.String())
} }
} }
func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error { func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error {
var msg sdkws.PushMessages var msg sdkws.PushMessages
conversationID := utils.GetConversationIDByMsg(msgData) conversationID := utils.GetConversationIDByMsg(msgData)
@ -296,5 +301,4 @@ func (c *Client) writePongMsg() error {
} }
_ = c.conn.SetWriteDeadline(writeWait) _ = c.conn.SetWriteDeadline(writeWait)
return c.conn.WriteMessage(PongMessage, nil) return c.conn.WriteMessage(PongMessage, nil)
} }

@ -33,6 +33,7 @@ type GzipCompressor struct {
func NewGzipCompressor() *GzipCompressor { func NewGzipCompressor() *GzipCompressor {
return &GzipCompressor{compressProtocol: "gzip"} return &GzipCompressor{compressProtocol: "gzip"}
} }
func (g *GzipCompressor) Compress(rawData []byte) ([]byte, error) { func (g *GzipCompressor) Compress(rawData []byte) ([]byte, error) {
gzipBuffer := bytes.Buffer{} gzipBuffer := bytes.Buffer{}
gz := gzip.NewWriter(&gzipBuffer) gz := gzip.NewWriter(&gzipBuffer)

@ -27,11 +27,13 @@ const (
GzipCompressionProtocol = "gzip" GzipCompressionProtocol = "gzip"
BackgroundStatus = "isBackground" BackgroundStatus = "isBackground"
) )
const ( const (
WebSocket = iota + 1 WebSocket = iota + 1
) )
const ( const (
//Websocket Protocol // Websocket Protocol.
WSGetNewestSeq = 1001 WSGetNewestSeq = 1001
WSPullMsgBySeqList = 1002 WSPullMsgBySeqList = 1002
WSSendMsg = 1003 WSSendMsg = 1003

@ -71,9 +71,11 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
ConnID: utils.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))), ConnID: utils.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))),
} }
} }
func (c *UserConnContext) GetRemoteAddr() string { func (c *UserConnContext) GetRemoteAddr() string {
return c.RemoteAddr return c.RemoteAddr
} }
func (c *UserConnContext) Query(key string) (string, bool) { func (c *UserConnContext) Query(key string) (string, bool) {
var value string var value string
if value = c.Req.URL.Query().Get(key); value == "" { if value = c.Req.URL.Query().Get(key); value == "" {
@ -81,6 +83,7 @@ func (c *UserConnContext) Query(key string) (string, bool) {
} }
return value, true return value, true
} }
func (c *UserConnContext) GetHeader(key string) (string, bool) { func (c *UserConnContext) GetHeader(key string) (string, bool) {
var value string var value string
if value = c.Req.Header.Get(key); value == "" { if value = c.Req.Header.Get(key); value == "" {
@ -88,27 +91,35 @@ func (c *UserConnContext) GetHeader(key string) (string, bool) {
} }
return value, true return value, true
} }
func (c *UserConnContext) SetHeader(key, value string) { func (c *UserConnContext) SetHeader(key, value string) {
c.RespWriter.Header().Set(key, value) c.RespWriter.Header().Set(key, value)
} }
func (c *UserConnContext) ErrReturn(error string, code int) { func (c *UserConnContext) ErrReturn(error string, code int) {
http.Error(c.RespWriter, error, code) http.Error(c.RespWriter, error, code)
} }
func (c *UserConnContext) GetConnID() string { func (c *UserConnContext) GetConnID() string {
return c.ConnID return c.ConnID
} }
func (c *UserConnContext) GetUserID() string { func (c *UserConnContext) GetUserID() string {
return c.Req.URL.Query().Get(WsUserID) return c.Req.URL.Query().Get(WsUserID)
} }
func (c *UserConnContext) GetPlatformID() string { func (c *UserConnContext) GetPlatformID() string {
return c.Req.URL.Query().Get(PlatformID) return c.Req.URL.Query().Get(PlatformID)
} }
func (c *UserConnContext) GetOperationID() string { func (c *UserConnContext) GetOperationID() string {
return c.Req.URL.Query().Get(OperationID) return c.Req.URL.Query().Get(OperationID)
} }
func (c *UserConnContext) GetToken() string { func (c *UserConnContext) GetToken() string {
return c.Req.URL.Query().Get(Token) return c.Req.URL.Query().Get(Token)
} }
func (c *UserConnContext) GetBackground() bool { func (c *UserConnContext) GetBackground() bool {
b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus)) b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus))
if err != nil { if err != nil {

@ -26,12 +26,12 @@ type Encoder interface {
Decode(encodeData []byte, decodeData interface{}) error Decode(encodeData []byte, decodeData interface{}) error
} }
type GobEncoder struct { type GobEncoder struct{}
}
func NewGobEncoder() *GobEncoder { func NewGobEncoder() *GobEncoder {
return &GobEncoder{} return &GobEncoder{}
} }
func (g *GobEncoder) Encode(data interface{}) ([]byte, error) { func (g *GobEncoder) Encode(data interface{}) ([]byte, error) {
buff := bytes.Buffer{} buff := bytes.Buffer{}
enc := gob.NewEncoder(&buff) enc := gob.NewEncoder(&buff)
@ -41,6 +41,7 @@ func (g *GobEncoder) Encode(data interface{}) ([]byte, error) {
} }
return buff.Bytes(), nil return buff.Bytes(), nil
} }
func (g *GobEncoder) Decode(encodeData []byte, decodeData interface{}) error { func (g *GobEncoder) Decode(encodeData []byte, decodeData interface{}) error {
buff := bytes.NewBuffer(encodeData) buff := bytes.NewBuffer(encodeData)
dec := gob.NewDecoder(buff) dec := gob.NewDecoder(buff)

@ -58,6 +58,7 @@ func newGWebSocket(protocolType int, handshakeTimeout time.Duration) *GWebSocket
func (d *GWebSocket) Close() error { func (d *GWebSocket) Close() error {
return d.conn.Close() return d.conn.Close()
} }
func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error { func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error {
upgrader := &websocket.Upgrader{ upgrader := &websocket.Upgrader{
HandshakeTimeout: d.handshakeTimeout, HandshakeTimeout: d.handshakeTimeout,
@ -69,8 +70,8 @@ func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) er
} }
d.conn = conn d.conn = conn
return nil return nil
} }
func (d *GWebSocket) WriteMessage(messageType int, message []byte) error { func (d *GWebSocket) WriteMessage(messageType int, message []byte) error {
// d.setSendConn(d.conn) // d.setSendConn(d.conn)
return d.conn.WriteMessage(messageType, message) return d.conn.WriteMessage(messageType, message)
@ -83,6 +84,7 @@ func (d *GWebSocket) WriteMessage(messageType int, message []byte) error {
func (d *GWebSocket) ReadMessage() (int, []byte, error) { func (d *GWebSocket) ReadMessage() (int, []byte, error) {
return d.conn.ReadMessage() return d.conn.ReadMessage()
} }
func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error { func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error {
return d.conn.SetReadDeadline(time.Now().Add(timeout)) return d.conn.SetReadDeadline(time.Now().Add(timeout))
} }
@ -97,7 +99,6 @@ func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Respo
d.conn = conn d.conn = conn
} }
return httpResp, err return httpResp, err
} }
func (d *GWebSocket) IsNil() bool { func (d *GWebSocket) IsNil() bool {
@ -110,9 +111,11 @@ func (d *GWebSocket) IsNil() bool {
func (d *GWebSocket) SetConnNil() { func (d *GWebSocket) SetConnNil() {
d.conn = nil d.conn = nil
} }
func (d *GWebSocket) SetReadLimit(limit int64) { func (d *GWebSocket) SetReadLimit(limit int64) {
d.conn.SetReadLimit(limit) d.conn.SetReadLimit(limit)
} }
func (d *GWebSocket) SetPongHandler(handler PongHandler) { func (d *GWebSocket) SetPongHandler(handler PongHandler) {
d.conn.SetPongHandler(handler) d.conn.SetPongHandler(handler)
} }

@ -75,8 +75,10 @@ type GrpcHandler struct {
func NewGrpcHandler(validate *validator.Validate, client discoveryregistry.SvcDiscoveryRegistry) *GrpcHandler { func NewGrpcHandler(validate *validator.Validate, client discoveryregistry.SvcDiscoveryRegistry) *GrpcHandler {
msgRpcClient := rpcclient.NewMessageRpcClient(client) msgRpcClient := rpcclient.NewMessageRpcClient(client)
pushRpcClient := rpcclient.NewPushRpcClient(client) pushRpcClient := rpcclient.NewPushRpcClient(client)
return &GrpcHandler{msgRpcClient: &msgRpcClient, return &GrpcHandler{
pushClient: &pushRpcClient, validate: validate} msgRpcClient: &msgRpcClient,
pushClient: &pushRpcClient, validate: validate,
}
} }
func (g GrpcHandler) GetSeq(context context.Context, data Req) ([]byte, error) { func (g GrpcHandler) GetSeq(context context.Context, data Req) ([]byte, error) {
@ -164,6 +166,7 @@ func (g GrpcHandler) UserLogout(context context.Context, data Req) ([]byte, erro
} }
return c, nil return c, nil
} }
func (g GrpcHandler) SetUserDeviceBackground(_ context.Context, data Req) ([]byte, bool, error) { func (g GrpcHandler) SetUserDeviceBackground(_ context.Context, data Req) ([]byte, bool, error) {
req := sdkws.SetAppBackgroundStatusReq{} req := sdkws.SetAppBackgroundStatusReq{}
if err := proto.Unmarshal(data.Data, &req); err != nil { if err := proto.Unmarshal(data.Data, &req); err != nil {

@ -86,6 +86,7 @@ type kickHandler struct {
func (ws *WsServer) SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry) { func (ws *WsServer) SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry) {
ws.MessageHandler = NewGrpcHandler(ws.validate, client) ws.MessageHandler = NewGrpcHandler(ws.validate, client)
} }
func (ws *WsServer) SetCacheHandler(cache cache.MsgModel) { func (ws *WsServer) SetCacheHandler(cache cache.MsgModel) {
ws.cache = cache ws.cache = cache
} }
@ -113,7 +114,6 @@ func NewWsServer(opts ...Option) (*WsServer, error) {
} }
if config.port < 1024 { if config.port < 1024 {
return nil, errors.New("port not allow to listen") return nil, errors.New("port not allow to listen")
} }
v := validator.New() v := validator.New()
return &WsServer{ return &WsServer{
@ -134,6 +134,7 @@ func NewWsServer(opts ...Option) (*WsServer, error) {
Encoder: NewGobEncoder(), Encoder: NewGobEncoder(),
}, nil }, nil
} }
func (ws *WsServer) Run() error { func (ws *WsServer) Run() error {
var client *Client var client *Client
go func() { go func() {
@ -165,7 +166,6 @@ func (ws *WsServer) registerClient(client *Client) {
log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID) log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID)
atomic.AddInt64(&ws.onlineUserNum, 1) atomic.AddInt64(&ws.onlineUserNum, 1)
atomic.AddInt64(&ws.onlineUserConnNum, 1) atomic.AddInt64(&ws.onlineUserConnNum, 1)
} else { } else {
i := &kickHandler{ i := &kickHandler{
clientOK: clientOK, clientOK: clientOK,
@ -194,6 +194,7 @@ func (ws *WsServer) registerClient(client *Client) {
ws.onlineUserConnNum, ws.onlineUserConnNum,
) )
} }
func getRemoteAdders(client []*Client) string { func getRemoteAdders(client []*Client) string {
var ret string var ret string
for i, c := range client { for i, c := range client {
@ -284,8 +285,8 @@ func (ws *WsServer) multiTerminalLoginChecker(info *kickHandler) {
} }
} }
} }
} }
func (ws *WsServer) unregisterClient(client *Client) { func (ws *WsServer) unregisterClient(client *Client) {
defer ws.clientPool.Put(client) defer ws.clientPool.Put(client)
isDeleteUser := ws.clients.delete(client.UserID, client.ctx.GetRemoteAddr()) isDeleteUser := ws.clients.delete(client.UserID, client.ctx.GetRemoteAddr())

@ -16,8 +16,9 @@ package msggateway
import "time" import "time"
type Option func(opt *configs) type (
type configs struct { Option func(opt *configs)
configs struct {
// 长连接监听端口 // 长连接监听端口
port int port int
// 长连接允许最大链接数 // 长连接允许最大链接数
@ -27,22 +28,26 @@ type configs struct {
// 允许消息最大长度 // 允许消息最大长度
messageMaxMsgLength int messageMaxMsgLength int
} }
)
func WithPort(port int) Option { func WithPort(port int) Option {
return func(opt *configs) { return func(opt *configs) {
opt.port = port opt.port = port
} }
} }
func WithMaxConnNum(num int64) Option { func WithMaxConnNum(num int64) Option {
return func(opt *configs) { return func(opt *configs) {
opt.maxConnNum = num opt.maxConnNum = num
} }
} }
func WithHandshakeTimeout(t time.Duration) Option { func WithHandshakeTimeout(t time.Duration) Option {
return func(opt *configs) { return func(opt *configs) {
opt.handshakeTimeout = t opt.handshakeTimeout = t
} }
} }
func WithMessageMaxMsgLength(length int) Option { func WithMessageMaxMsgLength(length int) Option {
return func(opt *configs) { return func(opt *configs) {
opt.messageMaxMsgLength = length opt.messageMaxMsgLength = length

@ -29,6 +29,7 @@ type UserMap struct {
func newUserMap() *UserMap { func newUserMap() *UserMap {
return &UserMap{} return &UserMap{}
} }
func (u *UserMap) GetAll(key string) ([]*Client, bool) { func (u *UserMap) GetAll(key string) ([]*Client, bool) {
allClients, ok := u.m.Load(key) allClients, ok := u.m.Load(key)
if ok { if ok {
@ -36,6 +37,7 @@ func (u *UserMap) GetAll(key string) ([]*Client, bool) {
} }
return nil, ok return nil, ok
} }
func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) { func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
allClients, userExisted := u.m.Load(key) allClients, userExisted := u.m.Load(key)
if userExisted { if userExisted {
@ -47,12 +49,12 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
} }
if len(clients) > 0 { if len(clients) > 0 {
return clients, userExisted, true return clients, userExisted, true
} }
return clients, userExisted, false return clients, userExisted, false
} }
return nil, userExisted, false return nil, userExisted, false
} }
func (u *UserMap) Set(key string, v *Client) { func (u *UserMap) Set(key string, v *Client) {
allClients, existed := u.m.Load(key) allClients, existed := u.m.Load(key)
if existed { if existed {
@ -67,6 +69,7 @@ func (u *UserMap) Set(key string, v *Client) {
u.m.Store(key, clients) u.m.Store(key, clients)
} }
} }
func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) { func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
allClients, existed := u.m.Load(key) allClients, existed := u.m.Load(key)
if existed { if existed {
@ -87,6 +90,7 @@ func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool)
} }
return existed return existed
} }
func (u *UserMap) deleteClients(key string, clients []*Client) (isDeleteUser bool) { func (u *UserMap) deleteClients(key string, clients []*Client) (isDeleteUser bool) {
m := utils.SliceToMapAny(clients, func(c *Client) (string, struct{}) { m := utils.SliceToMapAny(clients, func(c *Client) (string, struct{}) {
return c.ctx.GetRemoteAddr(), struct{}{} return c.ctx.GetRemoteAddr(), struct{}{}
@ -110,6 +114,7 @@ func (u *UserMap) deleteClients(key string, clients []*Client) (isDeleteUser boo
} }
return existed return existed
} }
func (u *UserMap) DeleteAll(key string) { func (u *UserMap) DeleteAll(key string) {
u.m.Delete(key) u.m.Delete(key)
} }

@ -19,6 +19,9 @@ import (
"sync" "sync"
"time" "time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@ -30,8 +33,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper" openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
) )
type MsgTransfer struct { type MsgTransfer struct {
@ -84,9 +85,12 @@ func StartTransfer(prometheusPort int) error {
func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase, func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase,
msgDatabase controller.CommonMsgDatabase, msgDatabase controller.CommonMsgDatabase,
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer { conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient,
return &MsgTransfer{persistentCH: NewPersistentConsumerHandler(chatLogDatabase), historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient), ) *MsgTransfer {
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase)} return &MsgTransfer{
persistentCH: NewPersistentConsumerHandler(chatLogDatabase), historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase),
}
} }
func (m *MsgTransfer) initPrometheus() { func (m *MsgTransfer) initPrometheus() {

@ -38,10 +38,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
) )
const ConsumerMsgs = 3 const (
const SourceMessages = 4 ConsumerMsgs = 3
const MongoMessages = 5 SourceMessages = 4
const ChannelNum = 100 MongoMessages = 5
ChannelNum = 100
)
type MsgChannelValue struct { type MsgChannelValue struct {
uniqueKey string uniqueKey string
@ -93,8 +95,10 @@ func NewOnlineHistoryRedisConsumerHandler(
} }
och.conversationRpcClient = conversationRpcClient och.conversationRpcClient = conversationRpcClient
och.groupRpcClient = groupRpcClient och.groupRpcClient = groupRpcClient
och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic}, KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis) config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
// statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d // statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d
// second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval) // second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
@ -163,7 +167,7 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
} }
} }
// 获取消息/通知 存储的消息列表, 不存储并且推送的消息列表, // 获取消息/通知 存储的消息列表, 不存储并且推送的消息列表,.
func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList( func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
totalMsgs []*ContextMsg, totalMsgs []*ContextMsg,
) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) { ) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
@ -378,13 +382,13 @@ func (och *OnlineHistoryRedisConsumerHandler) MessagesDistributionHandle() {
} }
} }
} }
func withAggregationCtx(ctx context.Context, values []*ContextMsg) context.Context { func withAggregationCtx(ctx context.Context, values []*ContextMsg) context.Context {
var allMessageOperationID string var allMessageOperationID string
for i, v := range values { for i, v := range values {
if opid := mcontext.GetOperationID(v.ctx); opid != "" { if opid := mcontext.GetOperationID(v.ctx); opid != "" {
if i == 0 { if i == 0 {
allMessageOperationID += opid allMessageOperationID += opid
} else { } else {
allMessageOperationID += "$" + opid allMessageOperationID += "$" + opid
} }
@ -433,11 +437,13 @@ func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(
for i := 0; i < len(ccMsg)/split; i++ { for i := 0; i < len(ccMsg)/split; i++ {
// log.Debug() // log.Debug()
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{ och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
ctx: ctx, cMsgList: ccMsg[i*split : (i+1)*split]}} ctx: ctx, cMsgList: ccMsg[i*split : (i+1)*split],
}}
} }
if (len(ccMsg) % split) > 0 { if (len(ccMsg) % split) > 0 {
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{ och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
ctx: ctx, cMsgList: ccMsg[split*(len(ccMsg)/split):]}} ctx: ctx, cMsgList: ccMsg[split*(len(ccMsg)/split):],
}}
} }
log.ZDebug(ctx, "timer trigger msg consumer end", "length", len(ccMsg)) log.ZDebug(ctx, "timer trigger msg consumer end", "length", len(ccMsg))
} }

@ -34,8 +34,10 @@ type OnlineHistoryMongoConsumerHandler struct {
func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase) *OnlineHistoryMongoConsumerHandler { func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase) *OnlineHistoryMongoConsumerHandler {
mc := &OnlineHistoryMongoConsumerHandler{ mc := &OnlineHistoryMongoConsumerHandler{
historyConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, historyConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToMongo.Topic}, KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
}, []string{config.Config.Kafka.MsgToMongo.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo), config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo),
msgDatabase: database, msgDatabase: database,
} }

@ -36,8 +36,10 @@ type PersistentConsumerHandler struct {
func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *PersistentConsumerHandler { func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *PersistentConsumerHandler {
return &PersistentConsumerHandler{ return &PersistentConsumerHandler{
persistentConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, persistentConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic}, KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql), config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql),
chatLogDatabase: database, chatLogDatabase: database,
} }

@ -145,7 +145,7 @@ func newPushReq(title, content string) PushReq {
} }
func newBatchPushReq(userIDs []string, taskID string) PushReq { func newBatchPushReq(userIDs []string, taskID string) PushReq {
var IsAsync = true IsAsync := true
return PushReq{Audience: &Audience{Alias: userIDs}, IsAsync: &IsAsync, TaskID: &taskID} return PushReq{Audience: &Audience{Alias: userIDs}, IsAsync: &IsAsync, TaskID: &taskID}
} }

@ -15,17 +15,16 @@
package getui package getui
import ( import (
"sync"
"github.com/go-redis/redis"
"context" "context"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"errors" "errors"
"strconv" "strconv"
"sync"
"time" "time"
"github.com/go-redis/redis"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@ -49,7 +48,7 @@ const (
taskURL = "/push/list/message" taskURL = "/push/list/message"
batchPushURL = "/push/list/alias" batchPushURL = "/push/list/alias"
// codes // codes.
tokenExpireCode = 10001 tokenExpireCode = 10001
tokenExpireTime = 60 * 60 * 23 tokenExpireTime = 60 * 60 * 23
taskIDTTL = 1000 * 60 * 60 * 24 taskIDTTL = 1000 * 60 * 60 * 24
@ -142,7 +141,7 @@ func (g *Client) GetTaskID(ctx context.Context, token string, pushReq PushReq) (
return respTask.TaskID, nil return respTask.TaskID, nil
} }
// max num is 999 // max num is 999.
func (g *Client) batchPush(ctx context.Context, token string, userIDs []string, pushReq PushReq) error { func (g *Client) batchPush(ctx context.Context, token string, userIDs []string, pushReq PushReq) error {
taskID, err := g.GetTaskID(ctx, token, pushReq) taskID, err := g.GetTaskID(ctx, token, pushReq)
if err != nil { if err != nil {

@ -66,6 +66,7 @@ func (p *Platform) Set(os string) error {
return nil return nil
} }
func (p *Platform) SetPlatform(platform string) error { func (p *Platform) SetPlatform(platform string) error {
switch platform { switch platform {
case constant.AndroidPlatformStr: case constant.AndroidPlatformStr:
@ -75,8 +76,8 @@ func (p *Platform) SetPlatform(platform string) error {
default: default:
return errors.New("platform err") return errors.New("platform err")
} }
} }
func (p *Platform) SetIOS() error { func (p *Platform) SetIOS() error {
return p.Set(IOS) return p.Set(IOS)
} }

@ -37,6 +37,7 @@ func (p *PushObj) SetNotification(no *Notification) {
func (p *PushObj) SetMessage(m *Message) { func (p *PushObj) SetMessage(m *Message) {
p.Message = m p.Message = m
} }
func (p *PushObj) SetOptions(o *Options) { func (p *PushObj) SetOptions(o *Options) {
p.Options = o p.Options = o
} }

@ -37,8 +37,10 @@ type ConsumerHandler struct {
func NewConsumerHandler(pusher *Pusher) *ConsumerHandler { func NewConsumerHandler(pusher *Pusher) *ConsumerHandler {
var consumerHandler ConsumerHandler var consumerHandler ConsumerHandler
consumerHandler.pusher = pusher consumerHandler.pusher = pusher
consumerHandler.pushConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, consumerHandler.pushConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToPush.Topic}, config.Config.Kafka.Addr, KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
}, []string{config.Config.Kafka.MsgToPush.Topic}, config.Config.Kafka.Addr,
config.Config.Kafka.ConsumerGroupID.MsgToPush) config.Config.Kafka.ConsumerGroupID.MsgToPush)
return &consumerHandler return &consumerHandler
} }
@ -76,7 +78,8 @@ func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
func (ConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil } func (ConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (ConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil } func (ConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (c *ConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, func (c *ConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error { claim sarama.ConsumerGroupClaim,
) error {
for msg := range claim.Messages() { for msg := range claim.Messages() {
ctx := c.pushConsumerGroup.GetContextFromMsg(msg) ctx := c.pushConsumerGroup.GetContextFromMsg(msg)
c.handleMs2PsChat(ctx, msg.Value) c.handleMs2PsChat(ctx, msg.Value)

@ -54,7 +54,8 @@ var errNoOfflinePusher = errors.New("no offlinePusher is configured")
func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase, func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache, groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache,
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient, msgRpcClient *rpcclient.MessageRpcClient) *Pusher { conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient, msgRpcClient *rpcclient.MessageRpcClient,
) *Pusher {
return &Pusher{ return &Pusher{
discov: discov, discov: discov,
database: database, database: database,
@ -265,7 +266,6 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
if reply != nil && reply.SinglePushResult != nil { if reply != nil && reply.SinglePushResult != nil {
wsResults = append(wsResults, reply.SinglePushResult...) wsResults = append(wsResults, reply.SinglePushResult...)
} }
} }
return wsResults, nil return wsResults, nil
} }

@ -17,6 +17,8 @@ package conversation
import ( import (
"context" "context"
"google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@ -31,7 +33,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc"
) )
type conversationServer struct { type conversationServer struct {
@ -184,7 +185,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
return &pbConversation.SetConversationsResp{}, nil return &pbConversation.SetConversationsResp{}, nil
} }
// 获取超级大群开启免打扰的用户ID // 获取超级大群开启免打扰的用户ID.
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbConversation.GetRecvMsgNotNotifyUserIDsReq) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) { func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbConversation.GetRecvMsgNotNotifyUserIDsReq) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID) userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
if err != nil { if err != nil {
@ -193,7 +194,7 @@ func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req
return &pbConversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil return &pbConversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
} }
// create conversation without notification for msg redis transfer // create conversation without notification for msg redis transfer.
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbConversation.CreateSingleChatConversationsReq) (*pbConversation.CreateSingleChatConversationsResp, error) { func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbConversation.CreateSingleChatConversationsReq) (*pbConversation.CreateSingleChatConversationsResp, error) {
var conversation tableRelation.ConversationModel var conversation tableRelation.ConversationModel
conversation.ConversationID = utils.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID) conversation.ConversationID = utils.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
@ -247,7 +248,10 @@ func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
} }
func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbConversation.GetConversationsByConversationIDReq) (*pbConversation.GetConversationsByConversationIDResp, error) { func (c *conversationServer) GetConversationsByConversationID(
ctx context.Context,
req *pbConversation.GetConversationsByConversationIDReq,
) (*pbConversation.GetConversationsByConversationIDResp, error) {
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs) conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
if err != nil { if err != nil {
return nil, err return nil, err

@ -83,7 +83,7 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
return nil return nil
} }
// ok // ok.
func (s *friendServer) ApplyToAddFriend( func (s *friendServer) ApplyToAddFriend(
ctx context.Context, ctx context.Context,
req *pbfriend.ApplyToAddFriendReq, req *pbfriend.ApplyToAddFriendReq,
@ -116,7 +116,7 @@ func (s *friendServer) ApplyToAddFriend(
return resp, nil return resp, nil
} }
// ok // ok.
func (s *friendServer) ImportFriends( func (s *friendServer) ImportFriends(
ctx context.Context, ctx context.Context,
req *pbfriend.ImportFriendReq, req *pbfriend.ImportFriendReq,
@ -142,7 +142,7 @@ func (s *friendServer) ImportFriends(
return &pbfriend.ImportFriendResp{}, nil return &pbfriend.ImportFriendResp{}, nil
} }
// ok // ok.
func (s *friendServer) RespondFriendApply( func (s *friendServer) RespondFriendApply(
ctx context.Context, ctx context.Context,
req *pbfriend.RespondFriendApplyReq, req *pbfriend.RespondFriendApplyReq,
@ -178,7 +178,7 @@ func (s *friendServer) RespondFriendApply(
return nil, errs.ErrArgs.Wrap("req.HandleResult != -1/1") return nil, errs.ErrArgs.Wrap("req.HandleResult != -1/1")
} }
// ok // ok.
func (s *friendServer) DeleteFriend( func (s *friendServer) DeleteFriend(
ctx context.Context, ctx context.Context,
req *pbfriend.DeleteFriendReq, req *pbfriend.DeleteFriendReq,
@ -199,7 +199,7 @@ func (s *friendServer) DeleteFriend(
return resp, nil return resp, nil
} }
// ok // ok.
func (s *friendServer) SetFriendRemark( func (s *friendServer) SetFriendRemark(
ctx context.Context, ctx context.Context,
req *pbfriend.SetFriendRemarkReq, req *pbfriend.SetFriendRemarkReq,
@ -220,7 +220,7 @@ func (s *friendServer) SetFriendRemark(
return resp, nil return resp, nil
} }
// ok // ok.
func (s *friendServer) GetDesignatedFriends( func (s *friendServer) GetDesignatedFriends(
ctx context.Context, ctx context.Context,
req *pbfriend.GetDesignatedFriendsReq, req *pbfriend.GetDesignatedFriendsReq,
@ -240,7 +240,7 @@ func (s *friendServer) GetDesignatedFriends(
return resp, nil return resp, nil
} }
// ok 获取接收到的好友申请(即别人主动申请的) // ok 获取接收到的好友申请(即别人主动申请的).
func (s *friendServer) GetPaginationFriendsApplyTo( func (s *friendServer) GetPaginationFriendsApplyTo(
ctx context.Context, ctx context.Context,
req *pbfriend.GetPaginationFriendsApplyToReq, req *pbfriend.GetPaginationFriendsApplyToReq,
@ -263,7 +263,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(
return resp, nil return resp, nil
} }
// ok 获取主动发出去的好友申请列表 // ok 获取主动发出去的好友申请列表.
func (s *friendServer) GetPaginationFriendsApplyFrom( func (s *friendServer) GetPaginationFriendsApplyFrom(
ctx context.Context, ctx context.Context,
req *pbfriend.GetPaginationFriendsApplyFromReq, req *pbfriend.GetPaginationFriendsApplyFromReq,
@ -286,7 +286,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(
return resp, nil return resp, nil
} }
// ok // ok.
func (s *friendServer) IsFriend( func (s *friendServer) IsFriend(
ctx context.Context, ctx context.Context,
req *pbfriend.IsFriendReq, req *pbfriend.IsFriendReq,
@ -300,7 +300,7 @@ func (s *friendServer) IsFriend(
return resp, nil return resp, nil
} }
// ok // ok.
func (s *friendServer) GetPaginationFriends( func (s *friendServer) GetPaginationFriends(
ctx context.Context, ctx context.Context,
req *pbfriend.GetPaginationFriendsReq, req *pbfriend.GetPaginationFriendsReq,

@ -17,20 +17,23 @@ package group
import ( import (
"context" "context"
"fmt" "fmt"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
"math/big" "math/big"
"math/rand" "math/rand"
"strconv" "strconv"
"strings" "strings"
"time" "time"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@ -45,7 +48,6 @@ import (
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group" pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc"
) )
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
@ -900,7 +902,6 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
}() }()
num++ num++
s.Notification.GroupInfoSetAnnouncementNotification(ctx, &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser}) s.Notification.GroupInfoSetAnnouncementNotification(ctx, &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser})
} }
switch len(data) - num { switch len(data) - num {
case 0: case 0:

@ -16,9 +16,10 @@ package group
import ( import (
"context" "context"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"time"
) )
func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCreateCountReq) (*group.GroupCreateCountResp, error) { func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCreateCountReq) (*group.GroupCreateCountResp, error) {

@ -39,7 +39,7 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m
if err != nil { if err != nil {
return nil, err return nil, err
} }
var conversationMaxSeqMap = make(map[string]int64) conversationMaxSeqMap := make(map[string]int64)
for _, conversation := range conversations { for _, conversation := range conversations {
if conversation.MaxSeq != 0 { if conversation.MaxSeq != 0 {
conversationMaxSeqMap[conversation.ConversationID] = conversation.MaxSeq conversationMaxSeqMap[conversation.ConversationID] = conversation.MaxSeq

@ -36,6 +36,7 @@ type LockerMessage struct {
func NewLockerMessage(cache cache.MsgModel) *LockerMessage { func NewLockerMessage(cache cache.MsgModel) *LockerMessage {
return &LockerMessage{cache: cache} return &LockerMessage{cache: cache}
} }
func (l *LockerMessage) LockMessageTypeKey(ctx context.Context, clientMsgID, typeKey string) (err error) { func (l *LockerMessage) LockMessageTypeKey(ctx context.Context, clientMsgID, typeKey string) (err error) {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
err = l.cache.LockMessageTypeKey(ctx, clientMsgID, typeKey) err = l.cache.LockMessageTypeKey(ctx, clientMsgID, typeKey)
@ -47,8 +48,8 @@ func (l *LockerMessage) LockMessageTypeKey(ctx context.Context, clientMsgID, typ
} }
} }
return err return err
} }
func (l *LockerMessage) LockGlobalMessage(ctx context.Context, clientMsgID string) (err error) { func (l *LockerMessage) LockGlobalMessage(ctx context.Context, clientMsgID string) (err error) {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
err = l.cache.LockMessageTypeKey(ctx, clientMsgID, GlOBALLOCK) err = l.cache.LockMessageTypeKey(ctx, clientMsgID, GlOBALLOCK)
@ -60,11 +61,12 @@ func (l *LockerMessage) LockGlobalMessage(ctx context.Context, clientMsgID strin
} }
} }
return err return err
} }
func (l *LockerMessage) UnLockMessageTypeKey(ctx context.Context, clientMsgID string, typeKey string) error { func (l *LockerMessage) UnLockMessageTypeKey(ctx context.Context, clientMsgID string, typeKey string) error {
return l.cache.UnLockMessageTypeKey(ctx, clientMsgID, typeKey) return l.cache.UnLockMessageTypeKey(ctx, clientMsgID, typeKey)
} }
func (l *LockerMessage) UnLockGlobalMessage(ctx context.Context, clientMsgID string) error { func (l *LockerMessage) UnLockGlobalMessage(ctx context.Context, clientMsgID string) error {
return l.cache.UnLockMessageTypeKey(ctx, clientMsgID, GlOBALLOCK) return l.cache.UnLockMessageTypeKey(ctx, clientMsgID, GlOBALLOCK)
} }

@ -84,6 +84,7 @@ func (m *msgServer) sendMsgSuperGroupChat(
resp.ClientMsgID = req.MsgData.ClientMsgID resp.ClientMsgID = req.MsgData.ClientMsgID
return resp, nil return resp, nil
} }
func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgData) { func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgData) {
log.ZDebug(nctx, "setConversationAtInfo", "msg", msg) log.ZDebug(nctx, "setConversationAtInfo", "msg", msg)
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx)) ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
@ -123,7 +124,6 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
log.ZWarn(ctx, "SetConversations", err, msg.AtUserIDList, conversation) log.ZWarn(ctx, "SetConversations", err, msg.AtUserIDList, conversation)
} }
} }
} }
func (m *msgServer) sendMsgNotification( func (m *msgServer) sendMsgNotification(

@ -16,6 +16,7 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -32,8 +33,9 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type MessageInterceptorChain []MessageInterceptorFunc type (
type msgServer struct { MessageInterceptorChain []MessageInterceptorFunc
msgServer struct {
RegisterCenter discoveryregistry.SvcDiscoveryRegistry RegisterCenter discoveryregistry.SvcDiscoveryRegistry
MsgDatabase controller.CommonMsgDatabase MsgDatabase controller.CommonMsgDatabase
Group *rpcclient.GroupRpcClient Group *rpcclient.GroupRpcClient
@ -46,6 +48,7 @@ type msgServer struct {
Handlers MessageInterceptorChain Handlers MessageInterceptorChain
notificationSender *rpcclient.NotificationSender notificationSender *rpcclient.NotificationSender
} }
)
func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) { func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) {
m.Handlers = append(m.Handlers, interceptorFunc...) m.Handlers = append(m.Handlers, interceptorFunc...)

@ -16,15 +16,24 @@ package msg
import ( import (
"context" "context"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"time"
) )
func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) { func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) {
msgCount, userCount, users, dateCount, err := m.MsgDatabase.RangeUserSendCount(ctx, time.UnixMilli(req.Start), time.UnixMilli(req.End), req.Group, req.Ase, req.Pagination.PageNumber, req.Pagination.ShowNumber) msgCount, userCount, users, dateCount, err := m.MsgDatabase.RangeUserSendCount(
ctx,
time.UnixMilli(req.Start),
time.UnixMilli(req.End),
req.Group,
req.Ase,
req.Pagination.PageNumber,
req.Pagination.ShowNumber,
)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -59,7 +68,14 @@ func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq
} }
func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupReq) (*msg.GetActiveGroupResp, error) { func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupReq) (*msg.GetActiveGroupResp, error) {
msgCount, groupCount, groups, dateCount, err := m.MsgDatabase.RangeGroupSendCount(ctx, time.UnixMilli(req.Start), time.UnixMilli(req.End), req.Ase, req.Pagination.PageNumber, req.Pagination.ShowNumber) msgCount, groupCount, groups, dateCount, err := m.MsgDatabase.RangeGroupSendCount(
ctx,
time.UnixMilli(req.Start),
time.UnixMilli(req.End),
req.Ase,
req.Pagination.PageNumber,
req.Pagination.ShowNumber,
)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -16,6 +16,7 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"

@ -28,9 +28,7 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
) )
var ( var ExcludeContentType = []int{constant.HasReadReceipt}
ExcludeContentType = []int{constant.HasReadReceipt}
)
type Validator interface { type Validator interface {
validate(pb *msg.SendMsgReq) (bool, int32, string) validate(pb *msg.SendMsgReq) (bool, int32, string)
@ -126,6 +124,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
return nil return nil
} }
} }
func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) {
msg.ServerMsgID = GetMsgID(msg.SendID) msg.ServerMsgID = GetMsgID(msg.SendID)
msg.SendTime = utils.GetCurrentTimestampByMill() msg.SendTime = utils.GetCurrentTimestampByMill()

@ -16,6 +16,8 @@ package third
import ( import (
"context" "context"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@ -23,7 +25,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"time"
) )
func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) { func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) {

@ -17,12 +17,15 @@ package third
import ( import (
"context" "context"
"fmt" "fmt"
"net/url"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cos" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cos"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/minio" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/minio"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/oss" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/oss"
"net/url"
"time" "google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@ -32,7 +35,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"google.golang.org/grpc"
) )
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {

@ -18,12 +18,13 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"strings"
"unicode/utf8"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"strings"
"unicode/utf8"
) )
func toPbMapArray(m map[string][]string) []*third.KeyValues { func toPbMapArray(m map[string][]string) []*third.KeyValues {

@ -38,8 +38,9 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
) )
type userServer struct { type userServer struct {

@ -33,7 +33,18 @@ func (c *MsgTool) ConversationsDestructMsgs() {
} }
log.ZDebug(context.Background(), "nums conversations need destruct", "nums", len(conversations)) log.ZDebug(context.Background(), "nums conversations need destruct", "nums", len(conversations))
for _, conversation := range conversations { for _, conversation := range conversations {
log.ZDebug(ctx, "UserMsgsDestruct", "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID, "msgDestructTime", conversation.MsgDestructTime, "lastMsgDestructTime", conversation.LatestMsgDestructTime) log.ZDebug(
ctx,
"UserMsgsDestruct",
"conversationID",
conversation.ConversationID,
"ownerUserID",
conversation.OwnerUserID,
"msgDestructTime",
conversation.MsgDestructTime,
"lastMsgDestructTime",
conversation.LatestMsgDestructTime,
)
seqs, err := c.msgDatabase.UserMsgsDestruct(ctx, conversation.OwnerUserID, conversation.ConversationID, conversation.MsgDestructTime, conversation.LatestMsgDestructTime) seqs, err := c.msgDatabase.UserMsgsDestruct(ctx, conversation.OwnerUserID, conversation.ConversationID, conversation.MsgDestructTime, conversation.LatestMsgDestructTime)
if err != nil { if err != nil {
log.ZError(ctx, "user msg destruct failed", err, "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID) log.ZError(ctx, "user msg destruct failed", err, "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID)

@ -20,6 +20,10 @@ import (
"math" "math"
"time" "time"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@ -34,9 +38,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
) )
type MsgTool struct { type MsgTool struct {
@ -48,7 +49,8 @@ type MsgTool struct {
} }
func NewMsgTool(msgDatabase controller.CommonMsgDatabase, userDatabase controller.UserDatabase, func NewMsgTool(msgDatabase controller.CommonMsgDatabase, userDatabase controller.UserDatabase,
groupDatabase controller.GroupDatabase, conversationDatabase controller.ConversationDatabase, msgNotificationSender *notification.MsgNotificationSender) *MsgTool { groupDatabase controller.GroupDatabase, conversationDatabase controller.ConversationDatabase, msgNotificationSender *notification.MsgNotificationSender,
) *MsgTool {
return &MsgTool{ return &MsgTool{
msgDatabase: msgDatabase, msgDatabase: msgDatabase,
userDatabase: userDatabase, userDatabase: userDatabase,
@ -86,7 +88,11 @@ func InitMsgTool() (*MsgTool, error) {
tx.NewGorm(db), tx.NewGorm(db),
) )
groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase()) groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
conversationDatabase := controller.NewConversationDatabase(relation.NewConversationGorm(db), cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)), tx.NewGorm(db)) conversationDatabase := controller.NewConversationDatabase(
relation.NewConversationGorm(db),
cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)),
tx.NewGorm(db),
)
msgRpcClient := rpcclient.NewMessageRpcClient(discov) msgRpcClient := rpcclient.NewMessageRpcClient(discov)
msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRpcClient(&msgRpcClient)) msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRpcClient(&msgRpcClient))
msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase, msgNotificationSender) msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase, msgNotificationSender)

@ -16,7 +16,7 @@ package cmd
import ( import (
"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway" "github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
//"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway" //"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway".
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"

@ -31,7 +31,7 @@ type CallBackConfig struct {
type NotificationConf struct { type NotificationConf struct {
IsSendMsg bool `yaml:"isSendMsg"` IsSendMsg bool `yaml:"isSendMsg"`
ReliabilityLevel int `yaml:"reliabilityLevel"` // 1 online 2 presistent ReliabilityLevel int `yaml:"reliabilityLevel"` // 1 online 2 persistent
UnreadCount bool `yaml:"unreadCount"` UnreadCount bool `yaml:"unreadCount"`
OfflinePush POfflinePush `yaml:"offlinePush"` OfflinePush POfflinePush `yaml:"offlinePush"`
} }

@ -30,7 +30,7 @@ import (
var ( var (
_, b, _, _ = runtime.Caller(0) _, b, _, _ = runtime.Caller(0)
// Root folder of this project // Root folder of this project.
Root = filepath.Join(filepath.Dir(b), "../../..") Root = filepath.Join(filepath.Dir(b), "../../..")
) )

@ -15,7 +15,7 @@
package constant package constant
// fixme 1<--->IOS 2<--->Android 3<--->Windows // fixme 1<--->IOS 2<--->Android 3<--->Windows
// fixme 4<--->OSX 5<--->Web 6<--->MiniWeb 7<--->Linux // fixme 4<--->OSX 5<--->Web 6<--->MiniWeb 7<--->Linux.
const ( const (
// Platform ID. // Platform ID.
IOSPlatformID = 1 IOSPlatformID = 1

@ -54,7 +54,6 @@ func MsgPb2DB(msg *sdkws.MsgData) *unrelation.MsgDataModel {
msgDataModel.AttachedInfo = msg.AttachedInfo msgDataModel.AttachedInfo = msg.AttachedInfo
msgDataModel.Ex = msg.Ex msgDataModel.Ex = msg.Ex
return &msgDataModel return &msgDataModel
} }
func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData { func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {

@ -29,7 +29,7 @@ const (
blackExpireTime = time.Second * 60 * 60 * 12 blackExpireTime = time.Second * 60 * 60 * 12
) )
// args fn will exec when no data in msgCache // args fn will exec when no data in msgCache.
type BlackCache interface { type BlackCache interface {
// get blackIDs from msgCache // get blackIDs from msgCache
metaCache metaCache

@ -41,7 +41,7 @@ const (
conversationExpireTime = time.Second * 60 * 60 * 12 conversationExpireTime = time.Second * 60 * 60 * 12
) )
// arg fn will exec when no data in msgCache // arg fn will exec when no data in msgCache.
type ConversationCache interface { type ConversationCache interface {
metaCache metaCache
NewCache() ConversationCache NewCache() ConversationCache

@ -32,7 +32,7 @@ const (
friendKey = "FRIEND_INFO:" friendKey = "FRIEND_INFO:"
) )
// args fn will exec when no data in msgCache // args fn will exec when no data in msgCache.
type FriendCache interface { type FriendCache interface {
metaCache metaCache
NewCache() FriendCache NewCache() FriendCache
@ -109,7 +109,7 @@ func (f *FriendCacheRedis) DelFriendIDs(ownerUserID ...string) FriendCache {
return new return new
} }
// todo // todo.
func (f *FriendCacheRedis) GetTwoWayFriendIDs( func (f *FriendCacheRedis) GetTwoWayFriendIDs(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,

@ -106,7 +106,8 @@ func NewGroupCacheRedis(
opts rockscache.Options, opts rockscache.Options,
) GroupCache { ) GroupCache {
rcClient := rockscache.NewClient(rdb, opts) rcClient := rockscache.NewClient(rdb, opts)
return &GroupCacheRedis{rcClient: rcClient, expireTime: groupExpireTime, return &GroupCacheRedis{
rcClient: rcClient, expireTime: groupExpireTime,
groupDB: groupDB, groupMemberDB: groupMemberDB, groupRequestDB: groupRequestDB, groupDB: groupDB, groupMemberDB: groupMemberDB, groupRequestDB: groupRequestDB,
mongoDB: mongoClient, metaCache: NewMetaCacheRedis(rcClient), mongoDB: mongoClient, metaCache: NewMetaCacheRedis(rcClient),
} }
@ -176,7 +177,7 @@ func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationTb.GroupMembe
return 0, errIndex return 0, errIndex
} }
// / groupInfo // / groupInfo.
func (g *GroupCacheRedis) GetGroupsInfo( func (g *GroupCacheRedis) GetGroupsInfo(
ctx context.Context, ctx context.Context,
groupIDs []string, groupIDs []string,
@ -265,7 +266,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
) )
} }
// userJoinSuperGroup // userJoinSuperGroup.
func (g *GroupCacheRedis) DelJoinedSuperGroupIDs(userIDs ...string) GroupCache { func (g *GroupCacheRedis) DelJoinedSuperGroupIDs(userIDs ...string) GroupCache {
new := g.NewCache() new := g.NewCache()
var keys []string var keys []string
@ -286,7 +287,7 @@ func (g *GroupCacheRedis) DelSuperGroupMemberIDs(groupIDs ...string) GroupCache
return new return new
} }
// groupMembersHash // groupMembersHash.
func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error) { func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error) {
return getCache( return getCache(
ctx, ctx,
@ -331,7 +332,7 @@ func (g *GroupCacheRedis) DelGroupMembersHash(groupID string) GroupCache {
return cache return cache
} }
// groupMemberIDs // groupMemberIDs.
func (g *GroupCacheRedis) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) { func (g *GroupCacheRedis) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) {
return getCache( return getCache(
ctx, ctx,

@ -31,7 +31,7 @@ const (
maxRetry = 10 // number of retries maxRetry = 10 // number of retries
) )
// NewRedis Initialize redis connection // NewRedis Initialize redis connection.
func NewRedis() (redis.UniversalClient, error) { func NewRedis() (redis.UniversalClient, error) {
if len(config.Config.Redis.Address) == 0 { if len(config.Config.Redis.Address) == 0 {
return nil, errors.New("redis address is empty") return nil, errors.New("redis address is empty")

@ -16,8 +16,9 @@ package cache
import ( import (
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"testing" "testing"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
) )
// TestNewRedis Test redis connection // TestNewRedis Test redis connection

@ -212,6 +212,7 @@ func (c *msgCache) GetMaxSeqs(ctx context.Context, conversationIDs []string) (m
func (c *msgCache) GetMaxSeq(ctx context.Context, conversationID string) (int64, error) { func (c *msgCache) GetMaxSeq(ctx context.Context, conversationID string) (int64, error) {
return c.getSeq(ctx, conversationID, c.getMaxSeqKey) return c.getSeq(ctx, conversationID, c.getMaxSeqKey)
} }
func (c *msgCache) SetMinSeq(ctx context.Context, conversationID string, minSeq int64) error { func (c *msgCache) SetMinSeq(ctx context.Context, conversationID string, minSeq int64) error {
return c.setSeq(ctx, conversationID, minSeq, c.getMinSeqKey) return c.setSeq(ctx, conversationID, minSeq, c.getMinSeqKey)
} }
@ -235,6 +236,7 @@ func (c *msgCache) SetMinSeqs(ctx context.Context, seqs map[string]int64) error
func (c *msgCache) GetMinSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { func (c *msgCache) GetMinSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
return c.getSeqs(ctx, conversationIDs, c.getMinSeqKey) return c.getSeqs(ctx, conversationIDs, c.getMinSeqKey)
} }
func (c *msgCache) GetMinSeq(ctx context.Context, conversationID string) (int64, error) { func (c *msgCache) GetMinSeq(ctx context.Context, conversationID string) (int64, error) {
return c.getSeq(ctx, conversationID, c.getMinSeqKey) return c.getSeq(ctx, conversationID, c.getMinSeqKey)
} }

@ -43,7 +43,7 @@ func NewAuthDatabase(cache cache.MsgModel, accessSecret string, accessExpire int
return &authDatabase{cache: cache, accessSecret: accessSecret, accessExpire: accessExpire} return &authDatabase{cache: cache, accessSecret: accessSecret, accessExpire: accessExpire}
} }
// 结果为空 不返回错误 // 结果为空 不返回错误.
func (a *authDatabase) GetTokensWithoutError( func (a *authDatabase) GetTokensWithoutError(
ctx context.Context, ctx context.Context,
userID string, userID string,
@ -52,7 +52,7 @@ func (a *authDatabase) GetTokensWithoutError(
return a.cache.GetTokensWithoutError(ctx, userID, platformID) return a.cache.GetTokensWithoutError(ctx, userID, platformID)
} }
// 创建token // 创建token.
func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformID int) (string, error) { func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformID int) (string, error) {
tokens, err := a.cache.GetTokensWithoutError(ctx, userID, platformID) tokens, err := a.cache.GetTokensWithoutError(ctx, userID, platformID)
if err != nil { if err != nil {

@ -48,7 +48,7 @@ func NewBlackDatabase(black relation.BlackModelInterface, cache cache.BlackCache
return &blackDatabase{black, cache} return &blackDatabase{black, cache}
} }
// Create 增加黑名单 // Create 增加黑名单.
func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) { func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
if err := b.black.Create(ctx, blacks); err != nil { if err := b.black.Create(ctx, blacks); err != nil {
return err return err
@ -56,7 +56,7 @@ func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackMode
return b.deleteBlackIDsCache(ctx, blacks) return b.deleteBlackIDsCache(ctx, blacks)
} }
// Delete 删除黑名单 // Delete 删除黑名单.
func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) { func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
if err := b.black.Delete(ctx, blacks); err != nil { if err := b.black.Delete(ctx, blacks); err != nil {
return err return err
@ -72,7 +72,7 @@ func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relat
return cache.ExecDel(ctx) return cache.ExecDel(ctx)
} }
// FindOwnerBlacks 获取黑名单列表 // FindOwnerBlacks 获取黑名单列表.
func (b *blackDatabase) FindOwnerBlacks( func (b *blackDatabase) FindOwnerBlacks(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -81,7 +81,7 @@ func (b *blackDatabase) FindOwnerBlacks(
return b.black.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber) return b.black.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
} }
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true) // CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true).
func (b *blackDatabase) CheckIn( func (b *blackDatabase) CheckIn(
ctx context.Context, ctx context.Context,
userID1, userID2 string, userID1, userID2 string,

@ -98,7 +98,6 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
temp.OwnerUserID = v temp.OwnerUserID = v
temp.CreateTime = now temp.CreateTime = now
conversations = append(conversations, temp) conversations = append(conversations, temp)
} }
if len(conversations) > 0 { if len(conversations) > 0 {
err = conversationTx.Create(ctx, conversations) err = conversationTx.Create(ctx, conversations)

@ -93,7 +93,7 @@ func NewFriendDatabase(
return &friendDatabase{friend: friend, friendRequest: friendRequest, cache: cache, tx: tx} return &friendDatabase{friend: friend, friendRequest: friendRequest, cache: cache, tx: tx}
} }
// ok 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) // ok 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true).
func (f *friendDatabase) CheckIn( func (f *friendDatabase) CheckIn(
ctx context.Context, ctx context.Context,
userID1, userID2 string, userID1, userID2 string,
@ -109,7 +109,7 @@ func (f *friendDatabase) CheckIn(
return utils.IsContain(userID2, userID1FriendIDs), utils.IsContain(userID1, userID2FriendIDs), nil return utils.IsContain(userID2, userID1FriendIDs), utils.IsContain(userID1, userID2FriendIDs), nil
} }
// 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增 // 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增.
func (f *friendDatabase) AddFriendRequest( func (f *friendDatabase) AddFriendRequest(
ctx context.Context, ctx context.Context,
fromUserID, toUserID string, fromUserID, toUserID string,
@ -143,7 +143,7 @@ func (f *friendDatabase) AddFriendRequest(
}) })
} }
// (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可 // (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可.
func (f *friendDatabase) BecomeFriends( func (f *friendDatabase) BecomeFriends(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -194,7 +194,7 @@ func (f *friendDatabase) BecomeFriends(
return cache.ExecDel(ctx) return cache.ExecDel(ctx)
} }
// 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝 // 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝.
func (f *friendDatabase) RefuseFriendRequest( func (f *friendDatabase) RefuseFriendRequest(
ctx context.Context, ctx context.Context,
friendRequest *relation.FriendRequestModel, friendRequest *relation.FriendRequestModel,
@ -215,7 +215,7 @@ func (f *friendDatabase) RefuseFriendRequest(
return nil return nil
} }
// AgreeFriendRequest 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 建立双向好友关系(存在的忽略) // AgreeFriendRequest 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 建立双向好友关系(存在的忽略).
func (f *friendDatabase) AgreeFriendRequest( func (f *friendDatabase) AgreeFriendRequest(
ctx context.Context, ctx context.Context,
friendRequest *relation.FriendRequestModel, friendRequest *relation.FriendRequestModel,
@ -289,7 +289,7 @@ func (f *friendDatabase) AgreeFriendRequest(
}) })
} }
// 删除好友 外部判断是否好友关系 // 删除好友 外部判断是否好友关系.
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) {
if err := f.friend.Delete(ctx, ownerUserID, friendUserIDs); err != nil { if err := f.friend.Delete(ctx, ownerUserID, friendUserIDs); err != nil {
return err return err
@ -297,7 +297,7 @@ func (f *friendDatabase) Delete(ctx context.Context, ownerUserID string, friendU
return f.cache.DelFriendIDs(append(friendUserIDs, ownerUserID)...).ExecDel(ctx) return f.cache.DelFriendIDs(append(friendUserIDs, ownerUserID)...).ExecDel(ctx)
} }
// 更新好友备注 零值也支持 // 更新好友备注 零值也支持.
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) {
if err := f.friend.UpdateRemark(ctx, ownerUserID, friendUserID, remark); err != nil { if err := f.friend.UpdateRemark(ctx, ownerUserID, friendUserID, remark); err != nil {
return err return err
@ -305,7 +305,7 @@ func (f *friendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
return f.cache.DelFriend(ownerUserID, friendUserID).ExecDel(ctx) return f.cache.DelFriend(ownerUserID, friendUserID).ExecDel(ctx)
} }
// 获取ownerUserID的好友列表 无结果不返回错误 // 获取ownerUserID的好友列表 无结果不返回错误.
func (f *friendDatabase) PageOwnerFriends( func (f *friendDatabase) PageOwnerFriends(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -314,7 +314,7 @@ func (f *friendDatabase) PageOwnerFriends(
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber) return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
} }
// friendUserID在哪些人的好友列表中 // friendUserID在哪些人的好友列表中.
func (f *friendDatabase) PageInWhoseFriends( func (f *friendDatabase) PageInWhoseFriends(
ctx context.Context, ctx context.Context,
friendUserID string, friendUserID string,
@ -323,7 +323,7 @@ func (f *friendDatabase) PageInWhoseFriends(
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber) return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
} }
// 获取我发出去的好友申请 无结果不返回错误 // 获取我发出去的好友申请 无结果不返回错误.
func (f *friendDatabase) PageFriendRequestFromMe( func (f *friendDatabase) PageFriendRequestFromMe(
ctx context.Context, ctx context.Context,
userID string, userID string,
@ -332,7 +332,7 @@ func (f *friendDatabase) PageFriendRequestFromMe(
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber) return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
} }
// 获取我收到的的好友申请 无结果不返回错误 // 获取我收到的的好友申请 无结果不返回错误.
func (f *friendDatabase) PageFriendRequestToMe( func (f *friendDatabase) PageFriendRequestToMe(
ctx context.Context, ctx context.Context,
userID string, userID string,
@ -341,7 +341,7 @@ func (f *friendDatabase) PageFriendRequestToMe(
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber) return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
} }
// 获取某人指定好友的信息 如果有好友不存在,也返回错误 // 获取某人指定好友的信息 如果有好友不存在,也返回错误.
func (f *friendDatabase) FindFriendsWithError( func (f *friendDatabase) FindFriendsWithError(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,

@ -203,7 +203,7 @@ func (g *groupDatabase) CreateGroup(
groups []*relationTb.GroupModel, groups []*relationTb.GroupModel,
groupMembers []*relationTb.GroupMemberModel, groupMembers []*relationTb.GroupMemberModel,
) error { ) error {
var cache = g.cache.NewCache() cache := g.cache.NewCache()
if err := g.tx.Transaction(func(tx any) error { if err := g.tx.Transaction(func(tx any) error {
if len(groups) > 0 { if len(groups) > 0 {
if err := g.groupDB.NewTx(tx).Create(ctx, groups); err != nil { if err := g.groupDB.NewTx(tx).Create(ctx, groups); err != nil {
@ -473,7 +473,7 @@ func (g *groupDatabase) UpdateGroupMember(
} }
func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error { func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error {
var cache = g.cache.NewCache() cache := g.cache.NewCache()
if err := g.tx.Transaction(func(tx any) error { if err := g.tx.Transaction(func(tx any) error {
for _, item := range data { for _, item := range data {
if err := g.groupMemberDB.NewTx(tx).Update(ctx, item.GroupID, item.UserID, item.Map); err != nil { if err := g.groupMemberDB.NewTx(tx).Update(ctx, item.GroupID, item.UserID, item.Map); err != nil {

@ -15,10 +15,14 @@
package controller package controller
import ( import (
"context"
"errors"
"time"
"gorm.io/gorm"
relation2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" relation2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"gorm.io/gorm"
"time"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
@ -32,13 +36,11 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"context" "go.mongodb.org/mongo-driver/mongo"
"errors"
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"go.mongodb.org/mongo-driver/mongo"
) )
const ( const (
@ -103,8 +105,23 @@ type CommonMsgDatabase interface {
MsgToPushMQ(ctx context.Context, key, conversarionID string, msg2mq *sdkws.MsgData) (int32, int64, error) MsgToPushMQ(ctx context.Context, key, conversarionID string, msg2mq *sdkws.MsgData) (int32, int64, error)
MsgToMongoMQ(ctx context.Context, key, conversarionID string, msgs []*sdkws.MsgData, lastSeq int64) error MsgToMongoMQ(ctx context.Context, key, conversarionID string, msgs []*sdkws.MsgData, lastSeq int64) error
RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) RangeUserSendCount(
RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) ctx context.Context,
start time.Time,
end time.Time,
group bool,
ase bool,
pageNumber int32,
showNumber int32,
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error)
RangeGroupSendCount(
ctx context.Context,
start time.Time,
end time.Time,
ase bool,
pageNumber int32,
showNumber int32,
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error)
} }
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel, msgMyqModel relation.ChatLogModelInterface) CommonMsgDatabase { func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel, msgMyqModel relation.ChatLogModelInterface) CommonMsgDatabase {
@ -575,7 +592,22 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co
log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID) log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID)
} }
} }
log.ZInfo(ctx, "db.cache.GetMessagesBySeq", "userID", userID, "conversationID", conversationID, "seqs", seqs, "successMsgs", len(successMsgs), "failedSeqs", failedSeqs, "conversationID", conversationID) log.ZInfo(
ctx,
"db.cache.GetMessagesBySeq",
"userID",
userID,
"conversationID",
conversationID,
"seqs",
seqs,
"successMsgs",
len(successMsgs),
"failedSeqs",
failedSeqs,
"conversationID",
conversationID,
)
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs)) prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
if len(failedSeqs) > 0 { if len(failedSeqs) > 0 {
mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs) mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs)
@ -637,7 +669,6 @@ func (db *commonMsgDatabase) UserMsgsDestruct(ctx context.Context, userID string
log.ZDebug(ctx, "deleteMsgRecursion finished", "conversationID", conversationID, "userID", userID, "index", index) log.ZDebug(ctx, "deleteMsgRecursion finished", "conversationID", conversationID, "userID", userID, "index", index)
break break
} }
} }
} }
} }
@ -652,7 +683,7 @@ func (db *commonMsgDatabase) UserMsgsDestruct(ctx context.Context, userID string
return seqs, nil return seqs, nil
} }
// this is struct for recursion // this is struct for recursion.
type delMsgRecursionStruct struct { type delMsgRecursionStruct struct {
minSeq int64 minSeq int64
delDocIDs []string delDocIDs []string
@ -665,7 +696,7 @@ func (d *delMsgRecursionStruct) getSetMinSeq() int64 {
// index 0....19(del) 20...69 // index 0....19(del) 20...69
// seq 70 // seq 70
// set minSeq 21 // set minSeq 21
// recursion 删除list并且返回设置的最小seq // recursion 删除list并且返回设置的最小seq.
func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversationID string, index int64, delStruct *delMsgRecursionStruct, remainTime int64) (int64, error) { func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversationID string, index int64, delStruct *delMsgRecursionStruct, remainTime int64) (int64, error) {
// find from oldest list // find from oldest list
msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1) msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
@ -791,15 +822,19 @@ func (db *commonMsgDatabase) CleanUpUserConversationsMsgs(ctx context.Context, u
func (db *commonMsgDatabase) SetMaxSeq(ctx context.Context, conversationID string, maxSeq int64) error { func (db *commonMsgDatabase) SetMaxSeq(ctx context.Context, conversationID string, maxSeq int64) error {
return db.cache.SetMaxSeq(ctx, conversationID, maxSeq) return db.cache.SetMaxSeq(ctx, conversationID, maxSeq)
} }
func (db *commonMsgDatabase) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { func (db *commonMsgDatabase) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
return db.cache.GetMaxSeqs(ctx, conversationIDs) return db.cache.GetMaxSeqs(ctx, conversationIDs)
} }
func (db *commonMsgDatabase) GetMaxSeq(ctx context.Context, conversationID string) (int64, error) { func (db *commonMsgDatabase) GetMaxSeq(ctx context.Context, conversationID string) (int64, error) {
return db.cache.GetMaxSeq(ctx, conversationID) return db.cache.GetMaxSeq(ctx, conversationID)
} }
func (db *commonMsgDatabase) SetMinSeq(ctx context.Context, conversationID string, minSeq int64) error { func (db *commonMsgDatabase) SetMinSeq(ctx context.Context, conversationID string, minSeq int64) error {
return db.cache.SetMinSeq(ctx, conversationID, minSeq) return db.cache.SetMinSeq(ctx, conversationID, minSeq)
} }
func (db *commonMsgDatabase) SetMinSeqs(ctx context.Context, seqs map[string]int64) error { func (db *commonMsgDatabase) SetMinSeqs(ctx context.Context, seqs map[string]int64) error {
return db.cache.SetMinSeqs(ctx, seqs) return db.cache.SetMinSeqs(ctx, seqs)
} }
@ -807,18 +842,23 @@ func (db *commonMsgDatabase) SetMinSeqs(ctx context.Context, seqs map[string]int
func (db *commonMsgDatabase) GetMinSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { func (db *commonMsgDatabase) GetMinSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
return db.cache.GetMinSeqs(ctx, conversationIDs) return db.cache.GetMinSeqs(ctx, conversationIDs)
} }
func (db *commonMsgDatabase) GetMinSeq(ctx context.Context, conversationID string) (int64, error) { func (db *commonMsgDatabase) GetMinSeq(ctx context.Context, conversationID string) (int64, error) {
return db.cache.GetMinSeq(ctx, conversationID) return db.cache.GetMinSeq(ctx, conversationID)
} }
func (db *commonMsgDatabase) GetConversationUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) { func (db *commonMsgDatabase) GetConversationUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) {
return db.cache.GetConversationUserMinSeq(ctx, conversationID, userID) return db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
} }
func (db *commonMsgDatabase) GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (map[string]int64, error) { func (db *commonMsgDatabase) GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (map[string]int64, error) {
return db.cache.GetConversationUserMinSeqs(ctx, conversationID, userIDs) return db.cache.GetConversationUserMinSeqs(ctx, conversationID, userIDs)
} }
func (db *commonMsgDatabase) SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error { func (db *commonMsgDatabase) SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error {
return db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, minSeq) return db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, minSeq)
} }
func (db *commonMsgDatabase) SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error) { func (db *commonMsgDatabase) SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error) {
return db.cache.SetConversationUserMinSeqs(ctx, conversationID, seqs) return db.cache.SetConversationUserMinSeqs(ctx, conversationID, seqs)
} }
@ -834,6 +874,7 @@ func (db *commonMsgDatabase) UserSetHasReadSeqs(ctx context.Context, userID stri
func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error { func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error {
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq) return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
} }
func (db *commonMsgDatabase) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) { func (db *commonMsgDatabase) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
return db.cache.GetHasReadSeqs(ctx, userID, conversationIDs) return db.cache.GetHasReadSeqs(ctx, userID, conversationIDs)
} }
@ -884,11 +925,26 @@ func (db *commonMsgDatabase) GetMinMaxSeqMongo(ctx context.Context, conversation
return return
} }
func (db *commonMsgDatabase) RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) { func (db *commonMsgDatabase) RangeUserSendCount(
ctx context.Context,
start time.Time,
end time.Time,
group bool,
ase bool,
pageNumber int32,
showNumber int32,
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) {
return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber) return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber)
} }
func (db *commonMsgDatabase) RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) { func (db *commonMsgDatabase) RangeGroupSendCount(
ctx context.Context,
start time.Time,
end time.Time,
ase bool,
pageNumber int32,
showNumber int32,
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) {
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber) return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
} }

@ -16,11 +16,12 @@ package controller
import ( import (
"context" "context"
"path/filepath"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"path/filepath"
"time"
) )
type S3Database interface { type S3Database interface {

@ -75,7 +75,7 @@ func (u *userDatabase) InitOnce(ctx context.Context, users []*relation.UserModel
return nil return nil
} }
// 获取指定用户的信息 如有userID未找到 也返回错误 // 获取指定用户的信息 如有userID未找到 也返回错误.
func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) { func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
users, err = u.cache.GetUsersInfo(ctx, userIDs) users, err = u.cache.GetUsersInfo(ctx, userIDs)
if err != nil { if err != nil {
@ -87,13 +87,13 @@ func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (use
return return
} }
// 获取指定用户的信息 如有userID未找到 不返回错误 // 获取指定用户的信息 如有userID未找到 不返回错误.
func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) { func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
users, err = u.cache.GetUsersInfo(ctx, userIDs) users, err = u.cache.GetUsersInfo(ctx, userIDs)
return return
} }
// 插入多条 外部保证userID 不重复 且在db中不存在 // 插入多条 外部保证userID 不重复 且在db中不存在.
func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) { func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) {
if err := u.tx.Transaction(func(tx any) error { if err := u.tx.Transaction(func(tx any) error {
err = u.userDB.Create(ctx, users) err = u.userDB.Create(ctx, users)
@ -111,7 +111,7 @@ func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel)
return u.cache.DelUsersInfo(userIDs...).ExecDel(ctx) return u.cache.DelUsersInfo(userIDs...).ExecDel(ctx)
} }
// 更新(非零值) 外部保证userID存在 // 更新(非零值) 外部保证userID存在.
func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (err error) { func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (err error) {
if err := u.userDB.Update(ctx, user); err != nil { if err := u.userDB.Update(ctx, user); err != nil {
return err return err
@ -119,7 +119,7 @@ func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (er
return u.cache.DelUsersInfo(user.UserID).ExecDel(ctx) return u.cache.DelUsersInfo(user.UserID).ExecDel(ctx)
} }
// 更新(零值) 外部保证userID存在 // 更新(零值) 外部保证userID存在.
func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) { func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
if err := u.userDB.UpdateByMap(ctx, userID, args); err != nil { if err := u.userDB.UpdateByMap(ctx, userID, args); err != nil {
return err return err
@ -127,7 +127,7 @@ func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[
return u.cache.DelUsersInfo(userID).ExecDel(ctx) return u.cache.DelUsersInfo(userID).ExecDel(ctx)
} }
// 获取,如果没找到,不返回错误 // 获取,如果没找到,不返回错误.
func (u *userDatabase) Page( func (u *userDatabase) Page(
ctx context.Context, ctx context.Context,
pageNumber, showNumber int32, pageNumber, showNumber int32,
@ -135,7 +135,7 @@ func (u *userDatabase) Page(
return u.userDB.Page(ctx, pageNumber, showNumber) return u.userDB.Page(ctx, pageNumber, showNumber)
} }
// userIDs是否存在 只要有一个存在就为true // userIDs是否存在 只要有一个存在就为true.
func (u *userDatabase) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) { func (u *userDatabase) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) {
users, err := u.userDB.Find(ctx, userIDs) users, err := u.userDB.Find(ctx, userIDs)
if err != nil { if err != nil {

@ -76,5 +76,4 @@ func (g *ConversationLocalCache) GetConversationIDs(ctx context.Context, userID
return conversationIDsResp.ConversationIDs, nil return conversationIDsResp.ConversationIDs, nil
} }
return hash.ids, nil return hash.ids, nil
} }

@ -35,12 +35,12 @@ func (f *FriendGorm) NewTx(tx any) relation.FriendModelInterface {
return &FriendGorm{NewMetaDB(tx.(*gorm.DB), &relation.FriendModel{})} return &FriendGorm{NewMetaDB(tx.(*gorm.DB), &relation.FriendModel{})}
} }
// 插入多条记录 // 插入多条记录.
func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel) (err error) { func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel) (err error) {
return utils.Wrap(f.db(ctx).Create(&friends).Error, "") return utils.Wrap(f.db(ctx).Create(&friends).Error, "")
} }
// 删除ownerUserID指定的好友 // 删除ownerUserID指定的好友.
func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) { func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
err = utils.Wrap( err = utils.Wrap(
f.db(ctx). f.db(ctx).
@ -52,7 +52,7 @@ func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserI
return err return err
} }
// 更新ownerUserID单个好友信息 更新零值 // 更新ownerUserID单个好友信息 更新零值.
func (f *FriendGorm) UpdateByMap( func (f *FriendGorm) UpdateByMap(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -65,12 +65,12 @@ func (f *FriendGorm) UpdateByMap(
) )
} }
// 更新好友信息的非零值 // 更新好友信息的非零值.
func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel) (err error) { func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel) (err error) {
return utils.Wrap(f.db(ctx).Updates(&friends).Error, "") return utils.Wrap(f.db(ctx).Updates(&friends).Error, "")
} }
// 更新好友备注(也支持零值 // 更新好友备注(也支持零值 .
func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) { func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
if remark != "" { if remark != "" {
return utils.Wrap( return utils.Wrap(
@ -86,7 +86,7 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
return utils.Wrap(f.db(ctx).Where("owner_user_id = ?", ownerUserID).Updates(m).Error, "") return utils.Wrap(f.db(ctx).Where("owner_user_id = ?", ownerUserID).Updates(m).Error, "")
} }
// 获取单个好友信息,如没找到 返回错误 // 获取单个好友信息,如没找到 返回错误.
func (f *FriendGorm) Take( func (f *FriendGorm) Take(
ctx context.Context, ctx context.Context,
ownerUserID, friendUserID string, ownerUserID, friendUserID string,
@ -98,7 +98,7 @@ func (f *FriendGorm) Take(
) )
} }
// 查找好友关系,如果是双向关系,则都返回 // 查找好友关系,如果是双向关系,则都返回.
func (f *FriendGorm) FindUserState( func (f *FriendGorm) FindUserState(
ctx context.Context, ctx context.Context,
userID1, userID2 string, userID1, userID2 string,
@ -112,7 +112,7 @@ func (f *FriendGorm) FindUserState(
) )
} }
// 获取 owner指定的好友列表 如果有friendUserIDs不存在也不返回错误 // 获取 owner指定的好友列表 如果有friendUserIDs不存在也不返回错误.
func (f *FriendGorm) FindFriends( func (f *FriendGorm) FindFriends(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -124,7 +124,7 @@ func (f *FriendGorm) FindFriends(
) )
} }
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在也不返回错误 // 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在也不返回错误.
func (f *FriendGorm) FindReversalFriends( func (f *FriendGorm) FindReversalFriends(
ctx context.Context, ctx context.Context,
friendUserID string, friendUserID string,
@ -136,7 +136,7 @@ func (f *FriendGorm) FindReversalFriends(
) )
} }
// 获取ownerUserID好友列表 支持翻页 // 获取ownerUserID好友列表 支持翻页.
func (f *FriendGorm) FindOwnerFriends( func (f *FriendGorm) FindOwnerFriends(
ctx context.Context, ctx context.Context,
ownerUserID string, ownerUserID string,
@ -158,7 +158,7 @@ func (f *FriendGorm) FindOwnerFriends(
return return
} }
// 获取哪些人添加了friendUserID 支持翻页 // 获取哪些人添加了friendUserID 支持翻页.
func (f *FriendGorm) FindInWhoseFriends( func (f *FriendGorm) FindInWhoseFriends(
ctx context.Context, ctx context.Context,
friendUserID string, friendUserID string,

@ -35,12 +35,12 @@ func (f *FriendRequestGorm) NewTx(tx any) relation.FriendRequestModelInterface {
return &FriendRequestGorm{NewMetaDB(tx.(*gorm.DB), &relation.FriendRequestModel{})} return &FriendRequestGorm{NewMetaDB(tx.(*gorm.DB), &relation.FriendRequestModel{})}
} }
// 插入多条记录 // 插入多条记录.
func (f *FriendRequestGorm) Create(ctx context.Context, friendRequests []*relation.FriendRequestModel) (err error) { func (f *FriendRequestGorm) Create(ctx context.Context, friendRequests []*relation.FriendRequestModel) (err error) {
return utils.Wrap(f.db(ctx).Create(&friendRequests).Error, "") return utils.Wrap(f.db(ctx).Create(&friendRequests).Error, "")
} }
// 删除记录 // 删除记录.
func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) { func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) {
return utils.Wrap( return utils.Wrap(
f.db(ctx). f.db(ctx).
@ -51,7 +51,7 @@ func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID str
) )
} }
// 更新零值 // 更新零值.
func (f *FriendRequestGorm) UpdateByMap( func (f *FriendRequestGorm) UpdateByMap(
ctx context.Context, ctx context.Context,
fromUserID string, fromUserID string,
@ -68,7 +68,7 @@ func (f *FriendRequestGorm) UpdateByMap(
) )
} }
// 更新记录 (非零值) // 更新记录 (非零值).
func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
return utils.Wrap( return utils.Wrap(
f.db(ctx). f.db(ctx).
@ -79,7 +79,7 @@ func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.
) )
} }
// 获取来指定用户的好友申请 未找到 不返回错误 // 获取来指定用户的好友申请 未找到 不返回错误.
func (f *FriendRequestGorm) Find( func (f *FriendRequestGorm) Find(
ctx context.Context, ctx context.Context,
fromUserID, toUserID string, fromUserID, toUserID string,
@ -104,7 +104,7 @@ func (f *FriendRequestGorm) Take(
return friendRequest, err return friendRequest, err
} }
// 获取toUserID收到的好友申请列表 // 获取toUserID收到的好友申请列表.
func (f *FriendRequestGorm) FindToUserID( func (f *FriendRequestGorm) FindToUserID(
ctx context.Context, ctx context.Context,
toUserID string, toUserID string,
@ -126,7 +126,7 @@ func (f *FriendRequestGorm) FindToUserID(
return return
} }
// 获取fromUserID发出去的好友申请列表 // 获取fromUserID发出去的好友申请列表.
func (f *FriendRequestGorm) FindFromUserID( func (f *FriendRequestGorm) FindFromUserID(
ctx context.Context, ctx context.Context,
fromUserID string, fromUserID string,

@ -16,9 +16,10 @@ package relation
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"gorm.io/gorm" "gorm.io/gorm"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
@ -67,6 +68,7 @@ func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, show
db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed) db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed)
return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber) return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber)
} }
func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) { func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
return groupIDs, utils.Wrap(g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error, "") return groupIDs, utils.Wrap(g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error, "")
} }

@ -34,7 +34,7 @@ const (
maxRetry = 100 // number of retries maxRetry = 100 // number of retries
) )
// newMysqlGormDB Initialize the database connection // newMysqlGormDB Initialize the database connection.
func newMysqlGormDB() (*gorm.DB, error) { func newMysqlGormDB() (*gorm.DB, error) {
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql") config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql")
@ -84,7 +84,7 @@ func newMysqlGormDB() (*gorm.DB, error) {
return db, nil return db, nil
} }
// connectToDatabase Connection retry for mysql // connectToDatabase Connection retry for mysql.
func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) { func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
var db *gorm.DB var db *gorm.DB
var err error var err error
@ -101,7 +101,7 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
return nil, err return nil, err
} }
// NewGormDB gorm mysql // NewGormDB gorm mysql.
func NewGormDB() (*gorm.DB, error) { func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound) specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey) specialerror.AddErrHandler(replaceDuplicateKey)

@ -34,35 +34,35 @@ func NewUserGorm(db *gorm.DB) relation.UserModelInterface {
return &UserGorm{NewMetaDB(db, &relation.UserModel{})} return &UserGorm{NewMetaDB(db, &relation.UserModel{})}
} }
// 插入多条 // 插入多条.
func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel) (err error) { func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel) (err error) {
return utils.Wrap(u.db(ctx).Create(&users).Error, "") return utils.Wrap(u.db(ctx).Create(&users).Error, "")
} }
// 更新用户信息 零值 // 更新用户信息 零值.
func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) { func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
return utils.Wrap(u.db(ctx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Updates(args).Error, "") return utils.Wrap(u.db(ctx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Updates(args).Error, "")
} }
// 更新多个用户信息 非零值 // 更新多个用户信息 非零值.
func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err error) { func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err error) {
return utils.Wrap(u.db(ctx).Model(user).Updates(user).Error, "") return utils.Wrap(u.db(ctx).Model(user).Updates(user).Error, "")
} }
// 获取指定用户信息 不存在,也不返回错误 // 获取指定用户信息 不存在,也不返回错误.
func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) { func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
err = utils.Wrap(u.db(ctx).Where("user_id in (?)", userIDs).Find(&users).Error, "") err = utils.Wrap(u.db(ctx).Where("user_id in (?)", userIDs).Find(&users).Error, "")
return users, err return users, err
} }
// 获取某个用户信息 不存在,则返回错误 // 获取某个用户信息 不存在,则返回错误.
func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error) { func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error) {
user = &relation.UserModel{} user = &relation.UserModel{}
err = utils.Wrap(u.db(ctx).Where("user_id = ?", userID).Take(&user).Error, "") err = utils.Wrap(u.db(ctx).Where("user_id = ?", userID).Take(&user).Error, "")
return user, err return user, err
} }
// 获取用户信息 不存在,不返回错误 // 获取用户信息 不存在,不返回错误.
func (u *UserGorm) Page( func (u *UserGorm) Page(
ctx context.Context, ctx context.Context,
pageNumber, showNumber int32, pageNumber, showNumber int32,

@ -20,13 +20,15 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/google/uuid"
"path" "path"
"strings" "strings"
"time" "time"
"github.com/google/uuid"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
) )
func New(impl s3.Interface) *Controller { func New(impl s3.Interface) *Controller {

@ -16,6 +16,7 @@ package cont
import ( import (
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
) )

@ -18,14 +18,16 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/tencentyun/cos-go-sdk-v5"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/tencentyun/cos-go-sdk-v5"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
) )
const ( const (

@ -18,16 +18,18 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/signer"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/signer"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
) )
const ( const (

@ -18,14 +18,16 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
) )
const ( const (
@ -146,7 +148,11 @@ func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire
} }
request.Header.Set(oss.HTTPHeaderHost, request.Host) request.Header.Set(oss.HTTPHeaderHost, request.Host)
request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat)) request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat))
authorization := fmt.Sprintf(`OSS %s:%s`, o.credentials.GetAccessKeyID(), o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret())) authorization := fmt.Sprintf(
`OSS %s:%s`,
o.credentials.GetAccessKeyID(),
o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret()),
)
request.Header.Set(oss.HTTPHeaderAuthorization, authorization) request.Header.Set(oss.HTTPHeaderAuthorization, authorization)
result.Parts[i] = s3.SignPart{ result.Parts[i] = s3.SignPart{
PartNumber: partNumber, PartNumber: partNumber,

@ -19,12 +19,13 @@ import (
"crypto/sha1" "crypto/sha1"
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"hash" "hash"
"io" "io"
"net/http" "net/http"
"sort" "sort"
"strings" "strings"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
) )
func (o *OSS) getAdditionalHeaderKeys(req *http.Request) ([]string, map[string]string) { func (o *OSS) getAdditionalHeaderKeys(req *http.Request) ([]string, map[string]string) {

@ -16,10 +16,11 @@ package unrelation
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"strconv" "strconv"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"

@ -39,7 +39,7 @@ type Mongo struct {
db *mongo.Client db *mongo.Client
} }
// NewMongo Initialize MongoDB connection // NewMongo Initialize MongoDB connection.
func NewMongo() (*Mongo, error) { func NewMongo() (*Mongo, error) {
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound) specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"

@ -19,9 +19,10 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
@ -80,7 +81,7 @@ func (m *MsgMongoDriver) UpdateMsg(
return res, nil return res, nil
} }
// PushUnique value must slice // PushUnique value must slice.
func (m *MsgMongoDriver) PushUnique( func (m *MsgMongoDriver) PushUnique(
ctx context.Context, ctx context.Context,
docID string, docID string,
@ -555,7 +556,7 @@ func (m *MsgMongoDriver) MarkSingleChatMsgsAsRead(
// } // }
// } // }
// //
// ]) // ]).
func (m *MsgMongoDriver) RangeUserSendCount( func (m *MsgMongoDriver) RangeUserSendCount(
ctx context.Context, ctx context.Context,
start time.Time, start time.Time,
@ -1081,21 +1082,21 @@ func (m *MsgMongoDriver) SearchMessage(ctx context.Context, req *msg.SearchMessa
func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessageReq) ([]*table.MsgInfoModel, error) { func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessageReq) ([]*table.MsgInfoModel, error) {
var pipe mongo.Pipeline var pipe mongo.Pipeline
conditon := bson.A{} condition := bson.A{}
if req.SendTime != "" { if req.SendTime != "" {
conditon = append(conditon, bson.M{"$eq": bson.A{bson.M{"$dateToString": bson.M{"format": "%Y-%m-%d", "date": bson.M{"$toDate": "$$item.msg.send_time"}}}, req.SendTime}}) condition = append(condition, bson.M{"$eq": bson.A{bson.M{"$dateToString": bson.M{"format": "%Y-%m-%d", "date": bson.M{"$toDate": "$$item.msg.send_time"}}}, req.SendTime}})
} }
if req.MsgType != 0 { if req.MsgType != 0 {
conditon = append(conditon, bson.M{"$eq": bson.A{"$$item.msg.content_type", req.MsgType}}) condition = append(condition, bson.M{"$eq": bson.A{"$$item.msg.content_type", req.MsgType}})
} }
if req.SessionType != 0 { if req.SessionType != 0 {
conditon = append(conditon, bson.M{"$eq": bson.A{"$$item.msg.session_type", req.SessionType}}) condition = append(condition, bson.M{"$eq": bson.A{"$$item.msg.session_type", req.SessionType}})
} }
if req.RecvID != "" { if req.RecvID != "" {
conditon = append(conditon, bson.M{"$regexFind": bson.M{"input": "$$item.msg.recv_id", "regex": req.RecvID}}) condition = append(condition, bson.M{"$regexFind": bson.M{"input": "$$item.msg.recv_id", "regex": req.RecvID}})
} }
if req.SendID != "" { if req.SendID != "" {
conditon = append(conditon, bson.M{"$regexFind": bson.M{"input": "$$item.msg.send_id", "regex": req.SendID}}) condition = append(condition, bson.M{"$regexFind": bson.M{"input": "$$item.msg.send_id", "regex": req.SendID}})
} }
or := bson.A{ or := bson.A{
@ -1131,15 +1132,20 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa
}, },
{ {
{"$project", bson.D{ {"$project", bson.D{
{"msgs", bson.D{ {
{"$filter", bson.D{ "msgs", bson.D{
{
"$filter", bson.D{
{"input", "$msgs"}, {"input", "$msgs"},
{"as", "item"}, {"as", "item"},
{"cond", bson.D{ {
{"$and", conditon}, "cond", bson.D{
{"$and", condition},
},
},
},
},
}, },
}},
}},
}, },
{"doc_id", 1}, {"doc_id", 1},
}}, }},
@ -1159,7 +1165,7 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa
return nil, errs.Wrap(mongo.ErrNoDocuments) return nil, errs.Wrap(mongo.ErrNoDocuments)
} }
msgs := make([]*table.MsgInfoModel, 0) msgs := make([]*table.MsgInfoModel, 0)
for index, _ := range msgsDocs { for index := range msgsDocs {
for i := range msgsDocs[index].Msg { for i := range msgsDocs[index].Msg {
msg := msgsDocs[index].Msg[i] msg := msgsDocs[index].Msg[i]
if msg == nil || msg.Msg == nil { if msg == nil || msg.Msg == nil {

@ -52,7 +52,6 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []str
func (mc *MConsumerGroup) GetContextFromMsg(cMsg *sarama.ConsumerMessage) context.Context { func (mc *MConsumerGroup) GetContextFromMsg(cMsg *sarama.ConsumerMessage) context.Context {
return GetContextWithMQHeader(cMsg.Headers) return GetContextWithMQHeader(cMsg.Headers)
} }
func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroupHandler) { func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroupHandler) {

@ -17,12 +17,13 @@ package kafka
import ( import (
"context" "context"
"errors" "errors"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
log "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" log "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"time"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@ -43,7 +44,7 @@ type Producer struct {
producer sarama.SyncProducer producer sarama.SyncProducer
} }
// NewKafkaProducer Initialize kafka producer // NewKafkaProducer Initialize kafka producer.
func NewKafkaProducer(addr []string, topic string) *Producer { func NewKafkaProducer(addr []string, topic string) *Producer {
p := Producer{} p := Producer{}
p.config = sarama.NewConfig() // Instantiate a sarama Config p.config = sarama.NewConfig() // Instantiate a sarama Config
@ -92,7 +93,8 @@ func GetMQHeaderWithContext(ctx context.Context) ([]sarama.RecordHeader, error)
{Key: []byte(constant.OperationID), Value: []byte(operationID)}, {Key: []byte(constant.OperationID), Value: []byte(operationID)},
{Key: []byte(constant.OpUserID), Value: []byte(opUserID)}, {Key: []byte(constant.OpUserID), Value: []byte(opUserID)},
{Key: []byte(constant.OpUserPlatform), Value: []byte(platform)}, {Key: []byte(constant.OpUserPlatform), Value: []byte(platform)},
{Key: []byte(constant.ConnID), Value: []byte(connID)}}, err {Key: []byte(constant.ConnID), Value: []byte(connID)},
}, err
} }
func GetContextWithMQHeader(header []*sarama.RecordHeader) context.Context { func GetContextWithMQHeader(header []*sarama.RecordHeader) context.Context {

@ -45,7 +45,7 @@ var (
} }
) )
// InitFromConfig initializes a Zap-based logger // InitFromConfig initializes a Zap-based logger.
func InitFromConfig( func InitFromConfig(
loggerPrefixName, moduleName string, loggerPrefixName, moduleName string,
logLevel int, logLevel int,
@ -183,7 +183,6 @@ func (l *ZapLogger) customCallerEncoder(caller zapcore.EntryCaller, enc zapcore.
// color = _levelToColor[zapcore.ErrorLevel] // color = _levelToColor[zapcore.ErrorLevel]
// } // }
enc.AppendString(s) enc.AppendString(s)
} }
func (l *ZapLogger) timeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { func (l *ZapLogger) timeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {

@ -20,17 +20,17 @@ import (
) )
var ( var (
//auth rpc // auth rpc.
UserLoginCounter prometheus.Counter UserLoginCounter prometheus.Counter
UserRegisterCounter prometheus.Counter UserRegisterCounter prometheus.Counter
//seg // seg.
SeqGetSuccessCounter prometheus.Counter SeqGetSuccessCounter prometheus.Counter
SeqGetFailedCounter prometheus.Counter SeqGetFailedCounter prometheus.Counter
SeqSetSuccessCounter prometheus.Counter SeqSetSuccessCounter prometheus.Counter
SeqSetFailedCounter prometheus.Counter SeqSetFailedCounter prometheus.Counter
//msg-db // msg-db.
MsgInsertRedisSuccessCounter prometheus.Counter MsgInsertRedisSuccessCounter prometheus.Counter
MsgInsertRedisFailedCounter prometheus.Counter MsgInsertRedisFailedCounter prometheus.Counter
MsgInsertMongoSuccessCounter prometheus.Counter MsgInsertMongoSuccessCounter prometheus.Counter
@ -40,7 +40,7 @@ var (
MsgPullFromMongoSuccessCounter prometheus.Counter MsgPullFromMongoSuccessCounter prometheus.Counter
MsgPullFromMongoFailedCounter prometheus.Counter MsgPullFromMongoFailedCounter prometheus.Counter
//msg-ws // msg-ws.
MsgRecvTotalCounter prometheus.Counter MsgRecvTotalCounter prometheus.Counter
GetNewestSeqTotalCounter prometheus.Counter GetNewestSeqTotalCounter prometheus.Counter
PullMsgBySeqListTotalCounter prometheus.Counter PullMsgBySeqListTotalCounter prometheus.Counter
@ -50,7 +50,7 @@ var (
WorkSuperGroupChatMsgRecvSuccessCounter prometheus.Counter WorkSuperGroupChatMsgRecvSuccessCounter prometheus.Counter
OnlineUserGauge prometheus.Gauge OnlineUserGauge prometheus.Gauge
//msg-msg // msg-msg.
SingleChatMsgProcessSuccessCounter prometheus.Counter SingleChatMsgProcessSuccessCounter prometheus.Counter
SingleChatMsgProcessFailedCounter prometheus.Counter SingleChatMsgProcessFailedCounter prometheus.Counter
GroupChatMsgProcessSuccessCounter prometheus.Counter GroupChatMsgProcessSuccessCounter prometheus.Counter
@ -58,23 +58,23 @@ var (
WorkSuperGroupChatMsgProcessSuccessCounter prometheus.Counter WorkSuperGroupChatMsgProcessSuccessCounter prometheus.Counter
WorkSuperGroupChatMsgProcessFailedCounter prometheus.Counter WorkSuperGroupChatMsgProcessFailedCounter prometheus.Counter
//msg-push // msg-push.
MsgOnlinePushSuccessCounter prometheus.Counter MsgOnlinePushSuccessCounter prometheus.Counter
MsgOfflinePushSuccessCounter prometheus.Counter MsgOfflinePushSuccessCounter prometheus.Counter
MsgOfflinePushFailedCounter prometheus.Counter MsgOfflinePushFailedCounter prometheus.Counter
// api // api.
ApiRequestCounter prometheus.Counter ApiRequestCounter prometheus.Counter
ApiRequestSuccessCounter prometheus.Counter ApiRequestSuccessCounter prometheus.Counter
ApiRequestFailedCounter prometheus.Counter ApiRequestFailedCounter prometheus.Counter
// grpc // grpc.
GrpcRequestCounter prometheus.Counter GrpcRequestCounter prometheus.Counter
GrpcRequestSuccessCounter prometheus.Counter GrpcRequestSuccessCounter prometheus.Counter
GrpcRequestFailedCounter prometheus.Counter GrpcRequestFailedCounter prometheus.Counter
SendMsgCounter prometheus.Counter SendMsgCounter prometheus.Counter
// conversation // conversation.
ConversationCreateSuccessCounter prometheus.Counter ConversationCreateSuccessCounter prometheus.Counter
ConversationCreateFailedCounter prometheus.Counter ConversationCreateFailedCounter prometheus.Counter
) )
@ -88,6 +88,7 @@ func NewUserLoginCounter() {
Help: "The number of user login", Help: "The number of user login",
}) })
} }
func NewUserRegisterCounter() { func NewUserRegisterCounter() {
if UserRegisterCounter != nil { if UserRegisterCounter != nil {
return return
@ -107,6 +108,7 @@ func NewSeqGetSuccessCounter() {
Help: "The number of successful get seq", Help: "The number of successful get seq",
}) })
} }
func NewSeqGetFailedCounter() { func NewSeqGetFailedCounter() {
if SeqGetFailedCounter != nil { if SeqGetFailedCounter != nil {
return return
@ -126,6 +128,7 @@ func NewSeqSetSuccessCounter() {
Help: "The number of successful set seq", Help: "The number of successful set seq",
}) })
} }
func NewSeqSetFailedCounter() { func NewSeqSetFailedCounter() {
if SeqSetFailedCounter != nil { if SeqSetFailedCounter != nil {
return return
@ -305,6 +308,7 @@ func NewGetNewestSeqTotalCounter() {
Help: "the number of get newest seq", Help: "the number of get newest seq",
}) })
} }
func NewPullMsgBySeqListTotalCounter() { func NewPullMsgBySeqListTotalCounter() {
if PullMsgBySeqListTotalCounter != nil { if PullMsgBySeqListTotalCounter != nil {
return return
@ -404,6 +408,7 @@ func NewWorkSuperGroupChatMsgProcessSuccessCounter() {
Help: "The number of work/super group chat msg successful processed", Help: "The number of work/super group chat msg successful processed",
}) })
} }
func NewWorkSuperGroupChatMsgProcessFailedCounter() { func NewWorkSuperGroupChatMsgProcessFailedCounter() {
if WorkSuperGroupChatMsgProcessFailedCounter != nil { if WorkSuperGroupChatMsgProcessFailedCounter != nil {
return return
@ -433,6 +438,7 @@ func NewMsgOfflinePushSuccessCounter() {
Help: "The number of msg successful offline pushed", Help: "The number of msg successful offline pushed",
}) })
} }
func NewMsgOfflinePushFailedCounter() { func NewMsgOfflinePushFailedCounter() {
if MsgOfflinePushFailedCounter != nil { if MsgOfflinePushFailedCounter != nil {
return return

@ -43,7 +43,8 @@ func BuildClaims(uid string, platformID int, ttl int64) Claims {
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), // Expiration time ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), // Expiration time
IssuedAt: jwt.NewNumericDate(now), // Issuing time IssuedAt: jwt.NewNumericDate(now), // Issuing time
NotBefore: jwt.NewNumericDate(before), // Begin Effective time NotBefore: jwt.NewNumericDate(before), // Begin Effective time
}} },
}
} }
func secret() jwt.Keyfunc { func secret() jwt.Keyfunc {
@ -101,9 +102,11 @@ func CheckAdmin(ctx context.Context) error {
func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) { func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
return GetClaimFromToken(string(redisToken.([]uint8))) return GetClaimFromToken(string(redisToken.([]uint8)))
} }
func IsManagerUserID(opUserID string) bool { func IsManagerUserID(opUserID string) bool {
return utils.IsContain(opUserID, config.Config.Manager.UserID) return utils.IsContain(opUserID, config.Config.Manager.UserID)
} }
func WsVerifyToken(token, userID string, platformID int) error { func WsVerifyToken(token, userID string, platformID int) error {
claim, err := GetClaimFromToken(token) claim, err := GetClaimFromToken(token)
if err != nil { if err != nil {

@ -20,17 +20,20 @@ import (
"io" "io"
"strings" "strings"
"github.com/pkg/errors"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/pkg/errors"
"github.com/go-zookeeper/zk" "github.com/go-zookeeper/zk"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver"
) )
var ErrConnIsNil = errors.New("conn is nil") var (
var ErrConnIsNilButLocalNotNil = errors.New("conn is nil, but local is not nil") ErrConnIsNil = errors.New("conn is nil")
ErrConnIsNilButLocalNotNil = errors.New("conn is nil, but local is not nil")
)
func (s *ZkClient) watch() { func (s *ZkClient) watch() {
for { for {
@ -54,7 +57,6 @@ func (s *ZkClient) watch() {
case zk.EventNotWatching: case zk.EventNotWatching:
} }
} }
} }
func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address, err error) { func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address, err error) {

@ -22,13 +22,14 @@ package auth
import ( import (
context "context" context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
) )
const ( const (

@ -22,14 +22,16 @@ package conversation
import ( import (
context "context" context "context"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb" reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
) )
const ( const (

@ -21,10 +21,11 @@
package errinfo package errinfo
import ( import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
) )
const ( const (

@ -22,14 +22,16 @@ package friend
import ( import (
context "context" context "context"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
) )
const ( const (

@ -22,15 +22,17 @@ package group
import ( import (
context "context" context "context"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" reflect "reflect"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb" sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
) )
const ( const (

@ -22,14 +22,16 @@ package msg
import ( import (
context "context" context "context"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
) )
const ( const (

@ -22,14 +22,16 @@ package msggateway
import ( import (
context "context" context "context"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
) )
const ( const (

@ -22,14 +22,16 @@ package push
import ( import (
context "context" context "context"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
) )
const ( const (

@ -21,11 +21,13 @@
package sdkws package sdkws
import ( import (
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
) )
const ( const (

@ -21,9 +21,10 @@
package statistics package statistics
import ( import (
reflect "reflect"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
) )
const ( const (

@ -22,13 +22,14 @@ package third
import ( import (
context "context" context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
) )
const ( const (

@ -22,15 +22,17 @@ package user
import ( import (
context "context" context "context"
conversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation" reflect "reflect"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" sync "sync"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync" conversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
) )
const ( const (

@ -21,10 +21,11 @@
package wrapperspb package wrapperspb
import ( import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
) )
const ( const (

@ -18,11 +18,12 @@ import (
"context" "context"
"fmt" "fmt"
"google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation" pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"google.golang.org/grpc"
) )
type Conversation struct { type Conversation struct {
@ -71,6 +72,7 @@ func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, owner
_, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq}) _, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
return err return err
} }
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error { func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
_, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation}) _, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
return err return err

@ -61,14 +61,13 @@ func (f *FriendRpcClient) GetFriendsInfo(
return return
} }
// possibleFriendUserID是否在userID的好友中 // possibleFriendUserID是否在userID的好友中.
func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) { func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
resp, err := f.Client.IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID}) resp, err := f.Client.IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
if err != nil { if err != nil {
return false, err return false, err
} }
return resp.InUser1Friends, nil return resp.InUser1Friends, nil
} }
func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) { func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {

@ -18,6 +18,9 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@ -25,9 +28,7 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc" // "google.golang.org/protobuf/proto".
"google.golang.org/protobuf/proto"
// "google.golang.org/protobuf/proto"
) )
func newContentTypeConf() map[int32]config.NotificationConf { func newContentTypeConf() map[int32]config.NotificationConf {

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

Loading…
Cancel
Save