From c577496b57cdfde70678d9dc834389a9d56b9f94 Mon Sep 17 00:00:00 2001 From: IC Rainbow Date: Wed, 20 Dec 2023 19:18:57 +0200 Subject: [PATCH] remove quote, tweak sql --- .../Chat/Migrations/M20231219_notes_folders.hs | 8 ++++---- src/Simplex/Chat/Store/Messages.hs | 11 +++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Simplex/Chat/Migrations/M20231219_notes_folders.hs b/src/Simplex/Chat/Migrations/M20231219_notes_folders.hs index 82a8d01915..31ed051895 100644 --- a/src/Simplex/Chat/Migrations/M20231219_notes_folders.hs +++ b/src/Simplex/Chat/Migrations/M20231219_notes_folders.hs @@ -12,16 +12,16 @@ m20231219_notes_folders = notes_folder_id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE, local_display_name TEXT NOT NULL, - FOREIGN KEY (user_id, local_display_name) - REFERENCES display_names (user_id, local_display_name) - ON DELETE CASCADE - ON UPDATE CASCADE, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, chat_ts TEXT, favorite INTEGER NOT NULL DEFAULT 0, unread_chat INTEGER DEFAULT 0 NOT NULL, chat_item_id INTEGER DEFAULT NULL REFERENCES chat_items ON DELETE SET NULL, + FOREIGN KEY (user_id, local_display_name) + REFERENCES display_names (user_id, local_display_name) + ON DELETE CASCADE + ON UPDATE CASCADE, ); CREATE UNIQUE INDEX idx_notes_user_local_display_name ON notes_fodler ( diff --git a/src/Simplex/Chat/Store/Messages.hs b/src/Simplex/Chat/Store/Messages.hs index 09fbc6646c..88e44b0605 100644 --- a/src/Simplex/Chat/Store/Messages.hs +++ b/src/Simplex/Chat/Store/Messages.hs @@ -736,8 +736,8 @@ getNotesChatPreview_ :: DB.Connection -> User -> ChatPreviewData 'CTNotes -> Exc getNotesChatPreview_ = error "TODO: getNotesChatPreview_" -- this function can be changed so it never fails, not only avoid failure on invalid json -toNoteChatItem :: UTCTime -> ChatItemRow :. QuoteRow -> Either StoreError (CChatItem 'CTNotes) -toNoteChatItem currentTs (((itemId, itemTs, AMsgDirection msgDir, itemContentText, itemText, itemStatus, sharedMsgId) :. (itemDeleted, deletedTs, itemEdited, createdAt, updatedAt) :. (timedTTL, timedDeleteAt, itemLive) :. (fileId_, fileName_, fileSize_, filePath, fileKey, fileNonce, fileStatus_, fileProtocol_)) :. quoteRow) = +toNoteChatItem :: UTCTime -> ChatItemRow -> Either StoreError (CChatItem 'CTNotes) +toNoteChatItem currentTs ((itemId, itemTs, AMsgDirection msgDir, itemContentText, itemText, itemStatus, sharedMsgId) :. (itemDeleted, deletedTs, itemEdited, createdAt, updatedAt) :. (timedTTL, timedDeleteAt, itemLive) :. (fileId_, fileName_, fileSize_, filePath, fileKey, fileNonce, fileStatus_, fileProtocol_)) = chatItem $ fromRight invalid $ dbParseACIContent itemContentText where invalid = ACIContent msgDir $ CIInvalidJSON itemContentText @@ -757,7 +757,7 @@ toNoteChatItem currentTs (((itemId, itemTs, AMsgDirection msgDir, itemContentTex _ -> Nothing cItem :: MsgDirectionI d => SMsgDirection d -> CIDirection 'CTNotes d -> CIStatus d -> CIContent d -> Maybe (CIFile d) -> CChatItem 'CTNotes cItem d chatDir ciStatus content file = - CChatItem d ChatItem {chatDir, meta = ciMeta content ciStatus, content, formattedText = parseMaybeMarkdownList itemText, quotedItem = toNoteQuote quoteRow, reactions = [], file} + CChatItem d ChatItem {chatDir, meta = ciMeta content ciStatus, content, formattedText = parseMaybeMarkdownList itemText, quotedItem = Nothing, reactions = [], file} badItem = Left $ SEBadChatItem itemId ciMeta :: CIContent d -> CIStatus d -> CIMeta 'CTNotes d ciMeta content status = @@ -769,11 +769,6 @@ toNoteChatItem currentTs (((itemId, itemTs, AMsgDirection msgDir, itemContentTex ciTimed :: Maybe CITimed ciTimed = timedTTL >>= \ttl -> Just CITimed {ttl, deleteAt = timedDeleteAt} -toNoteQuote :: QuoteRow -> Maybe (CIQuote 'CTNotes) -toNoteQuote qr@(_, _, _, _, quotedSent) = toQuote qr $ quotedSent >>= direction - where - direction sent = if sent then Just CIQNote else Nothing - getContactRequestChatPreviews_ :: DB.Connection -> User -> PaginationByTime -> ChatListQuery -> IO [AChatPreviewData] getContactRequestChatPreviews_ db User {userId} pagination clq = case clq of CLQFilters {favorite = False, unread = False} -> query ""