normalize smslog for mms and sms
This implements sxmo_hook_smslog.sh which allows the user to establish how logging looks. We were also inconsistent on this: mms would set the contact names in the logfile whereas sms ony gave the numbers and used a sed to convert them. I tought about setting this in sxmo_hook_tailtextlog.sh, but: (1) processing on a tail is a PITA (2) one can get the "raw" data for sms.txt from modelog.tsv. I implemented a basic and a fancy option, but it is really up to the user. I also implemented sxmo_contacts.sh --name-or-number and so was able to clear out the '???' code all over the place. Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
This commit is contained in:

committed by
Willow Barraco

parent
7f78a92b18
commit
d27f7e108d
109
configs/default_hooks/sxmo_hook_smslog.sh
Executable file
109
configs/default_hooks/sxmo_hook_smslog.sh
Executable file
@@ -0,0 +1,109 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
# Copyright 2022 Sxmo Contributors
|
||||||
|
|
||||||
|
# Allow user to override what we log in the sms.txt file.
|
||||||
|
|
||||||
|
# shellcheck source=scripts/core/sxmo_common.sh
|
||||||
|
. sxmo_common.sh
|
||||||
|
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||||
|
. sxmo_hook_icons.sh
|
||||||
|
|
||||||
|
VERB="$1" # Received or Sent
|
||||||
|
TYPE="$2" # SMS, MMS, or GroupMMS
|
||||||
|
NUM="$3" # if GroupMMS this will be "FromNumber ToNumbers LogdirNumber"
|
||||||
|
TIME="$4"
|
||||||
|
TEXT="$5"
|
||||||
|
MMSID="$6" # optional
|
||||||
|
|
||||||
|
basiclogging() {
|
||||||
|
if [ "$VERB" = "Received" ]; then
|
||||||
|
PREPOSITION="from"
|
||||||
|
else
|
||||||
|
PREPOSITION="to"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TYPE" = "GroupMMS" ]; then
|
||||||
|
# who sent it
|
||||||
|
FROM_NUM="$(printf "%s" "$NUM" | cut -d' ' -f1)"
|
||||||
|
# who else did they send it to
|
||||||
|
TO_NUMS="$(printf "%s" "$NUM" | cut -d' ' -f2)"
|
||||||
|
# what is the actual logdir number (will be everyone's phone number except yours)
|
||||||
|
NUM="$(printf "%s" "$NUM" | cut -d' ' -f3)"
|
||||||
|
|
||||||
|
printf "%s %s %s %s (to: %s) at %s:\n%s\n" \
|
||||||
|
"$VERB" "$TYPE" "$PREPOSITION" "$FROM_NUM" "$TO_NUMS" "$TIME" "$TEXT"
|
||||||
|
else
|
||||||
|
printf "%s %s %s %s at %s:\n%s\n" \
|
||||||
|
"$VERB" "$TYPE" "$PREPOSITION" "$NUM" "$TIME" "$TEXT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$SXMO_LOGDIR/$NUM/attachments/$MMS_ID.attachments.txt" ]; then
|
||||||
|
cat "$SXMO_LOGDIR/$NUM/attachments/$MMS_ID.attachments.txt" | tr '\n' '\0' | xargs -0 printf "$icon_att %s\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_to_list() {
|
||||||
|
pnc find "$1" | while read -r line; do
|
||||||
|
printf "%s, " "$(sxmo_contacts.sh --name-or-number "$line")"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
fancylogging() {
|
||||||
|
if [ "$VERB" = "Received" ]; then
|
||||||
|
PREPOSITION="from"
|
||||||
|
else
|
||||||
|
PREPOSITION="to"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PRETTY_TIME="$(date -d "$TIME")"
|
||||||
|
|
||||||
|
if [ "$TYPE" = "GroupMMS" ]; then
|
||||||
|
# who sent it
|
||||||
|
FROM_NUM="$(printf "%s" "$NUM" | cut -d' ' -f1)"
|
||||||
|
# who else did they send it to
|
||||||
|
TO_NUMS="$(printf "%s" "$NUM" | cut -d' ' -f2)"
|
||||||
|
# everyone except you
|
||||||
|
NUM="$(printf "%s" "$NUM" | cut -d' ' -f3)"
|
||||||
|
|
||||||
|
FROM_CONTACT="$(sxmo_contacts.sh --name-or-number "$FROM_NUM")"
|
||||||
|
|
||||||
|
TO_CONTACTS="$(generate_to_list "$TO_NUMS" | sed 's/, $//')"
|
||||||
|
generate_to_list | sed 's/, $//'
|
||||||
|
|
||||||
|
#This would be the contact for the entire group chain, if any.
|
||||||
|
NUM_CONTACT="$(sxmo_contacts.sh --name "$NUM")"
|
||||||
|
|
||||||
|
printf "%s\n%s %s (%s)\nFrom: %s\nTo: %s\n%s\n" \
|
||||||
|
"$PRETTY_TIME" \
|
||||||
|
"$VERB" \
|
||||||
|
"$TYPE" \
|
||||||
|
"$NUM_CONTACT" \
|
||||||
|
"$FROM_CONTACT" \
|
||||||
|
"$TO_CONTACTS" \
|
||||||
|
"$TEXT"
|
||||||
|
else
|
||||||
|
FROM_CONTACT="$(sxmo_contacts.sh --name-or-number "$NUM")"
|
||||||
|
|
||||||
|
printf "%s\n%s %s %s %s:\n%s\n" \
|
||||||
|
"$PRETTY_TIME" \
|
||||||
|
"$VERB" \
|
||||||
|
"$TYPE" \
|
||||||
|
"$PREPOSITION" \
|
||||||
|
"$FROM_CONTACT" \
|
||||||
|
"$TEXT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$SXMO_LOGDIR/$LOGDIR_NUM/attachments/$MMS_ID.attachments.txt" ]; then
|
||||||
|
tr '\n' '\0' < "$SXMO_LOGDIR/$LOGDIR_NUM/attachments/$MMS_ID.attachments.txt" \
|
||||||
|
| xargs -0 printf "$icon_att %s\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
#basiclogging "$@"
|
||||||
|
|
||||||
|
fancylogging "$@"
|
@@ -9,8 +9,6 @@
|
|||||||
. sxmo_common.sh
|
. sxmo_common.sh
|
||||||
|
|
||||||
NUMBER="$1"
|
NUMBER="$1"
|
||||||
CONTACTNAME="$(sxmo_contacts.sh | grep ": ${NUMBER}$" | cut -d: -f1)"
|
|
||||||
[ "???" = "$CONTACTNAME" ] && CONTACTNAME="$CONTACTNAME ($NUMBER)"
|
|
||||||
TERMNAME="$NUMBER SMS"
|
TERMNAME="$NUMBER SMS"
|
||||||
export TERMNAME
|
export TERMNAME
|
||||||
|
|
||||||
@@ -19,4 +17,4 @@ if [ "$SXMO_WM" = "sway" ] && [ -z "$SSH_CLIENT" ]; then
|
|||||||
regesc_termname="$(echo "$TERMNAME" | sed 's|+|\\+|g')"
|
regesc_termname="$(echo "$TERMNAME" | sed 's|+|\\+|g')"
|
||||||
swaymsg "[title=\"^$regesc_termname\$\"]" focus && exit 0
|
swaymsg "[title=\"^$regesc_termname\$\"]" focus && exit 0
|
||||||
fi
|
fi
|
||||||
sxmo_terminal.sh sh -c "tail -n9999 -f \"$SXMO_LOGDIR/$NUMBER/sms.txt\" | sed \"s|$NUMBER|$CONTACTNAME|g\""
|
sxmo_terminal.sh sh -c "tail -n9999 -f \"$SXMO_LOGDIR/$NUMBER/sms.txt\""
|
||||||
|
@@ -108,6 +108,14 @@ elif [ "$1" = "--me" ]; then
|
|||||||
all_contacts \
|
all_contacts \
|
||||||
| grep "^Me: " \
|
| grep "^Me: " \
|
||||||
| sed 's|^Me: ||'
|
| sed 's|^Me: ||'
|
||||||
|
elif [ "$1" = "--name-or-number" ]; then
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
printf "???\n"
|
||||||
|
else
|
||||||
|
contact="$(sxmo_contacts.sh --name "$2")"
|
||||||
|
[ "$contact" = "???" ] && contact="$2"
|
||||||
|
printf %s "$contact"
|
||||||
|
fi
|
||||||
elif [ "$1" = "--name" ]; then
|
elif [ "$1" = "--name" ]; then
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf "???\n"
|
printf "???\n"
|
||||||
|
@@ -148,9 +148,9 @@ extractmmsattachement() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ACTYPE" != "text/plain" ]; then
|
if [ "$ACTYPE" != "text/plain" ]; then
|
||||||
printf "$icon_att %s\n" \
|
printf "%s\n" \
|
||||||
"$(basename "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$OUTFILE")" \
|
"$(basename "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$OUTFILE")" \
|
||||||
>> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
>> "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$MMS_FILE.attachments.txt"
|
||||||
|
|
||||||
printf "%s\0" "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$OUTFILE"
|
printf "%s\0" "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$OUTFILE"
|
||||||
fi
|
fi
|
||||||
@@ -199,38 +199,32 @@ processmms() {
|
|||||||
FROM_NUM="$(printf %s "$MESSAGE" | jq -r '.attrs.Sender')"
|
FROM_NUM="$(printf %s "$MESSAGE" | jq -r '.attrs.Sender')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FROM_NAME="$(sxmo_contacts.sh --name "$FROM_NUM")"
|
|
||||||
TO_NUMS="$(printf %s "$MESSAGE" | jq -r '.attrs.Recipients | join("\n")')"
|
TO_NUMS="$(printf %s "$MESSAGE" | jq -r '.attrs.Recipients | join("\n")')"
|
||||||
# generate string of contact names, e.g., "BOB, SUZIE, SAM"
|
|
||||||
TO_NAMES="$(printf %s "$TO_NUMS" | xargs -n1 sxmo_contacts.sh --name | tr '\n' '\0' | xargs -0 printf "%s, " | sed 's/, $//')"
|
|
||||||
|
|
||||||
|
# Determine if this is a GroupMMS
|
||||||
count="$(printf "%s" "$TO_NUMS" | wc -l)"
|
count="$(printf "%s" "$TO_NUMS" | wc -l)"
|
||||||
|
|
||||||
|
# Calculate the LOGDIRNUM:
|
||||||
|
# For GroupMMS, the LOGDIRNUM will be all numbers in the group except
|
||||||
|
# your own, sorted numerically
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
# a group chat. LOGDIRNUM = all numbers except one's own, sorted numerically
|
|
||||||
LOGDIRNUM="$(printf "%b\n%s\n" "$TO_NUMS" "$FROM_NUM" | grep -v "^$MYNUM$" | sort -u | grep . | xargs printf %s)"
|
LOGDIRNUM="$(printf "%b\n%s\n" "$TO_NUMS" "$FROM_NUM" | grep -v "^$MYNUM$" | sort -u | grep . | xargs printf %s)"
|
||||||
mkdir -p "$SXMO_LOGDIR/$LOGDIRNUM"
|
|
||||||
printf "%s Group MMS from %s to %s at %s:\n" "$MESSAGE_TYPE" "$FROM_NAME" "$TO_NAMES" "$DATE" >> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
|
||||||
else
|
else
|
||||||
# not a group chat
|
|
||||||
if [ "$MESSAGE_TYPE" = "Sent" ]; then
|
if [ "$MESSAGE_TYPE" = "Sent" ]; then
|
||||||
LOGDIRNUM="$TO_NUMS"
|
LOGDIRNUM="$TO_NUMS"
|
||||||
elif [ "$MESSAGE_TYPE" = "Received" ]; then
|
elif [ "$MESSAGE_TYPE" = "Received" ]; then
|
||||||
LOGDIRNUM="$FROM_NUM"
|
LOGDIRNUM="$FROM_NUM"
|
||||||
fi
|
fi
|
||||||
mkdir -p "$SXMO_LOGDIR/$LOGDIRNUM"
|
|
||||||
printf "%s MMS from %s at %s:\n" "$MESSAGE_TYPE" "$FROM_NAME" "$DATE" >> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
|
||||||
fi
|
fi
|
||||||
|
mkdir -p "$SXMO_LOGDIR/$LOGDIRNUM"
|
||||||
|
|
||||||
stderr "$MESSAGE_TYPE MMS ($MMS_FILE) from number $LOGDIRNUM"
|
# check if blocked
|
||||||
|
|
||||||
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$LOGDIRNUM$"; then
|
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$LOGDIRNUM$"; then
|
||||||
mkdir -p "$SXMO_BLOCKDIR/$LOGDIRNUM"
|
mkdir -p "$SXMO_BLOCKDIR/$LOGDIRNUM"
|
||||||
stderr "BLOCKED mms from number: $LOGDIRNUM ($MMS_FILE)."
|
stderr "BLOCKED mms $LOGDIRNUM ($MMS_FILE)."
|
||||||
SXMO_LOGDIR="$SXMO_BLOCKDIR"
|
SXMO_LOGDIR="$SXMO_BLOCKDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$SXMO_LOGDIR/$LOGDIRNUM/attachments"
|
|
||||||
|
|
||||||
if [ "$MESSAGE_TYPE" = "Received" ]; then
|
if [ "$MESSAGE_TYPE" = "Received" ]; then
|
||||||
printf "%s\trecv_mms\t%s\t%s\n" "$DATE" "$LOGDIRNUM" "$MMS_FILE" >> "$SXMO_LOGDIR/modemlog.tsv"
|
printf "%s\trecv_mms\t%s\t%s\n" "$DATE" "$LOGDIRNUM" "$MMS_FILE" >> "$SXMO_LOGDIR/modemlog.tsv"
|
||||||
elif [ "$MESSAGE_TYPE" = "Sent" ]; then
|
elif [ "$MESSAGE_TYPE" = "Sent" ]; then
|
||||||
@@ -239,7 +233,8 @@ processmms() {
|
|||||||
stderr "Unknown message type: $MESSAGE_TYPE for $MMS_FILE"
|
stderr "Unknown message type: $MESSAGE_TYPE for $MMS_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# process 'content' of mms payload
|
# process 'content' of mms payload (in order to extract at least the content of the message, if not more)
|
||||||
|
mkdir -p "$SXMO_LOGDIR/$LOGDIRNUM/attachments"
|
||||||
OPEN_ATTACHMENTS_CMD="$(printf %s "$MESSAGE" | extractmmsattachement | xargs -0 printf "sxmo_open.sh '%s'; " | sed "s/sxmo_open.sh ''; //")"
|
OPEN_ATTACHMENTS_CMD="$(printf %s "$MESSAGE" | extractmmsattachement | xargs -0 printf "sxmo_open.sh '%s'; " | sed "s/sxmo_open.sh ''; //")"
|
||||||
if [ -f "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$MMS_FILE.txt" ]; then
|
if [ -f "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$MMS_FILE.txt" ]; then
|
||||||
TEXT="$(cat "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$MMS_FILE.txt")"
|
TEXT="$(cat "$SXMO_LOGDIR/$LOGDIRNUM/attachments/$MMS_FILE.txt")"
|
||||||
@@ -248,17 +243,23 @@ processmms() {
|
|||||||
TEXT="<Empty>"
|
TEXT="<Empty>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%b\n\n" "$TEXT" >> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
# write to sms.txt
|
||||||
|
if [ "$count" -gt 0 ]; then
|
||||||
|
sxmo_hook_smslog.sh "$MESSAGE_TYPE" "GroupMMS" "$FROM_NUM $TO_NUMS" "$DATE" "$TEXT" "$MMS_FILE" >> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
||||||
|
else
|
||||||
|
sxmo_hook_smslog.sh "$MESSAGE_TYPE" "MMS" "$FROM_NUM" "$DATE" "$TEXT" "$MMS_FILE" >> "$SXMO_LOGDIR/$LOGDIRNUM/sms.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# handle notification
|
||||||
if [ "$MESSAGE_TYPE" = "Received" ]; then
|
if [ "$MESSAGE_TYPE" = "Received" ]; then
|
||||||
[ "$FROM_NAME" = "???" ] && FROM_NAME="$FROM_NUM"
|
FROM_NAME="$(sxmo_contacts.sh --name-or-num "$FROM_NUM")"
|
||||||
if [ -z "$SXMO_DISABLE_SMS_NOTIFS" ]; then
|
if [ -z "$SXMO_DISABLE_SMS_NOTIFS" ]; then
|
||||||
[ -n "$OPEN_ATTACHMENTS_CMD" ] && TEXT="$icon_att $TEXT"
|
[ -n "$OPEN_ATTACHMENTS_CMD" ] && TEXT="$icon_att $TEXT"
|
||||||
sxmo_notificationwrite.sh \
|
sxmo_notificationwrite.sh \
|
||||||
random \
|
random \
|
||||||
"${OPEN_ATTACHMENTS_CMD}sxmo_hook_tailtextlog.sh \"$LOGDIRNUM\"" \
|
"${OPEN_ATTACHMENTS_CMD}sxmo_hook_tailtextlog.sh \"$LOGDIRNUM\"" \
|
||||||
"$SXMO_LOGDIR/$LOGDIRNUM/sms.txt" \
|
"$SXMO_LOGDIR/$LOGDIRNUM/sms.txt" \
|
||||||
"$FROM_NAME: $TEXT ($MMS_FILE)"
|
"$FROM_NAME: $TEXT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q screenoff "$SXMO_STATE"; then
|
if grep -q screenoff "$SXMO_STATE"; then
|
||||||
@@ -266,8 +267,7 @@ processmms() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
GROUPNAME="$(sxmo_contacts.sh --name "$LOGDIRNUM")"
|
GROUPNAME="$(sxmo_contacts.sh --name-or-num "$LOGDIRNUM")"
|
||||||
[ "$GROUPNAME" = "???" ] && GROUPNAME="$LOGDIRNUM"
|
|
||||||
sxmo_hook_sms.sh "$FROM_NAME" "$TEXT" "$MMS_FILE" "$GROUPNAME"
|
sxmo_hook_sms.sh "$FROM_NAME" "$TEXT" "$MMS_FILE" "$GROUPNAME"
|
||||||
else
|
else
|
||||||
sxmo_hook_sms.sh "$FROM_NAME" "$TEXT" "$MMS_FILE"
|
sxmo_hook_sms.sh "$FROM_NAME" "$TEXT" "$MMS_FILE"
|
||||||
|
@@ -46,8 +46,7 @@ checkforfinishedcalls() {
|
|||||||
|
|
||||||
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.monitoredcall"
|
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.monitoredcall"
|
||||||
|
|
||||||
CONTACT="$(sxmo_contacts.sh --name "$FINISHEDNUMBER")"
|
CONTACT="$(sxmo_contacts.sh --name-or-number "$FINISHEDNUMBER")"
|
||||||
[ "$CONTACT" = "???" ] && CONTACT="$FINISHEDNUMBER"
|
|
||||||
|
|
||||||
TIME="$(date +%FT%H:%M:%S%z)"
|
TIME="$(date +%FT%H:%M:%S%z)"
|
||||||
mkdir -p "$SXMO_LOGDIR"
|
mkdir -p "$SXMO_LOGDIR"
|
||||||
@@ -126,7 +125,6 @@ checkforincomingcalls() {
|
|||||||
stderr "Incoming Call..."
|
stderr "Incoming Call..."
|
||||||
INCOMINGNUMBER=$(sxmo_modemcall.sh vid_to_number "$VOICECALLID")
|
INCOMINGNUMBER=$(sxmo_modemcall.sh vid_to_number "$VOICECALLID")
|
||||||
INCOMINGNUMBER="$(cleanupnumber "$INCOMINGNUMBER")"
|
INCOMINGNUMBER="$(cleanupnumber "$INCOMINGNUMBER")"
|
||||||
CONTACTNAME=$(sxmo_contacts.sh --name "$INCOMINGNUMBER")
|
|
||||||
|
|
||||||
TIME="$(date +%FT%H:%M:%S%z)"
|
TIME="$(date +%FT%H:%M:%S%z)"
|
||||||
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$INCOMINGNUMBER$"; then
|
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$INCOMINGNUMBER$"; then
|
||||||
@@ -135,7 +133,7 @@ checkforincomingcalls() {
|
|||||||
printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$SXMO_BLOCKDIR/modemlog.tsv"
|
printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$SXMO_BLOCKDIR/modemlog.tsv"
|
||||||
else
|
else
|
||||||
stderr "Invoking ring hook (async)"
|
stderr "Invoking ring hook (async)"
|
||||||
[ "$CONTACTNAME" = "???" ] && CONTACTNAME="$INCOMINGNUMBER"
|
CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$INCOMINGNUMBER")
|
||||||
sxmo_hook_ring.sh "$CONTACTNAME" &
|
sxmo_hook_ring.sh "$CONTACTNAME" &
|
||||||
|
|
||||||
mkdir -p "$SXMO_LOGDIR"
|
mkdir -p "$SXMO_LOGDIR"
|
||||||
@@ -210,7 +208,6 @@ checkfornewtexts() {
|
|||||||
grep sms.content.number |
|
grep sms.content.number |
|
||||||
sed -E 's/^sms\.content\.number\s+:\s+//'
|
sed -E 's/^sms\.content\.number\s+:\s+//'
|
||||||
)"
|
)"
|
||||||
NUM="$(cleanupnumber "$NUM")"
|
|
||||||
|
|
||||||
TIME="$(echo "$TEXTDATA" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')"
|
TIME="$(echo "$TEXTDATA" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')"
|
||||||
TIME="$(date +%FT%H:%M:%S%z -d "$TIME")"
|
TIME="$(date +%FT%H:%M:%S%z -d "$TIME")"
|
||||||
@@ -224,7 +221,7 @@ checkfornewtexts() {
|
|||||||
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$NUM$"; then
|
if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$NUM$"; then
|
||||||
mkdir -p "$SXMO_BLOCKDIR/$NUM"
|
mkdir -p "$SXMO_BLOCKDIR/$NUM"
|
||||||
stderr "BLOCKED text from number: $NUM (TEXTID: $TEXTID)"
|
stderr "BLOCKED text from number: $NUM (TEXTID: $TEXTID)"
|
||||||
printf %b "Received from $NUM at $TIME:\n$TEXT\n\n" >> "$SXMO_BLOCKDIR/$NUM/sms.txt"
|
sxmo_hook_smslog.sh "Received" "SMS" "$NUM" "$TIME" "$TEXT" >> "$SXMO_BLOCKDIR/$NUM/sms.txt"
|
||||||
printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_BLOCKDIR/modemlog.tsv"
|
printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_BLOCKDIR/modemlog.tsv"
|
||||||
mmcli -m any --messaging-delete-sms="$TEXTID"
|
mmcli -m any --messaging-delete-sms="$TEXTID"
|
||||||
continue
|
continue
|
||||||
@@ -242,11 +239,10 @@ checkfornewtexts() {
|
|||||||
|
|
||||||
mkdir -p "$SXMO_LOGDIR/$NUM"
|
mkdir -p "$SXMO_LOGDIR/$NUM"
|
||||||
stderr "Text from number: $NUM (TEXTID: $TEXTID)"
|
stderr "Text from number: $NUM (TEXTID: $TEXTID)"
|
||||||
printf %b "Received SMS from $NUM at $TIME:\n$TEXT\n\n" >> "$SXMO_LOGDIR/$NUM/sms.txt"
|
sxmo_hook_smslog.sh "Received" "SMS" "$NUM" "$TIME" "$TEXT" >> "$SXMO_LOGDIR/$NUM/sms.txt"
|
||||||
printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_LOGDIR/modemlog.tsv"
|
printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_LOGDIR/modemlog.tsv"
|
||||||
mmcli -m any --messaging-delete-sms="$TEXTID"
|
mmcli -m any --messaging-delete-sms="$TEXTID"
|
||||||
CONTACTNAME=$(sxmo_contacts.sh --name "$NUM")
|
CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$NUM")
|
||||||
[ "$CONTACTNAME" = "???" ] && CONTACTNAME="$NUM"
|
|
||||||
|
|
||||||
if [ -z "$SXMO_DISABLE_SMS_NOTIFS" ]; then
|
if [ -z "$SXMO_DISABLE_SMS_NOTIFS" ]; then
|
||||||
sxmo_notificationwrite.sh \
|
sxmo_notificationwrite.sh \
|
||||||
|
@@ -145,8 +145,7 @@ $(
|
|||||||
list_active_calls | while read -r line; do
|
list_active_calls | while read -r line; do
|
||||||
CALLID="$(printf %s "$line" | cut -d" " -f1 | xargs basename)"
|
CALLID="$(printf %s "$line" | cut -d" " -f1 | xargs basename)"
|
||||||
NUMBER="$(vid_to_number "$CALLID")"
|
NUMBER="$(vid_to_number "$CALLID")"
|
||||||
CONTACT="$(sxmo_contacts.sh --name "$NUMBER")"
|
CONTACT="$(sxmo_contacts.sh --name-or-number "$NUMBER")"
|
||||||
[ "$CONTACT" = "???" ] && CONTACT="$NUMBER"
|
|
||||||
case "$line" in
|
case "$line" in
|
||||||
*"(ringing-in)")
|
*"(ringing-in)")
|
||||||
# TODO switch to this call
|
# TODO switch to this call
|
||||||
@@ -196,8 +195,7 @@ mute() {
|
|||||||
|
|
||||||
incoming_call_menu() {
|
incoming_call_menu() {
|
||||||
NUMBER="$(vid_to_number "$1")"
|
NUMBER="$(vid_to_number "$1")"
|
||||||
CONTACTNAME="$(sxmo_contacts.sh --name "$NUMBER")"
|
CONTACTNAME="$(sxmo_contacts.sh --name-or-number "$NUMBER")"
|
||||||
[ "$CONTACTNAME" = "???" ] && CONTACTNAME="$NUMBER"
|
|
||||||
|
|
||||||
if [ "$SXMO_WM" = "sway" ]; then
|
if [ "$SXMO_WM" = "sway" ]; then
|
||||||
pickup_height="40"
|
pickup_height="40"
|
||||||
|
@@ -157,8 +157,7 @@ if [ "$(printf %s "$NUMBER" | xargs pnc find | wc -l)" -gt 1 ] || [ -f "$SXMO_LO
|
|||||||
[ -f "$SXMO_LOGDIR/$NUMBER/draft.attachments.txt" ] && rm "$SXMO_LOGDIR/$NUMBER/draft.attachments.txt"
|
[ -f "$SXMO_LOGDIR/$NUMBER/draft.attachments.txt" ] && rm "$SXMO_LOGDIR/$NUMBER/draft.attachments.txt"
|
||||||
|
|
||||||
MMS_ID="$(echo "$MESSAGE_PATH" | rev | cut -d'/' -f1 | rev)"
|
MMS_ID="$(echo "$MESSAGE_PATH" | rev | cut -d'/' -f1 | rev)"
|
||||||
CONTACTNAME="$(sxmo_contacts.sh --name "$NUMBER")"
|
CONTACTNAME="$(sxmo_contacts.sh --name-or-number "$NUMBER")"
|
||||||
[ "$CONTACTNAME" = "???" ] && CONTACTNAME="$NUMBER"
|
|
||||||
sxmo_hook_sendsms.sh "$CONTACTNAME" "$TEXT" "$MMS_ID" "$CONTACTNAME"
|
sxmo_hook_sendsms.sh "$CONTACTNAME" "$TEXT" "$MMS_ID" "$CONTACTNAME"
|
||||||
info "Sent mms text to $CONTACTNAME with mms id ($MMS_ID) message ok"
|
info "Sent mms text to $CONTACTNAME with mms id ($MMS_ID) message ok"
|
||||||
|
|
||||||
@@ -199,11 +198,10 @@ else
|
|||||||
|
|
||||||
TIME="$(date +%FT%H:%M:%S%z)"
|
TIME="$(date +%FT%H:%M:%S%z)"
|
||||||
mkdir -p "$SXMO_LOGDIR/$NUMBER"
|
mkdir -p "$SXMO_LOGDIR/$NUMBER"
|
||||||
printf %b "Sent SMS to $NUMBER at $TIME:\n$TEXT\n\n" >> "$SXMO_LOGDIR/$NUMBER/sms.txt"
|
sxmo_hook_smslog.sh "Sent" "SMS" "$NUMBER" "$TIME" "$TEXT" >> "$SXMO_LOGDIR/$NUMBER/sms.txt"
|
||||||
printf "%s\tsent_txt\t%s\t%s chars\n" "$TIME" "$NUMBER" "$TEXTSIZE" >> "$SXMO_LOGDIR/modemlog.tsv"
|
printf "%s\tsent_txt\t%s\t%s chars\n" "$TIME" "$NUMBER" "$TEXTSIZE" >> "$SXMO_LOGDIR/modemlog.tsv"
|
||||||
|
|
||||||
CONTACTNAME="$(sxmo_contacts.sh --name "$NUMBER")"
|
CONTACTNAME="$(sxmo_contacts.sh --name-or-number "$NUMBER")"
|
||||||
[ "$CONTACTNAME" = "???" ] && CONTACTNAME="$NUMBER"
|
|
||||||
sxmo_hook_sendsms.sh "$CONTACTNAME" "$TEXT"
|
sxmo_hook_sendsms.sh "$CONTACTNAME" "$TEXT"
|
||||||
info "Sent sms text to $CONTACTNAME message ok"
|
info "Sent sms text to $CONTACTNAME message ok"
|
||||||
fi
|
fi
|
||||||
|
@@ -19,8 +19,7 @@ processvvm() {
|
|||||||
VVM_ID="$3" # unique id assigned to voice mail from vvmd
|
VVM_ID="$3" # unique id assigned to voice mail from vvmd
|
||||||
VVM_ATTACHMENT="$4" # full path + filename of amr file
|
VVM_ATTACHMENT="$4" # full path + filename of amr file
|
||||||
VVM_FILE="$SXMO_LOGDIR/$VVM_SENDER/attachments/$(basename "$VVM_ATTACHMENT")"
|
VVM_FILE="$SXMO_LOGDIR/$VVM_SENDER/attachments/$(basename "$VVM_ATTACHMENT")"
|
||||||
VVM_SENDER_NAME="$(sxmo_contacts.sh --name "$VVM_SENDER")"
|
VVM_SENDER_NAME="$(sxmo_contacts.sh --name-or-number "$VVM_SENDER")"
|
||||||
[ "$VVM_SENDER_NAME" = "???" ] && VVM_SENDER_NAME="$VVM_SENDER"
|
|
||||||
|
|
||||||
mkdir -p "$SXMO_LOGDIR/$VVM_SENDER/attachments"
|
mkdir -p "$SXMO_LOGDIR/$VVM_SENDER/attachments"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user