Skip to content

Commit

Permalink
add token (#60)
Browse files Browse the repository at this point in the history
* fix: args check

* fix/searchUserInfo

Signed-off-by: hanzhixiao <[email protected]>

* fix search normal user

Signed-off-by: hanzhixiao <[email protected]>

* fix: bug

* fix: bug

* feat token

Signed-off-by: hanzhixiao <[email protected]>

* compile

Signed-off-by: hanzhixiao <[email protected]>

---------

Signed-off-by: hanzhixiao <[email protected]>
Co-authored-by: withchao <[email protected]>
  • Loading branch information
hanzhixiao and withchao authored Jul 27, 2023
1 parent f4346c3 commit 1939145
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/chatci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
push:
branches:
- main
- develop
paths-ignore:
- "docs/**"
- "README.md"
Expand All @@ -26,6 +27,7 @@ on:
pull_request:
branches:
- main
- develop
paths-ignore:
- "README.md"
- "README_zh-CN.md"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (o *ChatApi) Login(c *gin.Context) {
apiresp.GinError(c, err)
return
}
imToken, err := o.imApiCaller.UserToken(c, resp1.UserID, constant2.NormalUser)
imToken, err := o.imApiCaller.UserToken(c, resp1.UserID, req.Platform)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ const (
)

const (
FinDAllUser = 0
FindNormalUser = 1
FinDAllUser = 2
)

const DefaultPlatform = 1
Expand Down
3 changes: 2 additions & 1 deletion pkg/common/db/database/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package database

import (
"context"
constant2 "github.com/OpenIMSDK/chat/pkg/common/constant"
admin2 "github.com/OpenIMSDK/chat/pkg/common/db/model/admin"
"github.com/OpenIMSDK/chat/pkg/common/db/model/chat"
"github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
Expand Down Expand Up @@ -114,7 +115,7 @@ func (o *ChatDatabase) TakeAttributeByUserID(ctx context.Context, userID string)

func (o *ChatDatabase) Search(ctx context.Context, normalUser int32, keyword string, genders int32, pageNumber int32, showNumber int32) (total uint32, attributes []*table.Attribute, err error) {
var forbiddenIDs []string
if normalUser == 1 {
if normalUser == constant2.NormalUser {
forbiddenIDs, err = o.forbiddenAccount.FindAllIDs(ctx)
if err != nil {
return 0, nil, err
Expand Down
5 changes: 3 additions & 2 deletions pkg/common/db/model/chat/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ func (o *Attribute) SearchNormalUser(ctx context.Context, keyword string, forbid
}
if len(forbiddenIDs) == 0 {
db = db.Where("gender in ?", genders)
} else {
db = db.Where("gender in ? and user_id not in ?", genders, forbiddenIDs)
}
if len(forbiddenIDs) > 0 {
db = db.Where("user_id not in ?", forbiddenIDs)
}
return ormutil.GormSearch[chat.Attribute](db, []string{"user_id", "account", "nickname", "phone_number"}, keyword, page, size)
}

0 comments on commit 1939145

Please sign in to comment.