Skip to content

feat(instagram): save deleted messages - #1531

Open
vishnuprasad0 wants to merge 3 commits into
crimera:devfrom
vishnuprasad0:feat/view-unsent-messages
Open

feat(instagram): save deleted messages#1531
vishnuprasad0 wants to merge 3 commits into
crimera:devfrom
vishnuprasad0:feat/view-unsent-messages

Conversation

@vishnuprasad0

Copy link
Copy Markdown

Saves incoming DMs as they arrive so you can still read them after they're unsent.
Adds a button on the DM header to view a chat's deleted messages (or all of them). Works for text and media — photos, videos, shared posts/reels and voice notes. Tapping a saved message lets you open, download or copy it.
Toggle it under DM settings.

Captures incoming DMs locally as they arrive so they stay readable after the
sender unsends them. Adds a history button on the DM action bar and a viewer
activity listing per-chat (or all) deleted messages, with per-sender attribution.
Media is recovered too: photos, videos, media/raven/clip/reel shares and voice
notes resolve their CDN url at patch time via the DirectItem entity; xma reshares
recover the post/reel permalink and open in Instagram. Tapping a saved item offers
open/download/copy, reusing the existing download feature.
Gated behind a 'Save deleted messages' toggle under DM settings.
@vishnuprasad0
vishnuprasad0 changed the base branch from main to dev July 15, 2026 11:47
@swakwork

swakwork commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the new PR. is it WIP or ready to ship?

@vishnuprasad0

Copy link
Copy Markdown
Author

Not WIP, it's ready — can push fixes later if anything comes up. It closes #1073

/** First String field on {@code o} whose value is an instagram.com post/reel permalink, query stripped. */
private String firstInstagramPermalink(Object o) {
try {
for (java.lang.reflect.Field g : o.getClass().getDeclaredFields()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid finding fields and methods on runtime

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same fix here , this is still inside xmaReshareLink() so it uses the same patch time resolved names..
no runtime field hunting. the instagram.com check is just filtering out non-post xma links (like xma_link)
updated in the last commit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I still don't get it, why do we required to find the element everytime on runtime

@swakwork

Copy link
Copy Markdown
Collaborator

I finally got time to test it patch. First of all the patch works amazing. I havent dig deep into the code. I just got 2 suggestions.

  1. Setting the orientation to Portrait -> Instagram atm supports tablets, with supports landscape as well and some freaks like me would be using on them. So we may not need to lock in portrait unless the UI is broken.

  2. Action bar header -> The action bar says "this chat" even when I try to access via Piko Settings.

  3. User Id -> Is there any reason why we are using user id instead of user name or group name ? Sure in the DB we can use id as the primary key as name can be modified by the user.

The UI could be more intuitive, but ya, we can discuss or handle it as a future PR.

Thanks for this PR 💌

…om settings

Drop the hard portrait lock on the deleted-messages screen in favour of
SCREEN_ORIENTATION_USER so tablets/landscape stay usable while still honouring
a user's rotation lock. Open the settings entry point unscoped so it always
lists all chats instead of inheriting the last-opened thread.
@swakwork

Copy link
Copy Markdown
Collaborator

Is username something that can be achieved?

@vishnuprasad0

Copy link
Copy Markdown
Author

Is username something that can be achieved?

Hey ,
DirectItem doesn't carry a username field, only item_id, user_id, text, timestamp, hide_in_thread, thread_key. So there's no username to grab at the moment a message is captured.

We get the username separately: a small directory (sender_id → username) that's filled from the thread's participant list via noteThreadUsers(). That hook only runs when the participant list loads/refreshes for a thread — it writes the name once and doesn't refresh after. So if a sender's first message lands before that list loads, the row keeps the raw id; and it won't follow later username changes. That's why it can look like it only worked the first time.

@swakwork

Copy link
Copy Markdown
Collaborator

Hey , DirectItem doesn't carry a username field, only item_id, user_id, text, timestamp, hide_in_thread, thread_key. So there's no username to grab at the moment a message is captured.

I'm pretty sure they would expect user names.

Also does it capture all the messages or only those that are deleted? Either way we may need to add delete data to clear media cache as well as db

@vishnuprasad0

Copy link
Copy Markdown
Author

Hey , DirectItem doesn't carry a username field, only item_id, user_id, text, timestamp, hide_in_thread, thread_key. So there's no username to grab at the moment a message is captured.

I'm pretty sure they would expect user names.

Also does it capture all the messages or only those that are deleted? Either way we may need to add delete data to clear media cache as well as db

  1. yep i agree with youu .... but Usernames do display , the sender name resolves from the participant directory, then thread title. It only falls back to a raw id in one case: the very first message from a sender before that thread's participant list has been harvested. On an active/opened chat it shows names fine. Did you see the raw id on an active chat, or just on the first-ever message?

  2. Clear button already exists as user choice . DeletedMessagesActivity has:
    A "Clear" action in the toolbar (line 96-117)
    clearSaved(threadId) wipes this chat's rows, or all rows when opened from settings.

there's no separate media cache to clear — media isn't downloaded, we only store the CDN/permalink URL as the row content. Clearing the DB row is clearing the media reference tooo

@swakwork

Copy link
Copy Markdown
Collaborator
  1. yep i agree with youu .... but Usernames do display , the sender name resolves from the participant directory, then thread title. It only falls back to a raw id in one case: the very first message from a sender before that thread's participant list has been harvested. On an active/opened chat it shows names fine. Did you see the raw id on an active chat, or just on the first-ever message?

I got users ids on a existing chat ( 1on1 chat not a group)

  1. Clear button already exists as user choice . DeletedMessagesActivity has:
    A "Clear" action in the toolbar (line 96-117)
    clearSaved(threadId) wipes this chat's rows, or all rows when opened from settings.

there's no separate media cache to clear — media isn't downloaded, we only store the CDN/permalink URL as the row content. Clearing the DB row is clearing the media reference tooo

My bad I haven't explored it much

@vippium

vippium commented Jul 23, 2026

Copy link
Copy Markdown

@vishnuprasad0 Will it also work for Disappearing Messages or not. Like if someone in chat enables the disappearing messages after 24hr.

I think it should be merged with it. Bcoz both works in the same way.

@swakwork

Copy link
Copy Markdown
Collaborator

Hey, can you test the PR on 439 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants