Add support for fetching pinned & bookmarked messages
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ type (
|
||||
FromID uint64
|
||||
ToID uint64
|
||||
|
||||
PinnedOnly bool
|
||||
BookmarkedOnly bool
|
||||
|
||||
Limit uint
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user