From a6f02008fe000272a24d1585598e163ade452ee2 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Tue, 12 Mar 2019 18:10:11 +0100 Subject: [PATCH] Fix permission check for message filtering and make it conditional --- messaging/service/message.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging/service/message.go b/messaging/service/message.go index fe530be4a..6da3c611b 100644 --- a/messaging/service/message.go +++ b/messaging/service/message.go @@ -97,7 +97,7 @@ func (svc *message) With(ctx context.Context) MessageService { func (svc *message) Find(filter *types.MessageFilter) (mm types.MessageSet, err error) { filter.CurrentUserID = auth.GetIdentityFromContext(svc.ctx).Identity() - if !svc.prm.CanReadChannelByID(filter.ChannelID) { + if filter.ChannelID > 0 && !svc.prm.CanReadChannelByID(filter.ChannelID) { return nil, errors.New("not allowed to access channel") } @@ -112,7 +112,7 @@ func (svc *message) Find(filter *types.MessageFilter) (mm types.MessageSet, err func (svc *message) FindThreads(filter *types.MessageFilter) (mm types.MessageSet, err error) { filter.CurrentUserID = auth.GetIdentityFromContext(svc.ctx).Identity() - if !svc.prm.CanReadChannelByID(filter.ChannelID) { + if filter.ChannelID > 0 && !svc.prm.CanReadChannelByID(filter.ChannelID) { return nil, errors.New("not allowed to access channel") }