Преглед изворни кода

fix regression in blocking feature

when user A blocks user B, user B is not signed off in user A's
buddy list, but user A is signed off in user B's buddy list. this
commit ensures both parties are notified of each other's departure.
Mike пре 2 година
родитељ
комит
652539ed20
2 измењених фајлова са 17 додато и 0 уклоњено
  1. 2 0
      foodgroup/feedbag.go
  2. 15 0
      foodgroup/feedbag_test.go

+ 2 - 0
foodgroup/feedbag.go

@@ -208,6 +208,8 @@ func (s FeedbagService) UpsertItem(ctx context.Context, sess *state.Session, inF
 			}
 			// alert blocked buddy that current user is offline
 			unicastDeparture(ctx, sess, blockedSess, s.messageRelayer)
+			// tell blocker that blocked user is offline
+			unicastDeparture(ctx, blockedSess, sess, s.messageRelayer)
 		case wire.FeedbagClassIdBart:
 			if err := s.broadcastIconUpdate(ctx, sess, item); err != nil {
 				return wire.SNACMessage{}, err

+ 15 - 0
foodgroup/feedbag_test.go

@@ -631,6 +631,21 @@ func TestFeedbagService_UpsertItem(t *testing.T) {
 								},
 							},
 						},
+						{
+							screenName: "user_screen_name",
+							message: wire.SNACMessage{
+								Frame: wire.SNACFrame{
+									FoodGroup: wire.Buddy,
+									SubGroup:  wire.BuddyDeparted,
+								},
+								Body: wire.SNAC_0x03_0x0C_BuddyDeparted{
+									TLVUserInfo: wire.TLVUserInfo{
+										ScreenName:   "buddy_1",
+										WarningLevel: 0,
+									},
+								},
+							},
+						},
 					},
 				},
 			},