@@ -38,6 +38,7 @@ import (
38
38
"github.com/openimsdk/tools/utils/datautil"
39
39
"github.com/openimsdk/tools/utils/stringutil"
40
40
"go.mongodb.org/mongo-driver/mongo"
41
+ "time"
41
42
)
42
43
43
44
// GroupApplicationReceiver
@@ -572,8 +573,51 @@ func (g *GroupNotificationSender) GroupApplicationAgreeMemberEnterNotification(c
572
573
return nil
573
574
}
574
575
575
- func (g * GroupNotificationSender ) MemberEnterNotification (ctx context.Context , groupID string , entrantUserID ... string ) error {
576
- return g .GroupApplicationAgreeMemberEnterNotification (ctx , groupID , "" , entrantUserID ... )
576
+ func (g * GroupNotificationSender ) MemberEnterNotification (ctx context.Context , groupID string , entrantUserID string ) error {
577
+ var err error
578
+ defer func () {
579
+ if err != nil {
580
+ log .ZError (ctx , stringutil .GetFuncName (1 )+ " failed" , err )
581
+ }
582
+ }()
583
+
584
+ if ! g .config .RpcConfig .EnableHistoryForNewMembers {
585
+ conversationID := msgprocessor .GetConversationIDBySessionType (constant .ReadGroupChatType , groupID )
586
+ maxSeq , err := g .msgRpcClient .GetConversationMaxSeq (ctx , conversationID )
587
+ if err != nil {
588
+ return err
589
+ }
590
+ if _ , err = g .msgRpcClient .SetUserConversationsMinSeq (ctx , & msg.SetUserConversationsMinSeqReq {
591
+ UserIDs : []string {entrantUserID },
592
+ ConversationID : conversationID ,
593
+ Seq : maxSeq ,
594
+ }); err != nil {
595
+ return err
596
+ }
597
+ }
598
+
599
+ if err := g .conversationRpcClient .GroupChatFirstCreateConversation (ctx , groupID , []string {entrantUserID }); err != nil {
600
+ return err
601
+ }
602
+
603
+ var group * sdkws.GroupInfo
604
+ group , err = g .getGroupInfo (ctx , groupID )
605
+ if err != nil {
606
+ return err
607
+ }
608
+ user , err := g .getGroupMember (ctx , groupID , entrantUserID )
609
+ if err != nil {
610
+ return err
611
+ }
612
+
613
+ tips := & sdkws.MemberEnterTips {
614
+ Group : group ,
615
+ EntrantUser : user ,
616
+ OperationTime : time .Now ().UnixMilli (),
617
+ }
618
+ g .setVersion (ctx , & tips .GroupMemberVersion , & tips .GroupMemberVersionID , database .GroupMemberVersionName , tips .Group .GroupID )
619
+ g .Notification (ctx , mcontext .GetOpUserID (ctx ), group .GroupID , constant .MemberInvitedNotification , tips )
620
+ return nil
577
621
}
578
622
579
623
func (g * GroupNotificationSender ) GroupDismissedNotification (ctx context.Context , tips * sdkws.GroupDismissedTips ) {
0 commit comments