diff --git a/files/classes/alts.py b/files/classes/alts.py index 2b09c9aee..2cff4b7c2 100644 --- a/files/classes/alts.py +++ b/files/classes/alts.py @@ -12,7 +12,6 @@ class Alt(Base): user2 = Column(Integer, ForeignKey("users.id"), primary_key=True) is_manual = Column(Boolean, default=False) created_utc = Column(Integer) - deleted = Column(Boolean, default=False) def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) diff --git a/files/routes/admin.py b/files/routes/admin.py index d1c3a7280..7eb8cdc0f 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -610,15 +610,13 @@ def admin_add_alt(v:User, username): user2 = get_user(request.values.get('other_username')) if user1.id == user2.id: abort(400, "Can't add the same account as alts of each other") - deleted = request.values.get('deleted', False, bool) or False ids = [user1.id, user2.id] a = g.db.query(Alt).filter(Alt.user1.in_(ids), Alt.user2.in_(ids)).one_or_none() - if a: abort(409, f"@{user1.username} and @{user2.username} are already known {'linked' if not a.deleted else 'delinked'} alts") + if a: abort(409, f"@{user1.username} and @{user2.username} are already known alts!") a = Alt( user1=user1.id, user2=user2.id, is_manual=True, - deleted=deleted ) g.db.add(a) g.db.flush() @@ -629,17 +627,14 @@ def admin_add_alt(v:User, username): check_for_alts(user1) check_for_alts(user2) - word = 'Delinked' if deleted else 'Linked' - ma_word = 'delink' if deleted else 'link' - note = f'from @{user2.username}' if deleted else f'with @{user2.username}' ma = ModAction( - kind=f"{ma_word}_accounts", + kind=f"link_accounts", user_id=v.id, target_user_id=user1.id, - _note=note + _note=f'with @{user2.username}' ) g.db.add(ma) - return {"message": f"{word} @{user1.username} and @{user2.username} successfully!"} + return {"message": f"Linked @{user1.username} and @{user2.username} successfully!"} @app.post('/@/alts//deleted') @limiter.limit(DEFAULT_RATELIMIT_SLOWER) diff --git a/files/routes/routehelpers.py b/files/routes/routehelpers.py index 0664b5654..701dd1267 100644 --- a/files/routes/routehelpers.py +++ b/files/routes/routehelpers.py @@ -72,13 +72,6 @@ def check_for_alts(current:User, include_current_session=False): add_alt(past_id, current_id) other_alts = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).all() for a in other_alts: - if a.deleted: - if include_current_session: - try: session["history"].remove(a.user1) - except: pass - try: session["history"].remove(a.user2) - except: pass - continue # don't propagate deleted alt links if a.user1 != past_id: add_alt(a.user1, past_id) if a.user1 != current_id: add_alt(a.user1, current_id) if a.user2 != past_id: add_alt(a.user2, past_id) diff --git a/migrations/20230218-remove-deleted-column.sql b/migrations/20230218-remove-deleted-column.sql new file mode 100644 index 000000000..ce2c5d1b0 --- /dev/null +++ b/migrations/20230218-remove-deleted-column.sql @@ -0,0 +1,2 @@ +delete from alts where deleted=true; +alter table alts drop column deleted;