53 lines
1.0 KiB
Python
53 lines
1.0 KiB
Python
import os
|
|
|
|
name = "Upload Avatar to Synapse"
|
|
|
|
kind = "action"
|
|
|
|
alias = "uploadavatar"
|
|
|
|
allowaction = os.environ.get("UPDATE_AVATARS", True)
|
|
|
|
showstatus = True
|
|
|
|
resolve = {
|
|
"get": {
|
|
#"sender": ["messageheaders", "userCard", "id"],
|
|
#"avatar": ["uploadimage"],
|
|
#"username": ["messageheaders", "userCard", "username"],
|
|
"avatar_hash": ["useravatar_hash"],
|
|
},
|
|
}
|
|
|
|
isrequest = True
|
|
|
|
method = "POST"
|
|
|
|
#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved
|
|
path = [
|
|
"https://loxthelion.com/_matrix/media/v3/upload?filename=avatar.jpg",
|
|
]
|
|
|
|
headers = {
|
|
"Authorization": {
|
|
"os": "AS_TOKEN",
|
|
"prefix": "Bearer ",
|
|
},
|
|
"Content-Type": "image/jpeg",
|
|
}
|
|
|
|
requestdata = "useravatar"
|
|
|
|
outputs = {
|
|
"uploadimage": "content_uri",
|
|
}
|
|
|
|
filters = [
|
|
{
|
|
"filterkey": "avatar_hash",
|
|
"operator": "==",
|
|
"filtervalue": {"outputs": "db_avatar_hash"},
|
|
"print": f"User avatar up to date. Skipping {name}...",
|
|
},
|
|
]
|