From 55bf7458d7f2bf36c67522f6b1d47be8ffa93800 Mon Sep 17 00:00:00 2001 From: Shivashis Padhi Date: Thu, 28 Jul 2022 12:35:17 +0530 Subject: [PATCH] Temporarily add second participant information for self dms --- store/sqlstore/post_store.go | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 5d423efc5d..5a746ae558 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -3027,29 +3027,27 @@ func postProcessTopDMs(s *SqlPostStore, userID string, topDMs []*model.TopDM) ([ } else { secondParticipantId = participants[0] } - - // filter topDM out if second user is bot - users, err := s.User().GetProfileByIds(context.Background(), []string{secondParticipantId}, &store.UserGetByIdsOpts{}, true) - if err != nil { - return nil, errors.Wrapf(err, "failed to get second participant information for user-id: %s", topDM.SecondParticipant) - } - if users[0].IsBot { - continue - } - user := users[0] - topDM.SecondParticipant = &model.TopDMInsightUserInformation{ - InsightUserInformation: model.InsightUserInformation{ - Id: user.Id, - LastPictureUpdate: user.LastPictureUpdate, - FirstName: user.FirstName, - LastName: user.LastName, - Username: user.Username, - NickName: user.Nickname, - }, - Position: user.Position, - } } - + // filter topDM out if second user is bot + users, err := s.User().GetProfileByIds(context.Background(), []string{secondParticipantId}, &store.UserGetByIdsOpts{}, true) + if err != nil { + return nil, errors.Wrapf(err, "failed to get second participant information for user-id: %s", topDM.SecondParticipant.Id) + } + if users[0].IsBot { + continue + } + user := users[0] + topDM.SecondParticipant = &model.TopDMInsightUserInformation{ + InsightUserInformation: model.InsightUserInformation{ + Id: user.Id, + LastPictureUpdate: user.LastPictureUpdate, + FirstName: user.FirstName, + LastName: user.LastName, + Username: user.Username, + NickName: user.Nickname, + }, + Position: user.Position, + } topDMsFiltered = append(topDMsFiltered, topDM) } return topDMsFiltered, nil