diff --git a/plugins/rmass/actions/getrmassuseravatar.py b/plugins/rmass/actions/getrmassuseravatar.py new file mode 100644 index 0000000..436eebb --- /dev/null +++ b/plugins/rmass/actions/getrmassuseravatar.py @@ -0,0 +1,38 @@ +name = "Get User Avatar" + +kind = "action" + +alias = "getavatar" + +showstatus = True + +isrequest = True + +method = "GET" + +#Used to resolve path for recursive handling. Path location must match the location of the recursiveset data from pullmessage operation +resolve = { + "get": { + "avatar": ["messageheaders", "userCard", "userPhoto"], + }, + "construct": { + "avatarpath": [ + "https://rentmasseur.com", + {"resolved": "avatar"}, + ], + }, +} + +#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved +path = [ + {"resolved": "avatarpath"}, +] + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +image = "useravatar" diff --git a/plugins/rmass/actions/rmassavatartosynapse.py b/plugins/rmass/actions/rmassavatartosynapse.py new file mode 100644 index 0000000..a204543 --- /dev/null +++ b/plugins/rmass/actions/rmassavatartosynapse.py @@ -0,0 +1,30 @@ +name = "Upload Avatar to Synapse" + +kind = "action" + +alias = "uploadavatar" + +showstatus = True + +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", +} \ No newline at end of file diff --git a/plugins/rmass/actions/synapseassignavatar.py b/plugins/rmass/actions/synapseassignavatar.py new file mode 100644 index 0000000..bfacb1d --- /dev/null +++ b/plugins/rmass/actions/synapseassignavatar.py @@ -0,0 +1,52 @@ +import os + +name = "Synapse Assign Avatar" + +kind = "action" + +showstatus = True + +#astoken = os.environ["AS_TOKEN"] + +resolve = { + "get": { + "sender": ["messageheaders", "userCard", "id"], + "avatar": ["uploadimage"], + "username": ["messageheaders", "userCard", "username"], + #"username": ["pullmessages", 0, "userCard", "username"], + }, + "construct": { + "matrixuser": [ + "@rmass_", + {"resolved": "sender"}, + ":loxthelion.com", + ], + }, +} + +keys = [ + { + "keytitle": "avatar_url", + "keyvalue": { + "resolved": "avatar", + }, + }, +] + +method = "PUT" + +path = [ + "https://loxthelion.com/_matrix/client/v3/profile/", + {"resolved": "matrixuser"}, + "/avatar_url?user_id=", + {"resolved": "matrixuser"}, +] + +headers = { + "Authorization": { + "os": "AS_TOKEN", + "prefix": "Bearer ", + }, + "Content-Type": "application/json", +} +