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

76 lines
2.4 KiB

package group
import (
2 years ago
"Open_IM/pkg/common/constant"
2 years ago
"Open_IM/pkg/common/tracelog"
2 years ago
pbConversation "Open_IM/pkg/proto/conversation"
2 years ago
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"errors"
"math/big"
"strconv"
"time"
)
func GetPublicUserInfoOne(ctx context.Context, userID string) (*sdk_ws.PublicUserInfo, error) {
return nil, errors.New("todo")
}
2 years ago
func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.UserInfo, error) {
return nil, errors.New("todo")
}
2 years ago
func GetUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.UserInfo, error) {
users, err := GetUsersInfo(ctx, userIDs)
2 years ago
if err != nil {
return nil, err
}
2 years ago
return utils.SliceToMap(users, func(e *sdk_ws.UserInfo) string {
return e.UserID
}), nil
}
func GetPublicUserInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.PublicUserInfo, error) {
return nil, errors.New("todo")
2 years ago
}
func GetPublicUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.PublicUserInfo, error) {
users, err := GetPublicUserInfo(ctx, userIDs)
if err != nil {
return nil, err
2 years ago
}
2 years ago
return utils.SliceToMap(users, func(e *sdk_ws.PublicUserInfo) string {
return e.UserID
}), nil
2 years ago
}
2 years ago
func GroupNotification(ctx context.Context, groupID string) {
var conversationReq pbConversation.ModifyConversationFieldReq
conversation := pbConversation.Conversation{
OwnerUserID: tracelog.GetOpUserID(ctx),
ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType),
ConversationType: constant.GroupChatType,
GroupID: groupID,
}
conversationReq.Conversation = &conversation
conversationReq.OperationID = tracelog.GetOperationID(ctx)
conversationReq.FieldType = constant.FieldGroupAtType
conversation.GroupAtType = constant.GroupNotification
conversationReq.UserIDList = cacheResp.UserIDList
_, err = pbConversation.NewConversationClient(s.etcdConn.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)).ModifyConversationField(ctx, &conversationReq)
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
}
func genGroupID(ctx context.Context, groupID string) string {
if groupID != "" {
return groupID
}
2 years ago
groupID = utils.Md5(tracelog.GetOperationID(ctx) + strconv.FormatInt(time.Now().UnixNano(), 10))
bi := big.NewInt(0)
bi.SetString(groupID[0:8], 16)
groupID = bi.String()
return groupID
}