|
|
@ -17,13 +17,13 @@ package group
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
|
|
|
"github.com/openimsdk/protocol/constant"
|
|
|
|
"github.com/openimsdk/protocol/constant"
|
|
|
|
pbgroup "github.com/openimsdk/protocol/group"
|
|
|
|
pbgroup "github.com/openimsdk/protocol/group"
|
|
|
|
"github.com/openimsdk/protocol/sdkws"
|
|
|
|
"github.com/openimsdk/protocol/sdkws"
|
|
|
@ -34,6 +34,12 @@ import (
|
|
|
|
"github.com/openimsdk/tools/utils/stringutil"
|
|
|
|
"github.com/openimsdk/tools/utils/stringutil"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GroupApplicationReceiver
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
applicantReceiver = iota
|
|
|
|
|
|
|
|
adminReceiver
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, userRpcClient *rpcclient.UserRpcClient, config *Config, fn func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error)) *GroupNotificationSender {
|
|
|
|
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, userRpcClient *rpcclient.UserRpcClient, config *Config, fn func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error)) *GroupNotificationSender {
|
|
|
|
return &GroupNotificationSender{
|
|
|
|
return &GroupNotificationSender{
|
|
|
|
NotificationSender: rpcclient.NewNotificationSender(&config.NotificationConfig, rpcclient.WithRpcClient(msgRpcClient), rpcclient.WithUserRpcClient(userRpcClient)),
|
|
|
|
NotificationSender: rpcclient.NewNotificationSender(&config.NotificationConfig, rpcclient.WithRpcClient(msgRpcClient), rpcclient.WithUserRpcClient(userRpcClient)),
|
|
|
@ -400,15 +406,17 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg}
|
|
|
|
|
|
|
|
if err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
|
|
|
var opUser *sdkws.GroupMemberFullInfo
|
|
|
|
|
|
|
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, userID := range append(userIDs, req.FromUserID) {
|
|
|
|
for _, userID := range append(userIDs, req.FromUserID) {
|
|
|
|
|
|
|
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, OpUser: opUser, HandleMsg: req.HandledMsg}
|
|
|
|
if userID == req.FromUserID {
|
|
|
|
if userID == req.FromUserID {
|
|
|
|
tips.ReceiverAs = 0
|
|
|
|
tips.ReceiverAs = applicantReceiver
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
tips.ReceiverAs = 1
|
|
|
|
tips.ReceiverAs = adminReceiver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
|
|
|
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -431,15 +439,17 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
|
|
|
|
|
|
|
|
if err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
|
|
|
var opUser *sdkws.GroupMemberFullInfo
|
|
|
|
|
|
|
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, userID := range append(userIDs, req.FromUserID) {
|
|
|
|
for _, userID := range append(userIDs, req.FromUserID) {
|
|
|
|
|
|
|
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, OpUser: opUser, HandleMsg: req.HandledMsg}
|
|
|
|
if userID == req.FromUserID {
|
|
|
|
if userID == req.FromUserID {
|
|
|
|
tips.ReceiverAs = 0
|
|
|
|
tips.ReceiverAs = applicantReceiver
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
tips.ReceiverAs = 1
|
|
|
|
tips.ReceiverAs = adminReceiver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
|
|
|
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
|
|
|
|
}
|
|
|
|
}
|
|
|
|