From ec9a08b42e976d7dfe2cc644780d1a20aefdab4b Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Thu, 3 Jan 2019 22:01:17 +0100 Subject: [PATCH] Thread filter now returns only threads current user created or replied to --- sam/repository/message.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sam/repository/message.go b/sam/repository/message.go index 8f1541033..7369c5c86 100644 --- a/sam/repository/message.go +++ b/sam/repository/message.go @@ -57,6 +57,8 @@ const ( " AND rel_channel IN " + sqlChannelAccess + " AND reply_to = 0 " + " AND replies > 0 " + + // for finding only threads we've created or replied to + " AND (rel_user = ? OR id IN (SELECT DISTINCT reply_to FROM messages WHERE rel_user = ?))" + " ORDER BY id DESC " + " LIMIT ? " + ")" + @@ -176,6 +178,9 @@ func (r *message) FindThreads(filter *types.MessageFilter) (types.MessageSet, er // for sqlChannelAccess params = append(params, filter.CurrentUserID, types.ChannelTypePublic) + // for finding only threads we've created or replied to + params = append(params, filter.CurrentUserID, filter.CurrentUserID) + // for sqlMessagesThreads params = append(params, filter.Limit)