This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select private_rooms.user_id, public_room_count + private_room_count as total_rooms | |
from (select user_id, count(distinct room_id) as private_room_count from users_who_share_private_rooms where user_id <> '' group by user_id) as private_rooms | |
inner join (select user_id, count(distinct room_id) as public_room_count from users_in_public_rooms where user_id <> '' group by user_id) as public_rooms on | |
public_rooms.user_id=private_rooms.user_id | |
order by total_rooms desc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select event_json.json::json->'content'->>'body' as message, | |
events.room_id, | |
room_stats_state.name, | |
events.sender | |
from events | |
left outer join event_json on | |
events.event_id=event_json.event_id | |
left outer join room_stats_state on | |
room_stats_state.room_id=events.room_id | |
where event_json.json::json->'content'->>'body'<>'' and events.sender='@ACCOUNT_NAME:SERVER.DOM'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pprint | |
token = 'PUT YOUR TOKEN HERE' | |
room = '!ROOM_ID:SERVER.DOM' | |
server_api = 'PUT YOUR SERVER HERE' # example: matrix.anontier.nl | |
query_members = f'https://{server_api}/_synapse/admin/v1/rooms/{room}/members?dir=b&from=0&limit=99999&order_by=id&access_token={token}' | |
query_devices = f'https://{server_api}/_matrix/client/r0/keys/query?access_token={token}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib | |
token = '<TOKEN>' | |
server = 'https://matrix.<SERVER NAME>.<TLD>' | |
api_rooms = f'{server}/_synapse/admin/v1/rooms?dir=b&from=0&limit=20&order_by=joined_local_members&access_token={token}' | |
delete_api = f'{server}/_synapse/admin/v1/rooms/' | |
local_users = 0 | |
while local_users == 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import requests | |
import time | |
import urllib | |
token = 'PUT TOKEN HERE' | |
days_from_now_start = 270 | |
days_from_now_end = 60 # will stop at minus 90 so we keep 3 months of history |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import requests | |
import urllib | |
import sys | |
import time | |
server = 'https://matrix.SERVER.TLD' | |
token = 'PUT TOKEN HERE' | |
# devices older than 180 days for users who didn't login for 45 days will be deleted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to prevent saving the user ip | |
CREATE OR REPLACE FUNCTION delete_ip() | |
RETURNS trigger AS | |
$BODY$ | |
BEGIN | |
NEW.ip = '127.0.0.1'; | |
RETURN NEW; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
event_json.json::json->'content'->>'body' as filename, | |
event_json.json::json->'content'->>'url' as url | |
from events | |
left outer join event_json on | |
events.event_id=event_json.event_id | |
left outer join room_stats_state on | |
room_stats_state.room_id=events.room_id | |
where event_json.json::json->'content'->>'url'<>'' and events.room_id='ROOM ID' limit 1000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### PASSWORDS ####### | |
# A shared secret (between Coturn and Synapse) used for authentication. | |
# You can put any string here, but generating a strong one is preferred (e.g. `pwgen -s 64 1`). | |
matrix_coturn_turn_static_auth_secret: '[REDACTED]' | |
# A secret used to protect access keys issued by the server. | |
# You can put any string here, but generating a strong one is preferred (e.g. `pwgen -s 64 1`). | |
matrix_synapse_macaroon_secret_key: '[REDACTED]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMP TABLE old_rooms AS | |
select distinct e_create.room_id | |
from events e_create | |
where e_create.type='m.room.create' and | |
e_create.origin_server_ts < [INSERT TIMESTAMP HERE]; # filter rooms created before timestamp, newer rooms not affected | |
CREATE TEMP TABLE old_rooms_new_events AS | |
select * | |
from events e_types |
OlderNewer