Skip to content

Commit 60acec7

Browse files
matrix-synapse API requests & stuff
1 parent ce1dde1 commit 60acec7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

matrix-synapse.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Snippets for interacting & performing updates on matrix-synapse server & database.
3+
4+
## Manually update password for a user in synapse postgresql database
5+
# 1: Generate a hash by running:
6+
/opt/venvs/matrix-synapse/bin/hash_password
7+
# Run the following query on your synapse psql databse:
8+
UPDATE users SET password_hash='<the hash here>' WHERE name='@<username>:<homeserver domain>';
9+
10+
## CURL request to get an access token for a particular user:
11+
curl -XPOST -d '{"type":"m.login.password", "user":"<username>", "password":"<plain_text_password>"}' "https://<homeserver_domain>/_matrix/client/r0/login"
12+
13+
## Send message as a user (must get access token as shown above; room_id looks like: !FUsJEhjhKcFSBczDVt:subtlefu.ge, get it from room settings -> advanced):
14+
curl -XPOST -d '{"msgtype":"m.text", "body":"Hello from '"$USER"'"}' "https://<homeserver_domain>/_matrix/client/r0/rooms/\<room_id>/send/m.room.message?access_token=<access_token>"
15+
16+
# send formatted text:
17+
curl -XPOST -d '{"msgtype":"m.text", "body":"**Hello**","format":"org.matrix.custom.html","formatted_body":"<strong>hello</strong>"}' "https://<homeserver_domain>/_matrix/client/r0/rooms/\<room_id>/send/m.room.message?access_token=<access_token>"
18+
19+
# register new user:
20+
curl -XPOST -d '{"username":"example", "password":"wordpass", "auth": {"type":"m.login.dummy"}}' "https://localhost:8448/_matrix/client/r0/register"
21+
22+
{
23+
"access_token": "QGV4YW1wbGU6bG9jYWxob3N0.AqdSzFmFYrLrTmteXc",
24+
"home_server": "localhost",
25+
"user_id": "@example:localhost"
26+
}
27+
28+
#Join room via alias:
29+
curl -XPOST -d '{}' "https://localhost:8448/_matrix/client/r0/join/%21asfLdzLnOdGRkdPZWu:localhost?access_token=YOUR_ACCESS_TOKEN"
30+

0 commit comments

Comments
 (0)