Both sides previous revision
Previous revision
Next revision
|
Previous revision
Next revision
Both sides next revision
|
en:tecdoc:abusenotif [2021/03/17 16:17] jomat |
en:tecdoc:abusenotif [2021/07/01 19:15] jomat [User Reg Notifications] |
#!/usr/bin/zsh | #!/usr/bin/zsh |
| |
AT='MDMA...' | # access token of @abuse:… |
| AT='MDMA... |
| # admin room to send notifications to |
ROOM='!x1y2z3:example.com' | ROOM='!x1y2z3:example.com' |
IP=$1 | # ip of the new user, with gdpr redaction to /24 |
| IP=`echo $1|cut -d. -f1-3`.0 |
| |
| #read stdin |
SI=`/bin/cat` | SI=`/bin/cat` |
echo `date` $SI >> /tmp/newuserlog | #try to retrieve new user id |
U=`echo $SI|jq -r .user_id` | U=`echo $SI|jq -r .user_id` |
| |
[ "null" = "$U" ] && exit 0 | [ "null" = "$U" ] && exit 0 |
| |
| # send notification |
curl -X PUT "https://asra.gr/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/"`uuid -m -F SIV`"?access_token=${AT}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"body\": \"@room New user registered: ${U} from ${IP}\", \"msgtype\": \"m.text\"}" >> /tmp/reguser.txt 2>> /tmp/reguser.txt | curl -X PUT "https://asra.gr/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/"`uuid -m -F SIV`"?access_token=${AT}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"body\": \"@room New user registered: ${U} from ${IP}\", \"msgtype\": \"m.text\"}" >> /tmp/reguser.txt 2>> /tmp/reguser.txt |
</code> | </code> |
| |
<code - /usr/local/bin/matrix_event_reported> | <code - /usr/local/bin/matrix_event_reported> |
#!/usr/bin/zsh | |
| |
AT='MDMA...' | |
ROOM='!x1y2z3:example.com' | |
IP=$1 | |
SI=`/bin/cat` | |
echo `date` $SI >> /tmp/newuserlog | |
U=`echo $SI|jq -r .user_id` | |
| |
[ -z "$U" ] && exit 0 | |
[ "null" = "$U" ] && exit 0 | |
| |
curl -X PUT "https://asra.gr/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/"`uuid -m -F SIV`"?access_token=${AT}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"body\": \"@room New user registered: ${U} from ${IP}\", \"msgtype\": \"m.text\"}" >> /tmp/reguser.txt 2>> /tmp/reguser.txt | |
| |
➜ ~ cat /usr/local/bin/matrix_event_reported | |
#!/bin/sh | #!/bin/sh |
| |
| |
echo date $* >> /tmp/report.log | echo date $* >> /tmp/report.log |
| |
| |
#https://asra.gr/.well-known/matrix/support | #https://asra.gr/.well-known/matrix/support |