diff --git a/pkg/scraper/api_types_dms_test.go b/pkg/scraper/api_types_dms_test.go index 5094bc3..227176f 100644 --- a/pkg/scraper/api_types_dms_test.go +++ b/pkg/scraper/api_types_dms_test.go @@ -74,7 +74,7 @@ func TestParseAPIDMConversation(t *testing.T) { assert.Len(chat_room.Participants, 2) - p1 := chat_room.Participants[0] + p1 := chat_room.Participants[1458284524761075714] assert.Equal(UserID(1458284524761075714), p1.UserID) assert.Equal(DMMessageID(1665936253483614212), p1.LastReadEventID) assert.True(p1.IsChatSettingsValid) @@ -84,7 +84,7 @@ func TestParseAPIDMConversation(t *testing.T) { assert.False(p1.IsMuted) assert.Equal("AT_END", p1.Status) - p2 := chat_room.Participants[1] + p2 := chat_room.Participants[1488963321701171204] assert.Equal(UserID(1488963321701171204), p2.UserID) assert.Equal(DMMessageID(1663623062195957773), p2.LastReadEventID) assert.False(p2.IsChatSettingsValid) diff --git a/pkg/scraper/dm_chat_room.go b/pkg/scraper/dm_chat_room.go index ffbef63..8ac560f 100644 --- a/pkg/scraper/dm_chat_room.go +++ b/pkg/scraper/dm_chat_room.go @@ -22,7 +22,7 @@ type DMChatRoom struct { LastMessagedAt Timestamp `db:"last_messaged_at"` IsNSFW bool `db:"is_nsfw"` - Participants []DMChatParticipant + Participants map[UserID]DMChatParticipant } func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom { @@ -32,7 +32,7 @@ func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom { ret.LastMessagedAt = TimestampFromUnix(int64(api_room.SortTimestamp)) ret.IsNSFW = api_room.NSFW - ret.Participants = []DMChatParticipant{} + ret.Participants = make(map[UserID]DMChatParticipant) for _, api_participant := range api_room.Participants { participant := DMChatParticipant{} participant.UserID = UserID(api_participant.UserID) @@ -48,7 +48,7 @@ func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom { participant.Status = api_room.Status participant.IsChatSettingsValid = true } - ret.Participants = append(ret.Participants, participant) + ret.Participants[participant.UserID] = participant } return ret }