Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/

RUN go get github.com/openimsdk/gomake@v0.0.9-alpha.3
RUN go get github.com/openimsdk/gomake@v0.0.9

# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
2 changes: 2 additions & 0 deletions config/chat-api-admin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
api:
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended
listenIP: 0.0.0.0
# Listening ports; if multiple are configured, multiple instances will be launched
ports: [ 10009 ]

2 changes: 2 additions & 0 deletions config/chat-api-chat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
api:
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended
listenIP: 0.0.0.0
# Listening ports; if multiple are configured, multiple instances will be launched
ports: [ 10008 ]

3 changes: 3 additions & 0 deletions config/chat-rpc-admin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
rpc:
# The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP
registerIP: ''
# IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP
listenIP: 0.0.0.0
# List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances.
ports: [ 30200 ]

tokenPolicy:
Expand Down
3 changes: 3 additions & 0 deletions config/chat-rpc-chat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
rpc:
# The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP
registerIP: ''
# IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP
listenIP: 0.0.0.0
# List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances.
ports: [ 30300 ]

verifyCode:
Expand Down
7 changes: 6 additions & 1 deletion config/log.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Log storage path, default is acceptable, change to a full path if modification is needed
storageLocation: ../../../../logs/
# Log rotation period (in hours), default is acceptable
rotationTime: 24
# Number of log files to retain, default is acceptable
remainRotationCount: 2
# Log level settings: 3 for production environment; 6 for more verbose logging in debugging environments
remainLogLevel: 6
# Whether to output to standard output, default is acceptable
isStdout: false
# Whether to log in JSON format, default is acceptable
isJson: false
withStack: false
9 changes: 8 additions & 1 deletion config/mongodb.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# URI for database connection, leave empty if using address and credential settings directly
uri: ''
# List of MongoDB server addresses
address: [ localhost:37017 ]
# Name of the database
database: openim_v3
# Username for database authentication
username: openIM
# Password for database authentication
password: openIM123
# Maximum number of connections in the connection pool
maxPoolSize: 100
maxRetry: 10
# Maximum number of retry attempts for a failed database connection
maxRetry: 10
9 changes: 8 additions & 1 deletion config/redis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# List of Redis server addresses
address: [ localhost:16379 ]
# Username for Redis authentication (leave blank if not used)
username: ''
# Password for Redis authentication
password: openIM123
# Enable or disable pipeline processing
enablePipeline: false
# Enable or disable cluster mode
clusterMode: false
# Database index to be used
db: 0
maxRetry: 10
# Maximum number of retry attempts for a failed connection
maxRetry: 10
5 changes: 4 additions & 1 deletion config/share.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ rpcRegisterName:
admin: admin

openIM:
# OpenIM API address
apiURL: http://127.0.0.1:10002
# OpenIM secret key, must be consistent with OpenIM
secret: openIM123
# OpenIM administrator userID, must be consistent with OpenIM
adminUserID: imAdmin

chatAdmin:
# Default username and password for the admin
- "chatAdmin"

