Local backups: inconsistent phone number format
I'm using SMSGate to backup SMS messages to a local file. I used a custom format string: "%n/%P/%D%t", so that each contact name would be a directory, and under it there would be a directory for each phone number (in case a contact has more than one number), and finally the date and direction of the message for the file name. e.g.
alice/+1-555-555-1111/...
bob/+1-555-555-1234/...
bob/+1-555-555-5678/...
The problem is that the numbers for some of my contacts seem to be formatted a little differently, causing some messages to be saved in different directories, even though they're the same phone number. e.g.
alice/+1-555-555-1111/...
alice/1-555-555-1111/...
alice/555-555-1111/...
bob/+1-555-555-1234
bob/(555) 555-1234/...
bob/+1-555-555-5678/
bob/1-555-555-5678/...
Incoming messages are always saved in the following format: +15555555555 (if using %p) +1-555-555-5555 (if using %P)
Outgoing messages appear to be saved in exactly the same format they were typed regardless of the placeholder used (%p or %P) unless the number was typed exactly in the format +1-555-555-5555 which becomes +15555555555 (if using %p) or remains +1-555-555-5555 (if using %P). Likewise +15555555555 becomes +1-555-555-5555 (%P) or remains unchanged (%p).
I think +15555555555 is the format used by the messaging app when you open a message and choose "add contact". This explains why, for a few contacts - those which I added through the messaging app - SMSGate correctly saved incoming and outgoing messages together under the same phone number no matter if I used %p or %P. However, (555) 555-5555 is the format used by the phone app when you click "create new contact" in call history. Manually entering a contact can result in any format. This might vary from one phone to another.
Note that when backing up, SMSGate will use the phone number as it was saved at the time the individual message was sent. This means you can't fix old messages by updating the number format to +1-555-555-5555 for each of your contacts. It will fix the problem going forward, but even if you create a new backup from scratch, old messages will still show up exactly as they did before. So, you'll either have to live with it, or fix your backups by hand.
I'm not exactly sure what fix to propose. I'd say we could be a little more liberal in what number formats we will recognize and reformat, but we may have to be careful about international phone number formats and unusual characters like pound and asterisk. We may want to create a new placeholder character to avoid breaking people's existing setups.
Maybe we could at least recognize the following as the same number:
+1-555-555-5555 (currently recognized)
+15555555555 (currently recognized)
+1 5555555555
1-555-555-5555
1 555-555-5555
+1 555-555-5555
1 555 555-5555
+1 555 555-5555
1 (555) 555-5555
+1 (555) 555-5555
@axet Thank you very much for creating SMSGate and all your other apps! Your work is appreciated.