48 lines
998 B
Go
48 lines
998 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
|
"gitlab.33.cn/chat/dtalk/service/group/service"
|
|
)
|
|
|
|
type GetMuteListLogic struct {
|
|
ctx context.Context
|
|
svc *service.Service
|
|
}
|
|
|
|
func NewGetMuteListLogic(ctx context.Context, svc *service.Service) *GetMuteListLogic {
|
|
return &GetMuteListLogic{
|
|
ctx: ctx,
|
|
svc: svc,
|
|
}
|
|
}
|
|
|
|
// GetMuteList 查询群禁言列表
|
|
func (l *GetMuteListLogic) GetMuteList(req *pb.GetMuteListReq) (*pb.GetMuteListResp, error) {
|
|
groupId := req.GroupId
|
|
personId := req.PersonId
|
|
|
|
_, err := l.svc.GetGroupInfoByGroupId(l.ctx, groupId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
person, err := l.svc.GetPersonByMemberIdAndGroupId(l.ctx, personId, groupId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err = person.IsAdmin(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
muteList, err := l.svc.GetGroupMembersMutedByGroupId(groupId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &pb.GetMuteListResp{
|
|
Members: NewRPCGroupMemberInfos(muteList),
|
|
}, nil
|
|
}
|