From 5e9e1872afa8c770d5aa6eec478810b2368ab983 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 17 Dec 2022 21:05:29 +0200 Subject: [PATCH] Revert "remove the logic for fixing old mentions" This reverts commit 90f6f0b96e5a3dc41d99824accf49627813fed33. --- files/routes/admin.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/files/routes/admin.py b/files/routes/admin.py index 1f0d1d548..93aca3466 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -20,6 +20,23 @@ from files.routes.wrappers import * from .front import frontlist +my = re.compile('.*?(src="\/uid\/([0-9]?[a-zA-Z]+[0-9]?)\/pic\/profile").*?', flags=re.I) + +@app.get('/admin/fix') +@admin_level_required(3) +def fix_36(v): + comments = g.db.query(Submission).filter(Submission.body_html.op("SIMILAR TO")('%src="/uid/[0-9]?[a-zA-Z]+[0-9]?/pic/profile"%')).all() + g.db.query(Comment).filter(Comment.body_html.op("SIMILAR TO")('%src="/uid/[0-9]?[a-zA-Z]+[0-9]?/pic/profile"%')).all() + for c in comments: + print(c.id, flush=True) + for i in my.finditer(c.body_html): + b36 = i.group(2) + print(f"b36: {b36}") + b10 = int(b36, 36) + print(f"b10: {b10}") + new = f'src="/uid/{b10}/pic"' + c.body_html = c.body_html.replace(i.group(1), new) + return 'nig' + @app.post('/kippy') @admin_level_required(PERMS['PRINT_MARSEYBUX_FOR_KIPPY_ON_PCMEMES']) def kippy(v):