From 8ddd1311f5988d68cacf0c528e8fe7dc9faa9e6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roman=20Smr=C5=BE?= <roman.smrz@seznam.cz>
Date: Sat, 8 Mar 2025 21:09:22 +0100
Subject: Deleting chatrooms

Changelog: Added `/delete` command to delete chatrooms for current user
---
 src/Erebos/Conversation.hs | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'src/Erebos/Conversation.hs')

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)
-- 
cgit v1.2.3