#proxyHeader: "X-Forwarded-For"
5 changes: 4 additions & 1 deletion config/zookeeper.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Database schema name
schema: openim
# List of server addresses
address: [ localhost:12181 ]
# Username for authentication (leave blank if not used)
username: ''
# Password for authentication (leave blank if not used)
password: ''

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
require (
github.com/livekit/protocol v1.10.1
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/gomake v0.0.9-alpha.3
github.com/openimsdk/gomake v0.0.9
github.com/openimsdk/protocol v0.0.63
github.com/openimsdk/tools v0.0.49-alpha.3
github.com/redis/go-redis/v9 v9.5.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADym
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/openimsdk/gomake v0.0.9-alpha.3 h1:KO3stbmiTksnnx2o2Lh8/FkKXc7qiF4rwPnr01WO7aM=
github.com/openimsdk/gomake v0.0.9-alpha.3/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/gomake v0.0.9 h1:ouf25ygN2PMQ68Gfgns/EQRPiLPnp+77SIr68GfE+n4=
github.com/openimsdk/gomake v0.0.9/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.63 h1:9DnweZe9nEYDFa4fGTbC9Cqi0gLUdtBhRo1NRP2X3WQ=
github.com/openimsdk/protocol v0.0.63/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.49-alpha.3 h1:mXKU09asKTLjj0yCsfqqMizs3ibl1vLimW7ZYzAMw44=
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/model/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (o *IPForbidden) Search(ctx context.Context, keyword string, state int32, p

switch state {
case constant.LimitNil:
// 不添加额外的过滤条件
case constant.LimitEmpty:
filter = bson.M{"limit_register": 0, "limit_login": 0}
case constant.LimitOnlyRegisterIP:
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"time"
)

// Admin 后台管理员.
// Admin user
type Admin struct {
Account string `bson:"account"`
Password string `bson:"password"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package admin

import "context"

// ClientConfig 客户端相关配置项.
// ClientConfig config
type ClientConfig struct {
Key string `bson:"key"`
Value string `bson:"value"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/forbidden_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"time"
)

// ForbiddenAccount 封号表.
// ForbiddenAccount table
type ForbiddenAccount struct {
UserID string `bson:"user_id"`
Reason string `bson:"reason"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/admin/invitation_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// 邀请码被注册使用.
type InvitationRegister struct {
InvitationCode string `bson:"invitation_code"`
UsedByUserID string `bson:"used_by_user_id"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// 禁止ip登录 注册.
type IPForbidden struct {
IP string `bson:"ip"`
LimitRegister bool `bson:"limit_register"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/admin/limit_user_login_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// 限制userID只能在某些ip登录.
type LimitUserLoginIP struct {
UserID string `bson:"user_id"`
IP string `bson:"ip"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/admin/register_add_friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// RegisterAddFriend 注册时默认好友.
type RegisterAddFriend struct {
UserID string `bson:"user_id"`
CreateTime time.Time `bson:"create_time"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/admin/register_add_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// RegisterAddGroup 注册时默认群组.
type RegisterAddGroup struct {
GroupID string `bson:"group_id"`
CreateTime time.Time `bson:"create_time"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/chat/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"
)

// Account 账号密码表.
type Account struct {
UserID string `bson:"user_id"`
Password string `bson:"password"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/chat/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"
)

// Attribute 用户属性表.
type Attribute struct {
UserID string `bson:"user_id"`
Account string `bson:"account"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/chat/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"
)

// Register 注册信息表.
type Register struct {
UserID string `bson:"user_id"`
DeviceID string `bson:"device_id"`
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/table/chat/user_login_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"
)

// 用户登录信息表.
type UserLoginRecord struct {
UserID string `bson:"user_id"`
LoginTime time.Time `bson:"login_time"`
Expand Down
8 changes: 4 additions & 4 deletions pkg/common/xlsx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ParseSheet(file *excelize.File, v interface{}) error {
} else if sheetIndex < 0 {
return nil
}
fieldIndex := make(map[string]int) // 结构体对应的下标
fieldIndex := make(map[string]int)
for i := 0; i < itemType.NumField(); i++ {
field := itemType.Field(i)
alias := field.Tag.Get("column")
Expand All @@ -54,8 +54,8 @@ func ParseSheet(file *excelize.File, v interface{}) error {
if len(fieldIndex) == 0 {
return errors.New("empty column struct")
}
sheetIndex := make(map[string]int) // sheet 对应的下标
for i := 1; ; i++ { // 第一行
sheetIndex := make(map[string]int)
for i := 1; ; i++ {
name, err := file.GetCellValue(sheetName, GetAxis(i, 1))
if err != nil {
return err
Expand Down Expand Up @@ -88,7 +88,7 @@ func ParseSheet(file *excelize.File, v interface{}) error {
return err
}
}
if notEmpty > 0 { // 空行表示结束
if notEmpty > 0 {
putItem(item)
} else {
break
Expand Down
13 changes: 6 additions & 7 deletions pkg/common/xlsx/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ func Num2AZ(num int) string {
var (
str string
k int
temp []int //保存转化后每一位数据的值,然后通过索引的方式匹配A-Z
temp []int
)
//用来匹配的字符A-Z
slices := []string{"", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

if num > 26 { //数据大于26需要进行拆分
if num > 26 {
for {
k = num % 26 //从个位开始拆分,如果求余为0,说明末尾为26,也就是Z,如果是转化为26进制数,则末尾是可以为0的,这里必须为A-Z中的一个
k = num % 26
if k == 0 {
temp = append(temp, 26)
k = 26
} else {
temp = append(temp, k)
}
num = (num - k) / 26 //减去num最后一位数的值,因为已经记录在temp中
if num <= 26 { //小于等于26直接进行匹配,不需要进行数据拆分
num = (num - k) / 26
if num <= 26 {
temp = append(temp, num)
break
}
Expand All @@ -46,7 +45,7 @@ func Num2AZ(num int) string {
return slices[num]
}
for _, value := range temp {
str = slices[value] + str //因为数据切分后存储顺序是反的,所以str要放在后面
str = slices[value] + str
}
return str
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/eerrs/predefine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ package eerrs
import "github.com/openimsdk/tools/errs"

var (
ErrPassword = errs.NewCodeError(20001, "PasswordError") // 密码错误
ErrAccountNotFound = errs.NewCodeError(20002, "AccountNotFound") // 账号不存在
ErrPhoneAlreadyRegister = errs.NewCodeError(20003, "PhoneAlreadyRegister") // 手机号已经注册
ErrAccountAlreadyRegister = errs.NewCodeError(20004, "AccountAlreadyRegister") // 账号已经注册
ErrVerifyCodeSendFrequently = errs.NewCodeError(20005, "VerifyCodeSendFrequently") // 频繁获取验证码
ErrVerifyCodeNotMatch = errs.NewCodeError(20006, "VerifyCodeNotMatch") // 验证码错误
ErrVerifyCodeExpired = errs.NewCodeError(20007, "VerifyCodeExpired") // 验证码过期
ErrVerifyCodeMaxCount = errs.NewCodeError(20008, "VerifyCodeMaxCount") // 验证码失败次数过多
ErrVerifyCodeUsed = errs.NewCodeError(20009, "VerifyCodeUsed") // 已经使用
ErrInvitationCodeUsed = errs.NewCodeError(20010, "InvitationCodeUsed") // 邀请码已经使用
ErrInvitationNotFound = errs.NewCodeError(20011, "InvitationNotFound") // 邀请码不存在
ErrForbidden = errs.NewCodeError(20012, "Forbidden") // 限制登录注册
ErrRefuseFriend = errs.NewCodeError(20013, "RefuseFriend") // 拒绝添加好友
ErrEmailAlreadyRegister = errs.NewCodeError(20014, "EmailAlreadyRegister") // 邮箱已经注册
ErrPassword = errs.NewCodeError(20001, "PasswordError")
ErrAccountNotFound = errs.NewCodeError(20002, "AccountNotFound")
ErrPhoneAlreadyRegister = errs.NewCodeError(20003, "PhoneAlreadyRegister")
ErrAccountAlreadyRegister = errs.NewCodeError(20004, "AccountAlreadyRegister")
ErrVerifyCodeSendFrequently = errs.NewCodeError(20005, "VerifyCodeSendFrequently")
ErrVerifyCodeNotMatch = errs.NewCodeError(20006, "VerifyCodeNotMatch")
ErrVerifyCodeExpired = errs.NewCodeError(20007, "VerifyCodeExpired")
ErrVerifyCodeMaxCount = errs.NewCodeError(20008, "VerifyCodeMaxCount")
ErrVerifyCodeUsed = errs.NewCodeError(20009, "VerifyCodeUsed")
ErrInvitationCodeUsed = errs.NewCodeError(20010, "InvitationCodeUsed")
ErrInvitationNotFound = errs.NewCodeError(20011, "InvitationNotFound")
ErrForbidden = errs.NewCodeError(20012, "Forbidden")
ErrRefuseFriend = errs.NewCodeError(20013, "RefuseFriend")
ErrEmailAlreadyRegister = errs.NewCodeError(20014, "EmailAlreadyRegister")
)
2 changes: 1 addition & 1 deletion pkg/email/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ func (m *mail) SendMail(ctx context.Context, mail string, verifyCode string) err
msg.SetHeader(`From`, m.senderMail)
msg.SetHeader(`To`, []string{mail}...)
msg.SetHeader(`Subject`, m.title)
msg.SetBody(`text/html`, fmt.Sprintf("您的验证码为:%s,该验证码5分钟内有效,请勿泄露于他人。", verifyCode))
msg.SetBody(`text/html`, fmt.Sprintf("Your verification code is: %s. This code is valid for 5 minutes and should not be shared with others", verifyCode))
return errs.Wrap(m.dail.DialAndSend(msg))
}