updates and bug fixes

This commit is contained in:
kx1t
2024-02-02 16:12:33 -05:00
parent db8fe816ff
commit 0a3ceebf58
5 changed files with 11 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
- [Send a Mastodon Post for each new plane in PlaneFence](#send-a-mastodon-post-for-each-new-plane-in-planefence)
- [Prerequisites](#prerequisites)
- [Signing up for a Mastodon Account and creating an Application](#signing-up-for-a-mastodon-account-and-creating-an-application)
- [Automatic verification checkmark of your Mastodon account](#automatic-verification-checkmark-of-your-mastodon-account)
- [Configuring Planefence to use Mastodon](#configuring-planefence-to-use-mastodon)
- [Summary of License Terms](#summary-of-license-terms)
@@ -45,6 +46,10 @@ Once you have an account, please do the following:
![image](https://user-images.githubusercontent.com/15090643/208438987-3e1fd9c2-5ce9-46c0-92e9-20bb78f55a8c.png)
## Automatic verification checkmark of your Mastodon account
If you add a link to your public Planefence or Plane-Alert page in the Extra Fields section of your Public Profile on Mastodon, you will get automatic account verification (with a cool green checkmark) for your Mastodon account.
## Configuring Planefence to use Mastodon
Please set the following parameters in your `planefence.config` file:

View File

@@ -26,10 +26,11 @@ else
# strip http:// https://
[[ "${MASTODON_SERVER:0:7}" == "http://" ]] && MASTODON_SERVER="${MASTODON_SERVER:7}" || true
[[ "${MASTODON_SERVER:0:8}" == "https://" ]] && MASTODON_SERVER="${MASTODON_SERVER:8}" || true
result="$(curl -sS -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" "https://${MASTODON_SERVER}/api/v1/apps/verify_credentials")"
result="$(curl -m 5 -sSL -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" "https://${MASTODON_SERVER}/api/v1/apps/verify_credentials")"
acct="$(curl -m 5 -sSL -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" "https://${MASTODON_SERVER}/api/v1/accounts/verify_credentials")"
if ! grep -iq "The access token is invalid\|<body class='error'>" <<< "$result" >/dev/null 2>&1
then
echo "[$(date)][$APPNAME] Mastodon configured correctly for $(jq -r '.acct' <<< "$result")'s application $(jq '.name' <<< "$result") / website $(jq '.website' <<< "$result")"
echo "[$(date)][$APPNAME] Mastodon configured correctly for $(jq -r '.acct' <<< "$acct")'s application $(jq '.name' <<< "$result") / website $(jq '.website' <<< "$result")"
[[ "${PF_MASTODON,,}" == "on" ]] && echo "[$(date)][$APPNAME] Mastodon enabled for Planefence" || echo "[$(date)][$APPNAME] Mastodon disabled for Planefence"
[[ "${PA_MASTODON,,}" == "on" ]] && echo "[$(date)][$APPNAME] Mastodon enabled for Plane-Alert" || echo "[$(date)][$APPNAME] Mastodon disabled for Plane-Alert"
else

View File

@@ -134,7 +134,7 @@ set -a
set +a
# MASTODON parameters for MASTODON notifications as an alternative to Twitter:
# MASTODON_SERVER contains the mastodon server name, for example "airwaves.social"
# MASTODON_NAMEE contains the @ name of the Mastodon account
# MASTODON_NAME contains the @ name of the Mastodon account
MASTODON_SERVER=
MASTODON_ACCESS_TOKEN=
MASTODON_VISIBILITY=unlisted

View File

@@ -353,7 +353,7 @@ set +a
# MASTODON parameters for MASTODON notifications as an alternative to Twitter:
# MASTODON_SERVER contains the mastodon server name, for example "airwaves.social"
# MASTODON_ACCESS_TOKEN contains the mastodon access token needed for posting
# MASTODON_NAMEE contains the @ name of the Mastodon account
# MASTODON_NAME contains the @ name of the Mastodon account
MASTODON_SERVER=
MASTODON_ACCESS_TOKEN=
MASTODON_VISIBILITY=unlisted

View File

@@ -299,7 +299,7 @@ then
# strip http:// https://
[[ "${MASTODON_SERVER:0:7}" == "http://" ]] && MASTODON_SERVER="${MASTODON_SERVER:7}" || true
[[ "${MASTODON_SERVER:0:8}" == "https://" ]] && MASTODON_SERVER="${MASTODON_SERVER:8}" || true
mast_result="$(curl -m 5 -sSL -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" "https://${MASTODON_SERVER}/api/v1/apps/verify_credentials")"
mast_result="$(curl -m 5 -sSL -H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" "https://${MASTODON_SERVER}/api/v1/accounts/verify_credentials")"
if ! grep -iq "The access token is invalid\|<body class='error'>" <<< "$mast_result" >/dev/null 2>&1; then
configure_both "MASTODON_NAME" "$(jq -r '.acct' <<< "$mast_result")"
fi