Skip to content

Commit 68c8e8f

Browse files
OpenIM-Roboticey-yu
andauthored
feat: support harmony (#649) (#694)
* feat: support harmony * feat: support harmony * feat: support harmony * fix: cicd Co-authored-by: icey-yu <119291641+icey-yu@users.noreply.github.com>
1 parent 9cbd1c2 commit 68c8e8f

4 files changed

Lines changed: 175 additions & 10 deletions

File tree

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: OpenIM Chat Build Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
paths-ignore:
9+
- "docs/**"
10+
- "README.md"
11+
- "README_zh-CN.md"
12+
- "**.md"
13+
- "docs/**"
14+
- "CONTRIBUTING.md"
15+
pull_request:
16+
branches:
17+
- main
18+
- release-*
19+
paths-ignore:
20+
- "README.md"
21+
- "README_zh-CN.md"
22+
- "CONTRIBUTING/**"
23+
- "**.md"
24+
- "docs/**"
25+
workflow_dispatch:
26+
27+
jobs:
28+
build-linux:
29+
name: Execute OpenIM Script On Linux
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
33+
pull-requests: write
34+
# environment:
35+
# name: openim
36+
strategy:
37+
matrix:
38+
arch: [amd64]
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
45+
with:
46+
go-version: "1.22"
47+
48+
- name: init
49+
run: sudo bash bootstrap.sh
50+
timeout-minutes: 20
51+
52+
- name: Checkout chat repository
53+
uses: actions/checkout@v4
54+
with:
55+
repository: "openimsdk/open-im-server"
56+
path: "server-repo"
57+
58+
- name: Set up Docker for Linux
59+
run: |
60+
cd ${{ github.workspace }}/server-repo
61+
sudo docker compose up -d
62+
sudo sleep 30 # Increased sleep time for better stability
63+
timeout-minutes: 30 # Increased timeout for Docker setup
64+
65+
- name: Modify Server Configuration
66+
run: |
67+
yq e '.secret = 123456' -i ${{ github.workspace }}/server-repo/config/share.yml
68+
69+
- name: Build and Start IM Serevr Services
70+
run: |
71+
cd ${{ github.workspace }}/server-repo
72+
sudo mage
73+
sudo mage start
74+
sudo mage check
75+
76+
- name: Modify Chat Configuration
77+
run: |
78+
yq e '.openIM.secret = 123456' -i config/share.yml
79+
80+
- name: Build, Start, Check Services and Print Logs for Linux
81+
run: |
82+
sudo mage
83+
sudo mage start
84+
sudo mage check
85+
86+
- name: Restart Services and Print Logs
87+
run: |
88+
sudo mage stop
89+
sudo mage start
90+
sudo mage check
91+
92+
- name: Test Chat
93+
run: |
94+
check_error() {
95+
echo "Response: $1"
96+
errCode=$(echo $1 | jq -r '.errCode')
97+
if [ "$errCode" != "0" ]; then
98+
errMsg=$(echo $1 | jq -r '.errMsg')
99+
echo "Error: $errMsg"
100+
exit 1
101+
fi
102+
}
103+
104+
# Test register
105+
response1=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
106+
"verifyCode": "666666",
107+
"platform": 3,
108+
"autoLogin": true,
109+
"user":{
110+
"nickname": "test12312",
111+
"areaCode":"+86",
112+
"phoneNumber": "12345678190",
113+
"password":"test123456"
114+
}
115+
}' http://127.0.0.1:10008/account/register)
116+
check_error "$response1"
117+
userID1=$(echo $response1 | jq -r '.data.userID')
118+
echo "userID1: $userID1"
119+
120+
response2=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
121+
"verifyCode": "666666",
122+
"platform": 3,
123+
"autoLogin": true,
124+
"user":{
125+
"nickname": "test22312",
126+
"areaCode":"+86",
127+
"phoneNumber": "12345678290",
128+
"password":"test123456"
129+
}
130+
}' http://127.0.0.1:10008/account/register)
131+
check_error "$response2"
132+
userID2=$(echo $response2 | jq -r '.data.userID')
133+
echo "userID2: $userID2"
134+
135+
# Test login
136+
login_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
137+
"platform": 3,
138+
"areaCode":"+86",
139+
"phoneNumber": "12345678190",
140+
"password":"test123456"
141+
}' http://localhost:10008/account/login)
142+
check_error "$login_response"
143+
144+
# Test get admin token
145+
get_admin_token_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
146+
"secret": "123456",
147+
"platformID": 2,
148+
"userID": "imAdmin"
149+
}' http://127.0.0.1:10002/auth/get_admin_token)
150+
check_error "$get_admin_token_response"
151+
adminToken=$(echo $get_admin_token_response | jq -r '.data.token')
152+
echo "adminToken: $adminToken"
153+
154+
# Test send message
155+
send_msg_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -H "token: $adminToken" -d '{
156+
"sendID": "'$userID1'",
157+
"recvID": "'$userID2'",
158+
"senderPlatformID": 3,
159+
"content": {
160+
"content": "hello!!"
161+
},
162+
"contentType": 101,
163+
"sessionType": 1
164+
}' http://127.0.0.1:10002/msg/send_msg)
165+
check_error "$send_msg_response"

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/jinzhu/copier v0.4.0 // indirect
1313
github.com/pkg/errors v0.9.1 // indirect
1414
google.golang.org/grpc v1.68.0
15-
google.golang.org/protobuf v1.34.2
15+
google.golang.org/protobuf v1.35.1
1616
gopkg.in/yaml.v3 v3.0.1 // indirect
1717
gorm.io/gorm v1.25.8
1818
)
@@ -26,8 +26,8 @@ require (
2626
require (
2727
github.com/livekit/protocol v1.10.1
2828
github.com/mitchellh/mapstructure v1.5.0
29-
github.com/openimsdk/gomake v0.0.15-alpha.11
30-
github.com/openimsdk/protocol v0.0.72
29+
github.com/openimsdk/gomake v0.0.14-alpha.5
30+
github.com/openimsdk/protocol v0.0.73-alpha.5
3131
github.com/openimsdk/tools v0.0.50-alpha.65
3232
github.com/redis/go-redis/v9 v9.5.1
3333
github.com/spf13/cobra v1.8.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
213213
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
214214
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
215215
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
216-
github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw=
217-
github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
218-
github.com/openimsdk/protocol v0.0.72 h1:K+vslwaR7lDXyBzb07UuEQITaqsgighz7NyXVIWsu6A=
219-
github.com/openimsdk/protocol v0.0.72/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
216+
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
217+
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
218+
github.com/openimsdk/protocol v0.0.73-alpha.5 h1:SQ7aQRuMJTrUXAoLIu0EIsVU+oIRBvXc7JlA88lEZvw=
219+
github.com/openimsdk/protocol v0.0.73-alpha.5/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
220220
github.com/openimsdk/tools v0.0.50-alpha.65 h1:BRtxkyWxDWPHuHphSwEyHZj7kJSR98am/fHOH84naK8=
221221
github.com/openimsdk/tools v0.0.50-alpha.65/go.mod h1:B+oqV0zdewN7OiEHYJm+hW+8/Te7B8tHHgD8rK5ZLZk=
222222
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
@@ -476,8 +476,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:
476476
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
477477
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
478478
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
479-
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
480-
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
479+
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
480+
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
481481
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
482482
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
483483
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

pkg/protocol/chat/chat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (x *RegisterUserReq) Check() error {
116116
if x.User.Nickname == "" {
117117
return errs.ErrArgs.WrapMsg("Nickname is nil")
118118
}
119-
if x.Platform < constantpb.IOSPlatformID || x.Platform > constantpb.AdminPlatformID {
119+
if x.Platform < constantpb.IOSPlatformID || x.Platform > constantpb.HarmonyOSPlatformID {
120120
return errs.ErrArgs.WrapMsg("platform is invalid")
121121
}
122122
if x.User == nil {

0 commit comments

Comments
 (0)