Allow emoji reactions

This commit is contained in:
Andrea Maria Piana 2020-12-22 17:20:12 +01:00
parent f3afa962c6
commit 06dcf0cea9
3 changed files with 12 additions and 3 deletions

View File

@ -755,11 +755,18 @@ func (m *MessageHandler) matchChatEntity(chatEntity common.ChatEntity, chats map
return nil, errors.New("not an community chat")
}
var emojiReaction bool
// We allow emoji reactions from anyone
switch chatEntity.(type) {
case *EmojiReaction:
emojiReaction = true
}
canPost, err := m.communitiesManager.CanPost(chatEntity.GetSigPubKey(), chat.CommunityID, chat.CommunityChatID(), chatEntity.GetGrant())
if err != nil {
return nil, err
}
if !canPost {
if !emojiReaction && !canPost {
return nil, errors.New("user can't post")
}

View File

@ -2304,7 +2304,9 @@ func (m *Messenger) dispatchMessage(ctx context.Context, spec common.RawMessage)
if err != nil {
return nil, err
}
if !canPost {
// We allow emoji reactions by anyone
if spec.MessageType != protobuf.ApplicationMetadataMessage_EMOJI_REACTION && !canPost {
m.logger.Error("can't post on chat", zap.String("chat-id", chat.ID), zap.String("chat-name", chat.Name))
return nil, errors.New("can't post on chat")

View File

@ -178,7 +178,7 @@ func (db sqlitePersistence) DeleteChat(chatID string) (err error) {
return
}
_, err := tx.Exec(`DELETE FROM user_messages WHERE local_chat_id = ?`, chatID)
_, err = tx.Exec(`DELETE FROM user_messages WHERE local_chat_id = ?`, chatID)
return
}