Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better fallback SQL for backwards compatibility #157

Closed
ReagentX opened this issue Aug 6, 2023 · 0 comments · Fixed by #166
Closed

Better fallback SQL for backwards compatibility #157

ReagentX opened this issue Aug 6, 2023 · 0 comments · Fixed by #166
Assignees
Labels
crate: database Related to the database crate enhancement Requires updating an existing feature

Comments

@ReagentX
Copy link
Owner

ReagentX commented Aug 6, 2023

From @rllbe in #151:

chat_recoverable_message_join table did not exist until iOS 16(at least not for iOS 15.4), but iMessage reply feature is supported since iOS 14.

pub const RECENTLY_DELETED: &str = "chat_recoverable_message_join";

.unwrap_or(db.prepare(&format!(
"SELECT
*,
c.chat_id,
(SELECT COUNT(*) FROM {MESSAGE_ATTACHMENT_JOIN} a WHERE m.ROWID = a.message_id) as num_attachments,
(SELECT NULL) as deleted_from,
(SELECT 0) as num_replies
FROM
message as m
LEFT JOIN {CHAT_MESSAGE_JOIN} as c ON m.ROWID = c.message_id
ORDER BY
m.date;
"
)).map_err(TableError::Messages)?)

This fallback SQL ignores the "message" table altogether, causing html outputs of iOS 14/15 backup not to show any reply signs at all.

Suggestion: adding another fallback SQL statement to the function below(and also the "stream_rows" function under it) would be good:

        .unwrap_or(db.prepare(&format!(
            "SELECT
                 *,
                 c.chat_id,
                 (SELECT COUNT(*) FROM {MESSAGE_ATTACHMENT_JOIN} a WHERE m.ROWID = a.message_id) as num_attachments,
                 (SELECT NULL) as deleted_from,
                 (SELECT COUNT(*) FROM {MESSAGE} m2 WHERE m2.thread_originator_guid = m.guid) as num_replies
             FROM
                 message as m
                 LEFT JOIN {CHAT_MESSAGE_JOIN} as c ON m.ROWID = c.message_id
             ORDER BY
                 m.date;
            "
        ))
@ReagentX ReagentX added crate: database Related to the database crate enhancement Requires updating an existing feature labels Aug 6, 2023
@ReagentX ReagentX self-assigned this Aug 6, 2023
ReagentX added a commit that referenced this issue Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate: database Related to the database crate enhancement Requires updating an existing feature
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant