parent
a85f6b8287
commit
d3fe5cdf34
@ -1,20 +1,38 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{}
|
||||
_, err := db.DB.GetSuperGroupByUserID(req.UserID)
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
userToSuperGroup, err := db.DB.GetSuperGroupByUserID(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed", err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return resp, nil
|
||||
}
|
||||
for _, groupID := range userToSuperGroup.GroupIDList {
|
||||
groupInfoDB, err := imdb.GetGroupInfoByGroupID(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupInfoByGroupID failed", groupID, err.Error())
|
||||
continue
|
||||
}
|
||||
groupInfo := &commonPb.GroupInfo{}
|
||||
if err := utils.CopyStructFields(groupInfo, groupInfoDB); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
resp.GroupList = append(resp.GroupList, groupInfo)
|
||||
}
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func SuperGroupNotification(operationID, sendID, recvID string) {
|
||||
//var tips sdk.TipsComm
|
||||
//var err error
|
||||
//marshaler := jsonpb.Marshaler{
|
||||
// OrigName: true,
|
||||
// EnumsAsInts: false,
|
||||
// EmitDefaults: false,
|
||||
//}
|
||||
//tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||
n := &NotificationMsg{
|
||||
SendID: sendID,
|
||||
RecvID: recvID,
|
||||
MsgFrom: constant.UserMsgType,
|
||||
ContentType: constant.SuperGroupUpdateNotification,
|
||||
SessionType: constant.SingleChatType,
|
||||
OperationID: operationID,
|
||||
}
|
||||
//n.Content, err = proto.Marshal(&tips)
|
||||
//if err != nil {
|
||||
// log.NewError(operationID, utils.GetSelfFuncName(), "proto.Marshal failed")
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
|
||||
Notification(n)
|
||||
}
|
Loading…
Reference in new issue