From 6b04874e4e3dd0a4d1d52db9a87aaa121e909eab Mon Sep 17 00:00:00 2001 From: Bofh Date: Thu, 11 Feb 2021 21:02:29 +0100 Subject: [PATCH] Make vital keys inmutable + changed API documentation --- README.md | 30 ++++++++++++++++++++++++++++++ igmirror.py | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/README.md b/README.md index 2772429..98dbea1 100644 --- a/README.md +++ b/README.md @@ -145,11 +145,41 @@ curl 127.0.0.1:8080//update` curl '127.0.0.1:8080/*/update'` ``` +**Configure parameters** of the Pixelfed account (on local mirror file-based DB) + +```bash +# Get the value of a parameter (except: password, cookie) +curl 127.0.0.1:8080//cfg/var1 + +# Set the value of a parameter +# this keys are inmutable: name, username, password, cookie +curl 127.0.0.1:8080//cfg/var1?valueyouwant + + +# CONFIGURABLE PARAMETERS: + +# ------------------ +# "sched" key sets a weight schedule so you can make an account update less often. +# +# For example: if you set the value to "3", only 1 times out of 3 (counted) will actually update the account +# "sched_now" is an automatic variable that counts the current status (used when "sched" is set). +# +# This will skip the account on wildcard or single /update action, until the count hits it's max value ("sched") +# As in the example above (sched = 3), you would set this value like this: + +curl 127.0.0.1:8080//cfg/sched?3 +# ------------------ + + +``` + **Log in or log out** the account from Pixelfed. ```bash curl 127.0.0.1:8080//login +curl '127.0.0.1:8080/*/login' curl 127.0.0.1:8080//logout +curl '127.0.0.1:8080/*/logout' ``` In case of repeated posts or disaster, **prune/nuke all Pixelfed posts** from the given account. diff --git a/igmirror.py b/igmirror.py index c071846..589a9d9 100644 --- a/igmirror.py +++ b/igmirror.py @@ -604,6 +604,10 @@ def account_config(acc_id, key, value): return False, 'Key does not exist yet: {}'.format(key) return True, accdata[key] + # protect inmutable keys + if key in ['name', 'username', 'password', 'cookie']: + return False, 'The given key is inmutable: {}'.format(key) + # value has something, so we set it accdata[key] = value db_set('accounts', acc_id, accdata)