3
0

FindMessages now only selects messages from channles we have access to

This commit is contained in:
Denis Arh 2018-10-29 08:34:43 +01:00
parent 9a8bef927d
commit 5006a14935
3 changed files with 7 additions and 2 deletions

View File

@ -112,6 +112,9 @@ func (r *message) FindMessages(filter *types.MessageFilter) (types.MessageSet, e
}
}
sql += " AND rel_channel IN " + sqlChannelAccess
params = append(params, filter.CurrentUserID, types.ChannelTypePublic)
sql += " ORDER BY id DESC"
if filter.Limit == 0 || filter.Limit > MESSAGES_MAX_LIMIT {

View File

@ -78,10 +78,9 @@ func (svc *message) With(ctx context.Context) MessageService {
func (svc *message) Find(filter *types.MessageFilter) (mm types.MessageSet, err error) {
// @todo get user from context
var currentUserID uint64 = repository.Identity(svc.ctx)
filter.CurrentUserID = repository.Identity(svc.ctx)
// @todo verify if current user can access & read from this channel
_ = currentUserID
_ = filter.ChannelID
mm, err = svc.message.FindMessages(filter)

View File

@ -28,6 +28,9 @@ type (
MessageFilter struct {
Query string
// Required param to filter accessible messages
CurrentUserID uint64
// All messages that belong to a channel
ChannelID uint64