FindMessages now only selects messages from channles we have access to
This commit is contained in:
parent
9a8bef927d
commit
5006a14935
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user