diff --git a/files/classes/comment.py b/files/classes/comment.py index 9dd32f24e..38ed5b802 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -32,7 +32,7 @@ class Comment(Base): parent_comment_id = Column(Integer, ForeignKey("comments.id")) over_18 = Column(Boolean, default=False) is_bot = Column(Boolean, default=False) - is_pinned = Column(String(255)) + is_pinned = Column(String(25)) sentto=Column(Integer) notifiedto=Column(Integer) app_id = Column(Integer, ForeignKey("oauth_apps.id")) diff --git a/files/classes/domains.py b/files/classes/domains.py index f7a528b7b..b68418e1f 100644 --- a/files/classes/domains.py +++ b/files/classes/domains.py @@ -5,8 +5,8 @@ class BannedDomain(Base): __tablename__ = "banneddomains" id = Column(Integer, primary_key=True) - domain = Column(String(255)) - reason = Column(String(255)) + domain = Column(String(50)) + reason = Column(String(100)) class BadLink(Base): @@ -14,5 +14,5 @@ class BadLink(Base): __tablename__ = "badlinks" id = Column(Integer, primary_key=True) link = Column(String(512)) - reason = Column(String(255)) + reason = Column(String(100)) autoban = Column(Boolean, default=False) \ No newline at end of file diff --git a/files/classes/images.py b/files/classes/images.py index 16cade148..b0de6cb76 100644 --- a/files/classes/images.py +++ b/files/classes/images.py @@ -12,13 +12,9 @@ class Image(Base): class BadPic(Base): - #Class for tracking fuzzy hashes of banned csam images - __tablename__="badpics" id = Column(BigInteger, primary_key=True) - description=Column(String(255)) + description=Column(String(200)) phash=Column(String(64)) ban_reason=Column(String(64)) - ban_time=Column(Integer) - - \ No newline at end of file + ban_time=Column(Integer) \ No newline at end of file diff --git a/files/classes/submission.py b/files/classes/submission.py index 6075b5ba7..f64cd01fe 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -22,7 +22,7 @@ class Submission(Base): author_id = Column(BigInteger, ForeignKey("users.id")) edited_utc = Column(BigInteger, default=0) created_utc = Column(BigInteger, default=0) - thumburl = Column(String(255)) + thumburl = Column(String(50)) is_banned = Column(Boolean, default=False) removed_by = Column(Integer) bannedfor = Column(Boolean) @@ -30,8 +30,8 @@ class Submission(Base): views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) - created_str = Column(String(255)) - stickied = Column(String(255)) + created_str = Column(String(25)) + stickied = Column(String(25)) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) club = Column(Boolean, default=False) diff --git a/files/classes/user.py b/files/classes/user.py index f43a2fff4..1238c3b0d 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -73,31 +73,31 @@ else: class User(Base): __tablename__ = "users" id = Column(Integer, primary_key=True) - username = Column(String(255)) - namecolor = Column(String(255), default=defaultcolor) - background = Column(String(255)) - customtitle = Column(String(255)) - customtitleplain = Column(String(255)) + username = Column(String(25)) + namecolor = Column(String(6), default=defaultcolor) + background = Column(String(20)) + customtitle = Column(String(300)) + customtitleplain = Column(String(100)) if "pcmemes.net" in site: - quadrant = Column(String(255)) + quadrant = Column(String(20)) basedcount = Column(Integer, default=0) - pills = Column(String(255), default="") + pills = deferred(Column(String(300), default="")) - titlecolor = Column(String(255), default=defaultcolor) - theme = Column(String(255), default=defaulttheme) - themecolor = Column(String(255), default=defaultcolor) + titlecolor = Column(String(6), default=defaultcolor) + theme = Column(String(10), default=defaulttheme) + themecolor = Column(String(6), default=defaultcolor) cardview = Column(Boolean, default=cardview) - song = Column(String(255)) - highres = Column(String(255)) - profileurl = Column(String(255)) - bannerurl = Column(String(255)) + song = Column(String(20)) + highres = Column(String(50)) + profileurl = Column(String(50)) + bannerurl = Column(String(50)) patron = Column(Integer, default=0) - verified = Column(String(255)) - email = Column(String(255)) + verified = Column(String(20)) + email = Column(String(50)) css = deferred(Column(String(4000))) profilecss = deferred(Column(String(4000))) - passhash = deferred(Column(String(255))) + passhash = deferred(Column(String(180))) post_count = Column(Integer, default=0) comment_count = Column(Integer, default=0) received_award_count = Column(Integer, default=0) @@ -112,7 +112,7 @@ class User(Base): agendaposter_expires_utc = Column(Integer, default=0) changelogsub = Column(Boolean, default=False) is_activated = Column(Boolean, default=False) - shadowbanned = Column(Boolean, default=False) + shadowbanned = Column(String(25), default=False) over_18 = Column(Boolean, default=False) hidevotedon = Column(Boolean, default=False) highlightcomments = Column(Boolean, default=True) @@ -131,7 +131,7 @@ class User(Base): is_banned = Column(Integer, default=0) unban_utc = Column(Integer, default=0) - ban_reason = Column(String(255)) + ban_reason = Column(String(120)) club_banned = Column(Boolean, default=False) club_allowed = Column(Boolean, default=False) login_nonce = Column(Integer, default=0) @@ -141,15 +141,15 @@ class User(Base): mfa_secret = deferred(Column(String(16))) is_private = Column(Boolean, default=False) stored_subscriber_count = Column(Integer, default=0) - defaultsortingcomments = Column(String(255), default="top") - defaultsorting = Column(String(255), default="hot") - defaulttime = Column(String(255), default=defaulttimefilter) + defaultsortingcomments = Column(String(15), default="top") + defaultsorting = Column(String(15), default="hot") + defaulttime = Column(String(5), default=defaulttimefilter) is_nofollow = Column(Boolean, default=False) custom_filter_list = Column(String(1000)) discord_id = Column(String(64)) ban_evade = Column(Integer, default=0) - original_username = deferred(Column(String(255))) + original_username = deferred(Column(String(25))) subscriptions = relationship("Subscription", viewonly=True) following = relationship("Follow", primaryjoin="Follow.user_id==User.id", viewonly=True) diff --git a/files/helpers/get.py b/files/helpers/get.py index 8a1f42f00..33399e758 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -210,7 +210,7 @@ def get_comments(cids, v=None, load_parent=False): ).filter(Comment.id.in_(cids)) if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] comments = comments.filter(Comment.author_id.notin_(shadowbanned)) comments = comments.join( @@ -236,7 +236,7 @@ def get_comments(cids, v=None, load_parent=False): output.append(comment) else: - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] output = g.db.query(Comment).options(lazyload('*')).filter(Comment.id.in_(cids), Comment.author_id.notin_(shadowbanned)).all() if load_parent: diff --git a/files/routes/admin.py b/files/routes/admin.py index 080f3ed23..2c2bb933f 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -755,11 +755,11 @@ def agendaposter(user_id, v): def shadowban(user_id, v): user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level != 0: abort(403) - user.shadowbanned = True + user.shadowbanned = v.username g.db.add(user) for alt in user.alts: if alt.admin_level > 0: break - alt.shadowbanned = True + alt.shadowbanned = v.username g.db.add(alt) ma = ModAction( kind="shadowban", @@ -780,10 +780,10 @@ def shadowban(user_id, v): def unshadowban(user_id, v): user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first() if user.admin_level != 0: abort(403) - user.shadowbanned = False + user.shadowbanned = None g.db.add(user) for alt in user.alts: - alt.shadowbanned = False + alt.shadowbanned = None g.db.add(alt) ma = ModAction( diff --git a/files/routes/comments.py b/files/routes/comments.py index d7ffd2700..576e9b526 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -85,7 +85,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): ) if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] comments = comments.filter(Comment.author_id.notin_(shadowbanned)) comments=comments.filter( diff --git a/files/routes/front.py b/files/routes/front.py index 06af889e2..ec02b0ba0 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -194,7 +194,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts=posts.filter(not_(Submission.title.ilike(f'%{word}%'))) if not (v and v.shadowbanned): - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] posts = posts.filter(Submission.author_id.notin_(shadowbanned)) if sort == "hot": diff --git a/files/routes/posts.py b/files/routes/posts.py index 5e6c0ca0c..eb76cfa5d 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -119,7 +119,7 @@ def post_id(pid, anything=None, v=None): ) if not (v and v.shadowbanned) and not (v and v.admin_level == 6): - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] comments = comments.filter(Comment.author_id.notin_(shadowbanned)) comments=comments.filter( @@ -160,7 +160,7 @@ def post_id(pid, anything=None, v=None): post.preloaded_comments = output else: - shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()] + shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] comments = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned)) if sort == "new": diff --git a/files/routes/settings.py b/files/routes/settings.py index e9e8d8856..adb7a75fd 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -46,7 +46,7 @@ def settings_profile_post(v): if request.values.get("background", v.background) != v.background: updated = True - v.background= request.values.get("background", None) + v.background = request.values.get("background", None) if request.values.get("slurreplacer", v.slurreplacer) != v.slurreplacer: updated = True @@ -755,7 +755,7 @@ def settings_song_change(v): if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User.id).options(lazyload('*')).filter_by(song=v.song).count() == 1: os.remove(f"/songs/{v.song}.mp3") - v.song=None + v.song = None g.db.add(v) g.db.commit() return redirect("/settings/profile") @@ -774,7 +774,7 @@ def settings_song_change(v): if "&" in id: id = id.split("&")[0] if path.isfile(f'/songs/{id}.mp3'): - v.song=id + v.song = id g.db.add(v) g.db.commit() return redirect("/settings/profile") @@ -824,7 +824,7 @@ def settings_song_change(v): songfile = max(paths, key=path.getctime) os.rename(songfile, f"/songs/{id}.mp3") - v.song=id + v.song = id g.db.add(v) g.db.commit() diff --git a/files/routes/users.py b/files/routes/users.py index d43d78045..f0a97e409 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -106,7 +106,7 @@ def suicide(v, username): @auth_required def get_coins(v, username): user = get_user(username) - if user is not None: return {"coins": user.coins}, 200 + if user != None: return {"coins": user.coins}, 200 else: return {"error": "invalid_user"}, 404 @app.post("/@/transfer_coins") diff --git a/files/templates/comments.html b/files/templates/comments.html index 822d90d25..b23cc8a47 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -194,7 +194,7 @@ {% endif %} {% if c.active_flags %}{{c.active_flags}} Reports{% endif %} {% if c.over_18 %}+18{% endif %} - {% if v and v.admin_level==6 and c.author.shadowbanned %}{% endif %} + {% if v and v.admin_level==6 and c.author.shadowbanned %}{% endif %} {% if c.is_pinned %}{% endif %} {% if c.distinguish_level %}{% endif %} {% if c.is_op %}{% endif %} diff --git a/files/templates/submission.html b/files/templates/submission.html index ef877b17b..21b3bada9 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -260,7 +260,7 @@ {% endfor %} {% endif %} - {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} + {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} {% if p.stickied %}{% endif %} {% if p.is_pinned %}{% endif %} {% if p.distinguish_level %} {% endif %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 891b31bf4..dd5742788 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -128,7 +128,7 @@ {% endfor %} {% endif %} - {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} + {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} {% if p.stickied %}{% endif %} {% if p.distinguish_level %}{% endif %} {% if p.is_pinned and request.path.startswith('/@') %}{% endif %}