Fix conversation context topic fallback
This commit is contained in:
@@ -5736,6 +5736,39 @@ func TestServeIMConversationContextAcceptsUserTopic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeIMConversationContextAcceptsFriendListTopicFallback(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
expectIMBearer(t, ctrl, "token-1", 7, 1)
|
||||
oldRelations := store.Relations
|
||||
peer := types.Uid(2)
|
||||
legacyTopic := types.Uid(2).P2PName(types.Uid(3))
|
||||
store.Relations = &testRelationsStore{friends: []types.FriendListItem{{
|
||||
Friendship: types.Friendship{
|
||||
TenantID: 7,
|
||||
UserID: types.Uid(1),
|
||||
PeerID: peer,
|
||||
Status: types.RelationshipFriend,
|
||||
Topic: legacyTopic,
|
||||
},
|
||||
}}}
|
||||
defer func() { store.Relations = oldRelations }()
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/v1/im/conversations/"+legacyTopic+"/context", nil)
|
||||
req.Header.Set("Authorization", "Bearer token-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
serveIMConversationContext(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status: got %d, want %d; body=%s", rec.Code, http.StatusOK, rec.Body.String())
|
||||
}
|
||||
data := decodeIMHTTPResponse(t, rec).Data.(map[string]any)
|
||||
if data["topic"] != legacyTopic || data["peer_user_id"] != peer.UserId() {
|
||||
t.Fatalf("unexpected context response: %#v", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeP2PConversationTopicParsesTinodeTopic(t *testing.T) {
|
||||
user := types.Uid(1)
|
||||
peer := types.Uid(2)
|
||||
|
||||
Reference in New Issue
Block a user