@@ -13,6 +13,17 @@ import (
13
13
)
14
14
15
15
func (r * Relation ) SyncBothFriendRequest (ctx context.Context , fromUserID , toUserID string ) error {
16
+ if toUserID == r .loginUserID {
17
+ if ! r .requestRecvSyncerLock .TryLock () {
18
+ return nil
19
+ }
20
+ defer r .requestRecvSyncerLock .Unlock ()
21
+ } else {
22
+ if ! r .requestSendSyncerLock .TryLock () {
23
+ return nil
24
+ }
25
+ defer r .requestSendSyncerLock .Unlock ()
26
+ }
16
27
req := & relation.GetDesignatedFriendsApplyReq {FromUserID : fromUserID , ToUserID : toUserID }
17
28
friendRequests , err := r .getDesignatedFriendsApply (ctx , req )
18
29
if err != nil {
@@ -32,6 +43,10 @@ func (r *Relation) SyncBothFriendRequest(ctx context.Context, fromUserID, toUser
32
43
33
44
// SyncAllSelfFriendApplication send
34
45
func (r * Relation ) SyncAllSelfFriendApplication (ctx context.Context ) error {
46
+ if ! r .requestSendSyncerLock .TryLock () {
47
+ return nil
48
+ }
49
+ defer r .requestSendSyncerLock .Unlock ()
35
50
req := & relation.GetPaginationFriendsApplyFromReq {UserID : r .loginUserID , Pagination : & sdkws.RequestPagination {}}
36
51
requests , err := r .getSelfFriendApplicationList (ctx , req )
37
52
if err != nil {
@@ -45,6 +60,10 @@ func (r *Relation) SyncAllSelfFriendApplication(ctx context.Context) error {
45
60
}
46
61
47
62
func (r * Relation ) SyncAllSelfFriendApplicationWithoutNotice (ctx context.Context ) error {
63
+ if ! r .requestSendSyncerLock .TryLock () {
64
+ return nil
65
+ }
66
+ defer r .requestSendSyncerLock .Unlock ()
48
67
req := & relation.GetPaginationFriendsApplyFromReq {UserID : r .loginUserID , Pagination : & sdkws.RequestPagination {}}
49
68
requests , err := r .getSelfFriendApplicationList (ctx , req )
50
69
if err != nil {
@@ -59,6 +78,10 @@ func (r *Relation) SyncAllSelfFriendApplicationWithoutNotice(ctx context.Context
59
78
60
79
// SyncAllFriendApplication recv
61
80
func (r * Relation ) SyncAllFriendApplication (ctx context.Context ) error {
81
+ if ! r .requestRecvSyncerLock .TryLock () {
82
+ return nil
83
+ }
84
+ defer r .requestRecvSyncerLock .Unlock ()
62
85
req := & relation.GetPaginationFriendsApplyToReq {UserID : r .loginUserID , Pagination : & sdkws.RequestPagination {}}
63
86
requests , err := r .getFriendApplicationList (ctx , req )
64
87
if err != nil {
@@ -71,6 +94,10 @@ func (r *Relation) SyncAllFriendApplication(ctx context.Context) error {
71
94
return r .requestRecvSyncer .Sync (ctx , datautil .Batch (ServerFriendRequestToLocalFriendRequest , requests ), localData , nil )
72
95
}
73
96
func (r * Relation ) SyncAllFriendApplicationWithoutNotice (ctx context.Context ) error {
97
+ if ! r .requestRecvSyncerLock .TryLock () {
98
+ return nil
99
+ }
100
+ defer r .requestRecvSyncerLock .Unlock ()
74
101
req := & relation.GetPaginationFriendsApplyToReq {UserID : r .loginUserID , Pagination : & sdkws.RequestPagination {}}
75
102
requests , err := r .getFriendApplicationList (ctx , req )
76
103
if err != nil {
0 commit comments