Updated handling of '+' in phone numbers, it is now never stripped but expected: all numbers should be full international phone numbers (including in contacts.tsv).

Ensure contacts from modem and contacts lists are all fully qualified phone numbers (starting with + and carrying a country prefix). This effectively filters out older/incompatible entries.
This commit is contained in:
Maarten van Gompel 2020-08-02 12:01:25 +02:00 committed by Miles Alan
parent 7f2f50c11a
commit 565eae8835
4 changed files with 7 additions and 5 deletions

View file

@ -3,6 +3,8 @@
# modem log merged with contact names defined in contacts file tsv.
# Wherein $CONTACTSFILE is tsv with two fields: number\tcontact name
# Wherein $LOGFILE is *sorted* tsv with three fields: date\tevt\tnumber
#
# number should be a full phone number starting with + and the country number
#
# Prints in output format: "number: contact"
@ -14,14 +16,14 @@ contacts() {
RECENTCONTACTEDNUMBERSREVCHRON="$(
cut -f3 "$LOGFILE" |
tac |
awk '!($0 in a){a[$0];print}' |
awk '!($0 in a){a[$0]; if (substr($0,1,1) == "+") print}' |
sed '/^[[:space:]]*$/d'
)"
printf %b "$RECENTCONTACTEDNUMBERSREVCHRON" | awk -F'\t' '
FNR==NR{a[$1]=$2; next}
{
if (!a[$1]) a[$1] = "Unknown Number";
print $0 ": " a[$1]
if (substr($0,1,1) == "+") print $0 ": " a[$1]
}
' "$CONTACTSFILE" -
}