124-webapp/create_room.py
2025-11-10 15:24:10 +01:00

40 lines
983 B
Python

#!/usr/bin/env python3
"""
Create a Matrix room for print orders
"""
import json
import requests
access_token = "syt_ZWluc3p3b3ZpZXI_vebsCCpDYUkfsqLgnvjz_1WOI0g"
user_id = "@einszwovier:124.local"
# Create room
data = {
"name": "Print Orders",
"topic": "PDF print order submissions from the web app",
"preset": "private_chat",
"visibility": "private"
}
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
response = requests.post(
"http://localhost:8008/_matrix/client/r0/createRoom",
json=data,
headers=headers
)
print(f"Room creation response: {response.status_code}")
print(json.dumps(response.json(), indent=2))
if response.status_code == 200:
room_id = response.json()['room_id']
print(f"\n✅ Room created successfully!")
print(f"Room ID: {room_id}")
print(f"\n📋 Add this to your .env file:")
print(f"MATRIX_ROOM={room_id}")
else:
print(f"\n❌ Room creation failed")