From b3899f559c75601977293f7ffec069805b31111e Mon Sep 17 00:00:00 2001
From: withchao <48119764+withchao@users.noreply.github.com>
Date: Wed, 16 Aug 2023 18:43:10 +0800
Subject: [PATCH 01/19] fix: minio sign cndpoint crash caused by unconfigured
(#881)
* fix: create group type limit
* fix: group notification
* fix: group notification
* fix: group notification
* chore: group member hash
* chore: group member hash
* chore: group member hash
* chore: group member hash
* test: log
* test: log
* test: log
* test: log
* test: log
* sync: hash code
* sync: hash code
* sync: hash code
* test: log
* test: log
* test: log
* test: log
* test: log
* fix: time stamp
* fix: minio sign endpoint opts
---
pkg/common/db/s3/minio/minio.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/pkg/common/db/s3/minio/minio.go b/pkg/common/db/s3/minio/minio.go
index 9137f7b75..1f848d1b4 100644
--- a/pkg/common/db/s3/minio/minio.go
+++ b/pkg/common/db/s3/minio/minio.go
@@ -84,6 +84,7 @@ func NewMinio() (s3.Interface, error) {
init: false,
}
if conf.SignEndpoint == "" || conf.SignEndpoint == conf.Endpoint {
+ m.opts = opts
m.sign = m.core.Client
} else {
su, err := url.Parse(conf.SignEndpoint)
From 7000755e1530dfdd543f1d0cec625b2c790538f5 Mon Sep 17 00:00:00 2001
From: pluto <2631223275@qq.com>
Date: Thu, 17 Aug 2023 14:20:46 +0800
Subject: [PATCH 02/19] Fix bug #862 (#879)
* test
* Solve the problem that the storage of multiple terminals in the online state is overwritten
* go.sum
* debug
* debug
* Judging whether to be kicked out
* Judging whether to be kicked out
* Finish debug
---
go.mod | 2 +-
go.sum | 4 +-
go.work.sum | 4 +-
internal/api/route.go | 2 +-
internal/rpc/user/user.go | 2 +-
pkg/common/db/cache/user.go | 84 +++++++++++++++++++++++++++++++++----
pkg/rpcclient/user.go | 2 +-
7 files changed, 84 insertions(+), 16 deletions(-)
diff --git a/go.mod b/go.mod
index c2f8093e7..87cb62369 100644
--- a/go.mod
+++ b/go.mod
@@ -37,7 +37,7 @@ require (
require github.com/google/uuid v1.3.0
require (
- github.com/OpenIMSDK/protocol v0.0.10
+ github.com/OpenIMSDK/protocol v0.0.11
github.com/OpenIMSDK/tools v0.0.13
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
github.com/go-redis/redis v6.15.9+incompatible
diff --git a/go.sum b/go.sum
index 1b9d43ec9..bf86b45e1 100644
--- a/go.sum
+++ b/go.sum
@@ -17,8 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/OpenIMSDK/protocol v0.0.10 h1:OiJR2BAAJjuKKK8KPxYZdJCwOSzMMxwF5fnJdOmLPdQ=
-github.com/OpenIMSDK/protocol v0.0.10/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
+github.com/OpenIMSDK/protocol v0.0.11 h1:3sWujfQhO1I1Da1b8UScaZcc0DNunSbNiH3DagZB/AA=
+github.com/OpenIMSDK/protocol v0.0.11/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.13 h1:rcw4HS8S2DPZR9UOBxD8/ol9UBMzXBypzOVEytDRIMo=
github.com/OpenIMSDK/tools v0.0.13/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
diff --git a/go.work.sum b/go.work.sum
index 8ae1c5cc7..76e060d37 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -221,8 +221,8 @@ cloud.google.com/go/websecurityscanner v1.6.1/go.mod h1:Njgaw3rttgRHXzwCB8kgCYqv
cloud.google.com/go/workflows v1.11.1 h1:2akeQ/PgtRhrNuD/n1WvJd5zb7YyuDZrlOanBj2ihPg=
cloud.google.com/go/workflows v1.11.1/go.mod h1:Z+t10G1wF7h8LgdY/EmRcQY8ptBD/nvofaL6FqlET6g=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
-github.com/OpenIMSDK/protocol v0.0.10 h1:OiJR2BAAJjuKKK8KPxYZdJCwOSzMMxwF5fnJdOmLPdQ=
-github.com/OpenIMSDK/protocol v0.0.10/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
+github.com/OpenIMSDK/protocol v0.0.11 h1:3sWujfQhO1I1Da1b8UScaZcc0DNunSbNiH3DagZB/AA=
+github.com/OpenIMSDK/protocol v0.0.11/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 h1:DTQ/38ao/CfXsrK0cSAL+h4R/u0VVvfWLZEOlLwEROI=
github.com/alecthomas/kingpin/v2 v2.3.1 h1:ANLJcKmQm4nIaog7xdr/id6FM6zm5hHnfZrvtKPxqGg=
github.com/alecthomas/kingpin/v2 v2.3.1/go.mod h1:oYL5vtsvEHZGHxU7DMp32Dvx+qL+ptGn6lWaot2vCNE=
diff --git a/internal/api/route.go b/internal/api/route.go
index f961489a3..8cf65b03d 100644
--- a/internal/api/route.go
+++ b/internal/api/route.go
@@ -82,7 +82,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
userRouterGroup.POST("/get_users", ParseToken, u.GetUsers)
userRouterGroup.POST("/get_users_online_status", ParseToken, u.GetUsersOnlineStatus)
userRouterGroup.POST("/get_users_online_token_detail", ParseToken, u.GetUsersOnlineTokenDetail)
- userRouterGroup.POST("/subscribe_users_status", ParseToken, u.UnSubscriberStatus)
+ userRouterGroup.POST("/subscribe_users_status", ParseToken, u.SubscriberStatus)
userRouterGroup.POST("/unsubscribe_users_status", ParseToken, u.UnSubscriberStatus)
userRouterGroup.POST("/get_users_status", ParseToken, u.GetUserStatus)
userRouterGroup.POST("/get_subscribe_users_status", ParseToken, u.GetSubscribeUsersStatus)
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index a16a16bb2..a1cb0db09 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -299,7 +299,7 @@ func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatu
FromUserID: value.UserID,
ToUserID: userID,
Status: value.Status,
- PlatformID: value.PlatformID,
+ PlatformID: value.PlatformIDs[0],
}
s.userNotificationSender.UserStatusChangeNotification(ctx, tips)
}
diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go
index 05374cc5f..fee907575 100644
--- a/pkg/common/db/cache/user.go
+++ b/pkg/common/db/cache/user.go
@@ -17,6 +17,7 @@ package cache
import (
"context"
"encoding/json"
+ "github.com/OpenIMSDK/protocol/constant"
"hash/crc32"
"strconv"
"time"
@@ -37,6 +38,7 @@ const (
olineStatusKey = "ONLINE_STATUS:"
userOlineStatusExpireTime = time.Second * 60 * 60 * 24
statusMod = 501
+ platformID = "_PlatformIDSuffix"
)
type UserCache interface {
@@ -92,6 +94,10 @@ func (u *UserCacheRedis) getUserGlobalRecvMsgOptKey(userID string) string {
return userGlobalRecvMsgOptKey + userID
}
+func (u *UserCacheRedis) getUserStatusHashKey(userID string, Id int32) string {
+ return userID + "_" + string(Id) + platformID
+}
+
func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error) {
return getCache(
ctx,
@@ -177,9 +183,9 @@ func (u *UserCacheRedis) GetUserStatus(ctx context.Context, userIDs []string) ([
if err == redis.Nil {
// key or field does not exist
res = append(res, &user.OnlineStatus{
- UserID: userID,
- Status: 0,
- PlatformID: -1,
+ UserID: userID,
+ Status: constant.Offline,
+ PlatformIDs: nil,
})
continue
} else {
@@ -211,12 +217,74 @@ func (u *UserCacheRedis) SetUserStatus(ctx context.Context, list []*user.OnlineS
if err != nil {
return errs.Wrap(err)
}
- _, err = u.rdb.HSet(ctx, key, status.UserID, string(jsonData)).Result()
- if err != nil {
- return errs.Wrap(err)
- }
- if isNewKey > 0 {
+ if isNewKey == 0 {
+ _, err = u.rdb.HSet(ctx, key, status.UserID, string(jsonData)).Result()
+ if err != nil {
+ return errs.Wrap(err)
+ }
u.rdb.Expire(ctx, key, userOlineStatusExpireTime)
+ } else {
+ result, err := u.rdb.HGet(ctx, key, status.UserID).Result()
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ var onlineStatus user.OnlineStatus
+ err = json.Unmarshal([]byte(result), &onlineStatus)
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ onlineStatus.UserID = status.UserID
+ if status.Status == constant.Offline {
+ var newPlatformIDs []int32
+ for _, val := range onlineStatus.PlatformIDs {
+ if val != status.PlatformIDs[0] {
+ newPlatformIDs = append(newPlatformIDs, val)
+ }
+ }
+ if newPlatformIDs == nil {
+ onlineStatus.Status = constant.Offline
+ onlineStatus.PlatformIDs = nil
+ newjsonData, err := json.Marshal(&onlineStatus)
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ _, err = u.rdb.HSet(ctx, key, status.UserID, string(newjsonData)).Result()
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ } else {
+ onlineStatus.PlatformIDs = newPlatformIDs
+ newjsonData, err := json.Marshal(&onlineStatus)
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ _, err = u.rdb.HSet(ctx, key, status.UserID, string(newjsonData)).Result()
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ }
+ } else {
+ onlineStatus.Status = constant.Online
+ // Judging whether to be kicked out.
+ flag := false
+ for _, val := range onlineStatus.PlatformIDs {
+ if val == status.PlatformIDs[0] {
+ flag = true
+ break
+ }
+ }
+ if !flag {
+ onlineStatus.PlatformIDs = append(onlineStatus.PlatformIDs, status.PlatformIDs[0])
+ }
+ newjsonData, err := json.Marshal(&onlineStatus)
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ _, err = u.rdb.HSet(ctx, key, status.UserID, string(newjsonData)).Result()
+ if err != nil {
+ return errs.Wrap(err)
+ }
+ }
}
}
return nil
diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go
index 3c24efbbd..2fdeb134f 100644
--- a/pkg/rpcclient/user.go
+++ b/pkg/rpcclient/user.go
@@ -158,6 +158,6 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
}
func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status int32, platformID int) error {
- _, err := u.Client.SetUserStatus(ctx, &user.SetUserStatusReq{StatusList: []*user.OnlineStatus{{UserID: userID, Status: status, PlatformID: int32(platformID)}}})
+ _, err := u.Client.SetUserStatus(ctx, &user.SetUserStatusReq{StatusList: []*user.OnlineStatus{{UserID: userID, Status: status, PlatformIDs: []int32{int32(platformID)}}}})
return err
}
From 84c60cd6b62a33c14a44a6fa67c385d322c90a78 Mon Sep 17 00:00:00 2001
From: Gordon <46924906+FGadvancer@users.noreply.github.com>
Date: Thu, 17 Aug 2023 15:57:59 +0800
Subject: [PATCH 03/19] Feature: add api of get server time and the message's
read status is incorrect when app reinstalling. (#884)
* fix: to start im or chat, ZooKeeper must be started first.
* fix: msg gateway start output err info
Signed-off-by: Gordon <1432970085@qq.com>
* fix: msg gateway start output err info
Signed-off-by: Gordon <1432970085@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* fix: go mod update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: get all userID
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: msggateway add online status call
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: log change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: log change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* chore: network mode change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat: add api of get server time
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* feat: remove go work sum
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: pull message add isRead field
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
---------
Signed-off-by: Gordon <1432970085@qq.com>
Signed-off-by: withchao <993506633@qq.com>
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: withchao <993506633@qq.com>
Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com>
Co-authored-by: FGadvancer
+
+
-
- Open IM Server
+
-
- ⭐️ Open source Instant Messaging Server ⭐️
-
+
+
+ ⭐️ Open source Instant Messaging Server ⭐️
@@ -18,164 +21,220 @@
+
- English • - 中文 + English • + 简体中文 • + Docs
+ -## Open-IM-Server 是什么 +## ✨ 关于 OpenIM + +Open-IM-Server 是使用纯 Golang 精心制作的强大的即时消息服务器。其通过 JSON over WebSocket 进行通信的独特方法将每次交互都视为消息。这简化了定制并消除了修改服务器代码的需求。通过利用微服务架构,服务器可以通过集群部署,保证出色的性能和可伸缩性。 + +Open-IM-Server 不仅仅是一个即时消息服务器;它是将实时网络集成到您的应用程序中的强大工具,定位为您集成的首选选择!🚀 + +请注意,Open-IM-Server 不作为独立产品运行,也不提供内置的帐户注册或登录服务。为了简化您的实施过程,我们已开源了 [chat repository](https://github.com/OpenIMSDK/chat),其中包括这些功能。与 Open-IM-Server 一起部署此聊天业务服务器可加快全面的聊天产品的设置。👥 + +为了进一步增强您的体验,我们还提供了 SDK 客户端,在其中实现了大多数复杂逻辑。可以在 [此链接](https://github.com/OpenIMSDK/openim-sdk-core) 找到 [SDK repository](https://github.com/OpenIMSDK/openim-sdk-core)。[chat repository](https://github.com/OpenIMSDK/chat) 是我们的业务服务器,而 'core' 代表 SDK 的高级封装,它们协同工作以提供卓越的结果。✨ + +## :star2: 为什么选择 OpenIM + +**🔍 功能截图显示** + +03IC2zwDcPL2EH#m*-Nf$ME4@k471F{G-sk>
zR@hizS?yv*)=!2@@2l3ppMpNku5;p+rx#4O1!>YKGXdp`O
zE3!tjGcdJ9c2+bwyq&?kt(PZfn
wcr
zW@yzA?6<6gf+k*}eK81Uru_}TZdjy}=Xm-_AE`~4@nGkir~Rz{iS&>;d^!bxRIia`
z4mDGtN;vfkGaEnwF|**QV1Q~uMJ~(SWSHi;=Ch)*e7zV)@q4YnQdVpGqyO5Kw%aB*
z)ZZ3f)tlvIcKuP}pZ_*dLXFl+IRgZ%7ghRdYz*`|VGRn--}n;zRW5mV%9E1n$01c)
zJ1bP_^SsgUX}a6szJLSc+}T82ccZ-F;2Rj>dV*>peLLM+vcr}*OOD%JlWCyyETRxO
z`L(-KBCF0)UCVF}lgDy!_$2eGV2jO@g1C41Ij)bt34mY&LcYP8AeUZ8=~Am9T!lzq
z-28Af)H@t`WTW+)8?Q;S2Qg`!#*nVzdPFc>4!8#f@!~)8TLO%#?p~D?p!+H
zPC~{c*t1#ytX4}d>w~so>ZyI~U~SgOMzvOwG7EikhbjJc{5@2wqj_pZI%l6j#R&KI
zCGykzR>IBBxa}TNrQX#jk2XA3xT^dnsIdF#PAg$|Y}-}f7&mfA|GSn&5`7{FGQx
zk+S^v;$9mcXs!S`B$(YricGOeW$OSD#&?^Hk2G??mvd*6&s5ELzVa`gQqtQxNi