remove quote, tweak sql

This commit is contained in:
IC Rainbow
2023-12-20 19:18:57 +02:00
parent cbe134ef71
commit c577496b57
2 changed files with 7 additions and 12 deletions
@@ -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 (
+3 -8
View File
@@ -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 ""