mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-04 14:59:22 +08:00
Merge branch 'pre-release-v3.8.4' into cherry-pick-3b710fd
This commit is contained in:
commit
90529aad2f
25
.github/workflows/go-build-test.yml
vendored
25
.github/workflows/go-build-test.yml
vendored
@ -12,6 +12,10 @@ jobs:
|
||||
go-build:
|
||||
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
SHARE_CONFIG_PATH: config/share.yml
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
@ -40,6 +44,10 @@ jobs:
|
||||
with:
|
||||
compose-file: "./docker-compose.yml"
|
||||
|
||||
- name: Modify Server Configuration
|
||||
run: |
|
||||
yq e '.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }}
|
||||
|
||||
# - name: Get Internal IP Address
|
||||
# id: get-ip
|
||||
# run: |
|
||||
@ -71,6 +79,11 @@ jobs:
|
||||
go mod download
|
||||
go install github.com/magefile/mage@latest
|
||||
|
||||
- name: Modify Chat Configuration
|
||||
run: |
|
||||
cd ${{ github.workspace }}/chat-repo
|
||||
yq e '.openIM.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }}
|
||||
|
||||
- name: Build and test Chat Services
|
||||
run: |
|
||||
cd ${{ github.workspace }}/chat-repo
|
||||
@ -132,7 +145,7 @@ jobs:
|
||||
|
||||
# Test get admin token
|
||||
get_admin_token_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
|
||||
"secret": "openIM123",
|
||||
"secret": "123456",
|
||||
"platformID": 2,
|
||||
"userID": "imAdmin"
|
||||
}' http://127.0.0.1:10002/auth/get_admin_token)
|
||||
@ -169,7 +182,8 @@ jobs:
|
||||
contents: write
|
||||
env:
|
||||
SDK_DIR: openim-sdk-core
|
||||
CONFIG_PATH: config/notification.yml
|
||||
NOTIFICATION_CONFIG_PATH: config/notification.yml
|
||||
SHARE_CONFIG_PATH: config/share.yml
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
@ -184,7 +198,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "openimsdk/openim-sdk-core"
|
||||
ref: "release-v3.8"
|
||||
ref: "main"
|
||||
path: ${{ env.SDK_DIR }}
|
||||
|
||||
- name: Set up Go ${{ matrix.go_version }}
|
||||
@ -199,8 +213,9 @@ jobs:
|
||||
|
||||
- name: Modify Server Configuration
|
||||
run: |
|
||||
yq e '.groupCreated.isSendMsg = true' -i ${{ env.CONFIG_PATH }}
|
||||
yq e '.friendApplicationApproved.isSendMsg = true' -i ${{ env.CONFIG_PATH }}
|
||||
yq e '.groupCreated.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
||||
yq e '.friendApplicationApproved.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
||||
yq e '.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }}
|
||||
|
||||
- name: Start Server Services
|
||||
run: |
|
||||
|
@ -1,9 +1,9 @@
|
||||
secret: openIM123
|
||||
|
||||
imAdminUserID: [ imAdmin ]
|
||||
imAdminUserID: [imAdmin]
|
||||
|
||||
# 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time
|
||||
multiLogin:
|
||||
policy: 1
|
||||
# max num of tokens in one end
|
||||
maxNumOneEnd: 30
|
||||
maxNumOneEnd: 30
|
||||
|
@ -51,6 +51,10 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultSecret = "openIM123"
|
||||
)
|
||||
|
||||
type userServer struct {
|
||||
pbuser.UnimplementedUserServer
|
||||
online cache.OnlineCache
|
||||
@ -273,6 +277,10 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
||||
if len(req.Users) == 0 {
|
||||
return nil, errs.ErrArgs.WrapMsg("users is empty")
|
||||
}
|
||||
// check if secret is changed
|
||||
if s.config.Share.Secret == defaultSecret {
|
||||
return nil, servererrs.ErrSecretNotChanged.Wrap()
|
||||
}
|
||||
|
||||
if err = authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
|
||||
return nil, err
|
||||
|
@ -37,7 +37,8 @@ const (
|
||||
|
||||
// General error codes.
|
||||
const (
|
||||
NoError = 0 // No error
|
||||
NoError = 0 // No error
|
||||
|
||||
DatabaseError = 90002 // Database error (redis/mysql, etc.)
|
||||
NetworkError = 90004 // Network error
|
||||
DataError = 90007 // Data error
|
||||
@ -45,11 +46,12 @@ const (
|
||||
CallbackError = 80000
|
||||
|
||||
// General error codes.
|
||||
ServerInternalError = 500 // Server internal error
|
||||
ArgsError = 1001 // Input parameter error
|
||||
NoPermissionError = 1002 // Insufficient permission
|
||||
DuplicateKeyError = 1003
|
||||
RecordNotFoundError = 1004 // Record does not exist
|
||||
ServerInternalError = 500 // Server internal error
|
||||
ArgsError = 1001 // Input parameter error
|
||||
NoPermissionError = 1002 // Insufficient permission
|
||||
DuplicateKeyError = 1003
|
||||
RecordNotFoundError = 1004 // Record does not exist
|
||||
SecretNotChangedError = 1050 // secret not changed
|
||||
|
||||
// Account error codes.
|
||||
UserIDNotFoundError = 1101 // UserID does not exist or is not registered
|
||||
|
@ -17,6 +17,8 @@ package servererrs
|
||||
import "github.com/openimsdk/tools/errs"
|
||||
|
||||
var (
|
||||
ErrSecretNotChanged = errs.NewCodeError(SecretNotChangedError, "secret not changed, please change secret in config/share.yml for security reasons")
|
||||
|
||||
ErrDatabase = errs.NewCodeError(DatabaseError, "DatabaseError")
|
||||
ErrNetwork = errs.NewCodeError(NetworkError, "NetworkError")
|
||||
ErrCallback = errs.NewCodeError(CallbackError, "CallbackError")
|
||||
|
25
tools/stress-test/README.md
Normal file
25
tools/stress-test/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Stress Test
|
||||
|
||||
## Usage
|
||||
|
||||
You need set `TestTargetUserList` and `DefaultGroupID` variables.
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
go build -o _output/bin/tools/linux/amd64/stress-test tools/stress-test/main.go
|
||||
|
||||
# or
|
||||
|
||||
go build -o tools/stress-test/stress-test tools/stress-test/main.go
|
||||
```
|
||||
|
||||
### Excute
|
||||
|
||||
```bash
|
||||
_output/bin/tools/linux/amd64/stress-test -c config/
|
||||
|
||||
#or
|
||||
|
||||
tools/stress-test/stress-test -c config/
|
||||
```
|
@ -233,15 +233,12 @@ func (st *StressTest) SendMsg(ctx context.Context, userID string) error {
|
||||
"content": fmt.Sprintf("index %d. The current time is %s", st.MsgCounter, time.Now().Format("2006-01-02 15:04:05.000")),
|
||||
}
|
||||
|
||||
req := &apistruct.SendMsgReq{
|
||||
SendMsg: apistruct.SendMsg{
|
||||
SendID: userID,
|
||||
SenderNickname: userID,
|
||||
GroupID: st.DefaultGroupID,
|
||||
ContentType: constant.Text,
|
||||
SessionType: constant.ReadGroupChatType,
|
||||
Content: contentObj,
|
||||
},
|
||||
req := map[string]any{
|
||||
"sendID": userID,
|
||||
"groupID": st.DefaultGroupID,
|
||||
"contentType": constant.Text,
|
||||
"sessionType": constant.ReadGroupChatType,
|
||||
"content": contentObj,
|
||||
}
|
||||
|
||||
_, err := st.PostRequest(ctx, ApiAddress+SendMsg, &req)
|
||||
@ -258,18 +255,15 @@ func (st *StressTest) SendMsg(ctx context.Context, userID string) error {
|
||||
func (st *StressTest) CreateGroup(ctx context.Context, userID string) (string, error) {
|
||||
groupID := fmt.Sprintf("StressTestGroup_%d_%s", st.GroupCounter, time.Now().Format("20060102150405"))
|
||||
|
||||
groupInfo := &sdkws.GroupInfo{
|
||||
GroupID: groupID,
|
||||
GroupName: groupID,
|
||||
GroupType: constant.WorkingGroup,
|
||||
req := map[string]any{
|
||||
"memberUserIDs": TestTargetUserList,
|
||||
"ownerUserID": userID,
|
||||
"groupInfo": map[string]any{
|
||||
"groupID": groupID,
|
||||
"groupName": groupID,
|
||||
"groupType": constant.WorkingGroup,
|
||||
},
|
||||
}
|
||||
|
||||
req := group.CreateGroupReq{
|
||||
OwnerUserID: userID,
|
||||
MemberUserIDs: TestTargetUserList,
|
||||
GroupInfo: groupInfo,
|
||||
}
|
||||
|
||||
resp := group.CreateGroupResp{}
|
||||
|
||||
response, err := st.PostRequest(ctx, ApiAddress+CreateGroup, &req)
|
||||
|
Loading…
x
Reference in New Issue
Block a user