Chatty Triage

Had recently run into an issue with Chatty where it failed to deliver a couple of messages with attachments, which on it’s own wouldn’t have been that big of a deal, the problem came with those failed messages suddenly filling up the chat thread, I guess because it kept attempting to send and failing, leaving the chat so full of failed messages I couldn’t find actual messages.

Had to dig through topics till I found someone had a similar issue where they triaged the chatty database for the offending messages, but that’s not enough to stop the messages from appearing, there’s also a hidden folder under the home directory that stores the mms and a status file for it and those have to be deleted as well. Perhaps just deleting the files under the .mms directory would have fixed it but I figured may as well delete the db entries as well.

This has me wondering why chatty doesn’t have a feature built in to purge failed messages, or as I saw in the mms status files, those marked as drafts.

Would be a serious roadblock for anyone not knowledgeable in sql, even then you have to know chatty stores message data in a hidden directory.

I also have a possibly similar issue, but I have written a script that I run in the CLI(should put a chron job on it) to purge held stuck SMS messages, especially if I am not receiving an expected SMS; but since my MMS seems to be incompatible with my wireless carrier I have held messages months old in my queue and get undelivered warning SMSs. I have noticed they(the undelivered MMS errors) will go away on I believe the carrier side after a year or two(some were from my Pinephone and Pinephonepro days and same chatty incompatibility or MMS APN issues) but I still have two now in holding for maybe the last six or more months.
This is my fixSMS script I run every now and then to wipe stuck SMSs. I forget if there is a specific way in the docs to do this especially for MMSs vs SMSs.
The smsfix script:

#! /bin/sh
mmcli -m any --messaging-list-sms | a>

one short command in there, that’s it… don’t forget to chmod +x fixsms to make it executable as ./fixsms or put it in your path.

I guess it has been a while…

purism@pureos:~$ ./fixsms 
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
successfully deleted SMS from modem
purism@pureos:~$ 

this is what it looks like after running that script/command now once the buffer is cleaned:

purism@pureos:~$ ./fixsms 
error: invalid SMS string specified: 'No'
purism@pureos:~$ 

I sometimes have to run the script twice or more to get all cleared, as a few messages are still somehow locked up, especially for fresher stuck messages. But once the others get deleted they always seem to unlock and become cleanable for the script’s command.

===============================
ok I looked around… and remember I have just cleaned my modem of stuck SMSs in the post above.
you can try this, (I think this might show what we need) first list the MMSs stuck in your system

   sudo mmcli -m 0 --messaging-status

Then delete messages one at a time by index number:

   sudo mmcli -m any --messaging-delete-sms=1
   sudo mmcli -m any --messaging-delete-sms=2
   # Repeat as needed

fwiw this didn’t clear my MMSs because they are not in my system they are still at my carrier as chatty doesn’t seem(or I am doing it wrong) to be able to use the carrier’s published MMS APN despite the Internet gateway APN working great for me on my Librem 5/PureOS-Crimson.

Please understand that I do not really know how Chatty does this stuff, or how MMS somehow uses a early-mid 2000s candybar/flip-phone era hack to download the attachments over http? using a tweaked SMS scripting to grab the attachment from a special net gateway.
FYI once I purge the stuck SMSs; I will, over the space of ten to thirty minutes, get a slow spaced out run of what I assume is recent undelivered SMSs which were on the carrier side but also had a broken copy stuck and then cleared away with my fixsms script from my phone.

I assume(correct me please!) the MMSs are unclearable via MMCLI tools because they never got to the phone(bad MMS APN settings) and the carrier delivers an ‘undelivered error’ vis SMS.

======================================
tried this:

purism@pureos:~$    sudo mmcli -m any --messaging-list-sms
[sudo] password for purism: 
No sms messages were found
purism@pureos:~$ mmcli -m any  --messaging-list-sms
    /org/freedesktop/ModemManager1/SMS/37 (receiving)
purism@pureos:~$ 

and that is a more useful response…
but:

purism@pureos:~$ sudo mmcli -m any --messaging-delete-sms=1
error: couldn't find SMS at '/org/freedesktop/ModemManager1/SMS/1': 'not found in any modem'
purism@pureos:~$ 

Again no stuck messages SMS or MMS are listed in my now modem in this post after my SMS clearing script, the MMSs are again still on the wireless carrier/provider side not in my modem so will pop an undeleverd error usually after a reboot, and usually only after a few days.

If it helps here is where the chatty database is stored, I think this goes back to Nokia Maemo days when we still built on Debian Sarge and before systemd. Keep track of this DB when you write a backup script as dumping this into your wiped phone will give you back your chat history. It is nice to maybe write a rclone script for your phone on a chron job to zip your needed backup stuff and direct upload to a storage service, your SD card, or a VPS.

/home/purism/.purple/chatty/db/chatty-history.db

I hope any of this helps.

To your point on mmcli, I had bash aliases already to check for stuck messages and purging them from the modem, in this instance there was nothing in the modem to clear, but it was the first thing I checked since it was a common issue 2 years ago, with the phone waking up to recieve a message and then not getting anything. So I had followed steps from another thread to resolve the issue:

  1. pkill chatty
  2. journalctl --verify ; journalctl --rotate ; journalctl --vacuum-time=1s
  3. delete mms folders for the messages sent in ~/.local/share/chatty/mms based on the day the day they were sent
  4. triage chatty-history.db with sqlite3 to purge the entries in messages and files containing the borked message/file information
  5. delete the files in ~/.mms/modemmanager/ with long hash names and the associated .status files for them

Once chatty was started it no longer would fill up the chat thread with the failed messages, but the whole experience is what made me think chatty should have a feature built-in to resolve issues like this. Maybe the devs consider deleting files from ~/.mms/modemmanager to be outside the scope of the application?

OK, yea… I pretty much dumped all of the knowledge and tools that I had from my 2019–> pine and now purism, but I will be watching the thread for more ideas.

…and fixed a while ago.