Skip to content

Commit b28e560

Browse files
committed
created simplefilter class to encapsulate all filtering functionality. made bots active by default with toggle moderation mode active (moderating) or passive (filter only). rooms being moderated by bot are stored in dict as room:active_mode(bool)
1 parent c5e4afe commit b28e560

23 files changed

+493
-516
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def blind_user2(db):
267267
@pytest.fixture
268268
def no_rate_limit():
269269
"""Disables post rate limiting for the test"""
270-
import sogs.model.room as mroom
270+
from sogs.model.room import Room as mroom
271271

272272
saved = (mroom.rate_limit_size, mroom.rate_limit_interval)
273273
mroom.rate_limit_size, mroom.rate_limit_interval = None, None

contrib/auth-example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def get_signing_headers(
7171
body,
7272
blinded: bool = True,
7373
):
74-
7574
assert len(server_pk) == 32
7675
assert len(nonce) == 16
7776

contrib/pg-import.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686

8787

8888
with pgsql.transaction():
89-
9089
curin = old.cursor()
9190
curout = pgsql.cursor()
9291

@@ -131,7 +130,6 @@
131130
curout.execute("ALTER TABLE rooms DROP CONSTRAINT room_image_fk")
132131

133132
def copy(table):
134-
135133
cols = [r['name'] for r in curin.execute(f"PRAGMA table_info({table})")]
136134
if not cols:
137135
raise RuntimeError(f"Expected table {table} does not exist in sqlite db")

sogs/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ def parse_and_set_perm_flags(flags, perm_setting):
400400
sys.exit(2)
401401

402402
elif update_room:
403-
404403
rooms = []
405404
all_rooms = False
406405
global_rooms = False
@@ -577,8 +576,7 @@ def parse_and_set_perm_flags(flags, perm_setting):
577576
if args.name is not None:
578577
if global_rooms or all_rooms:
579578
print(
580-
"Error: --rooms cannot be '+' or '*' (i.e. global/all) with --name",
581-
file=sys.stderr,
579+
"Error: --rooms cannot be '+' or '*' (i.e. global/all) with --name", file=sys.stderr
582580
)
583581
sys.exit(1)
584582

sogs/migrations/file_message.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
def migrate(conn, *, check_only):
6-
76
from .. import db
87

98
fix_fk = False

sogs/migrations/import_hacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def migrate(conn, *, check_only):
4343
rows = conn.execute(
4444
"SELECT room, old_message_id_max, message_id_offset FROM room_import_hacks"
4545
)
46-
for (room, id_max, offset) in rows:
46+
for room, id_max, offset in rows:
4747
db.ROOM_IMPORT_HACKS[room] = (id_max, offset)
4848

4949
if not db.HAVE_FILE_ID_HACKS and 'room_import_hacks' not in db.metadata.tables:

sogs/migrations/reactions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
def migrate(conn, *, check_only):
6-
76
from .. import db
87

98
if 'user_reactions' in db.metadata.tables:
@@ -177,7 +176,6 @@ def migrate(conn, *, check_only):
177176
)
178177

179178
else: # postgresql
180-
181179
if 'seqno_data' not in db.metadata.tables['messages'].c:
182180
conn.execute(
183181
"""

sogs/migrations/v_0_1_x.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def sqlite_connect_readonly(path):
3939

4040

4141
def import_from_0_1_x(conn):
42-
4342
from .. import config, db, utils
4443

4544
# Old database database.db is a single table database containing just the list of rooms:
@@ -109,7 +108,6 @@ def ins_user(session_id):
109108
)
110109

111110
with sqlite_connect_readonly(room_db_path) as rconn:
112-
113111
# Messages were stored in this:
114112
#
115113
# CREATE TABLE IF NOT EXISTS messages (
@@ -235,7 +233,6 @@ def ins_user(session_id):
235233
and data in (None, "deleted")
236234
and signature in (None, "deleted")
237235
):
238-
239236
# Deleted message; we still need to insert a tombstone for it, and copy the
240237
# deletion id as the "seqno" field. (We do this with a second query
241238
# because the first query is going to trigger an automatic update of the
@@ -340,7 +337,6 @@ def ins_user(session_id):
340337
n_files = rconn.execute("SELECT COUNT(*) FROM files").fetchone()[0]
341338

342339
for file_id, timestamp in rconn.execute("SELECT id, timestamp FROM files"):
343-
344340
# file_id is an integer value but stored in a TEXT field, of course.
345341
file_id = int(file_id)
346342

@@ -507,7 +503,6 @@ def ins_user(session_id):
507503
""",
508504
(import_cutoff,),
509505
):
510-
511506
ins_user(session_id)
512507
db.query(
513508
"""

0 commit comments

Comments
 (0)