You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/group/g.go

68 lines
1.8 KiB

package group
import (
"Open_IM/pkg/common/constant"
2 years ago
relation "Open_IM/pkg/common/db/mysql"
pbGroup "Open_IM/pkg/proto/group"
2 years ago
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"math/big"
"strconv"
"time"
)
2 years ago
func getDBGroupRequest(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (dbGroupRequest *relation.GroupRequest) {
dbGroupRequest = &relation.GroupRequest{}
utils.CopyStructFields(&dbGroupRequest, req)
dbGroupRequest.UserID = req.FromUserID
2 years ago
dbGroupRequest.HandleUserID = utils.OpUserID(ctx)
dbGroupRequest.HandledTime = time.Now()
return dbGroupRequest
}
2 years ago
func getDBGroupMember(ctx context.Context, groupID, userID string) (dbGroupMember *relation.GroupMember, err error) {
dbGroupMember = &relation.GroupMember{}
2 years ago
member := relation.GroupMember{}
member.GroupID = groupID
member.UserID = userID
member.RoleLevel = constant.GroupOrdinaryUsers
2 years ago
member.OperatorUserID = utils.OpUserID(ctx)
member.FaceURL = user.FaceURL
member.Nickname = user.Nickname
member.JoinSource = request.JoinSource
member.InviterUserID = request.InviterUserID
member.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
return dbGroupMember, nil
}
2 years ago
func getUsersInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.UserInfo, error) {
return nil, nil
}
2 years ago
func getUserMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.UserInfo, error) {
users, err := getUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
}
userMap := make(map[string]*sdk_ws.UserInfo)
for i, user := range users {
userMap[user.UserID] = users[i]
}
return userMap, nil
}
func genGroupID(ctx context.Context, groupID string) string {
if groupID != "" {
return groupID
}
2 years ago
groupID = utils.Md5(utils.OperationID(ctx) + strconv.FormatInt(time.Now().UnixNano(), 10))
bi := big.NewInt(0)
bi.SetString(groupID[0:8], 16)
groupID = bi.String()
return groupID
}