3
0

Add support for fetching pinned & bookmarked messages

This commit is contained in:
Denis Arh
2018-11-08 22:48:55 +01:00
parent 5b832bbea1
commit 0ee0951630
3 changed files with 16 additions and 0 deletions
+3
View File
@@ -23,6 +23,9 @@ type (
FirstID uint64 `json:"firstID,string"`
LastID uint64 `json:"lastID,string"`
RepliesTo uint64 `json:"repliesTo,string"`
PinnedOnly bool `json:pinned`
BookmarkedOnly bool `json:bookmarked`
}
MessageThreads struct {
+10
View File
@@ -139,6 +139,16 @@ func (r *message) FindMessages(filter *types.MessageFilter) (types.MessageSet, e
params = append(params, filter.ToID)
}
if filter.BookmarkedOnly || filter.PinnedOnly {
sql += " AND id IN (SELECT rel_message FROM message_flags WHERE flag = ?) "
if filter.PinnedOnly {
params = append(params, types.MessageFlagBookmarkedMessage)
} else {
params = append(params, types.MessageFlagPinnedToChannel)
}
}
sql += " AND rel_channel IN " + sqlChannelAccess
params = append(params, filter.CurrentUserID, types.ChannelTypePublic)
+3
View File
@@ -54,6 +54,9 @@ type (
FromID uint64
ToID uint64
PinnedOnly bool
BookmarkedOnly bool
Limit uint
}