diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-03-08 21:09:22 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-03-20 20:46:53 +0100 |
commit | 8ddd1311f5988d68cacf0c528e8fe7dc9faa9e6f (patch) | |
tree | 613dd3cf0f79931556ab89f52e20efd353ed713b /src/Erebos/Conversation.hs | |
parent | 8a5898cc06d54c30679678eb204725852786ee84 (diff) |
Deleting chatrooms
Changelog: Added `/delete` command to delete chatrooms for current user
Diffstat (limited to 'src/Erebos/Conversation.hs')
-rw-r--r-- | src/Erebos/Conversation.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Erebos/Conversation.hs b/src/Erebos/Conversation.hs index 63475bd..f0ffa70 100644 --- a/src/Erebos/Conversation.hs +++ b/src/Erebos/Conversation.hs @@ -18,6 +18,7 @@ module Erebos.Conversation ( conversationHistory, sendMessage, + deleteConversation, ) where import Control.Monad.Except @@ -103,3 +104,7 @@ conversationHistory (ChatroomConversation rstate) = map (\msg -> ChatroomMessage sendMessage :: (MonadHead LocalState m, MonadError String m) => Conversation -> Text -> m (Maybe Message) sendMessage (DirectMessageConversation thread) text = fmap Just $ DirectMessageMessage <$> (fromStored <$> sendDirectMessage (msgPeer thread) text) <*> pure False sendMessage (ChatroomConversation rstate) text = sendChatroomMessage rstate text >> return Nothing + +deleteConversation :: (MonadHead LocalState m, MonadError String m) => Conversation -> m () +deleteConversation (DirectMessageConversation _) = throwError "deleting direct message conversation is not supported" +deleteConversation (ChatroomConversation rstate) = deleteChatroomByStateData (head $ roomStateData rstate) |