diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 18d7e45c3..b3d599d97 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -4624,8 +4624,6 @@ code { .fa,.fas,.far,.fal,.fad,.fab{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-.0667em}.fa-sm{font-size:.875em}.fa-2x{font-size:2em}.fa-fw{text-align:center;width:1.25em}.fa-flip-horizontal{-webkit-filter:none;filter:none}.fa-stack{display:inline-block;height:2em;line-height:2em;position:relative;vertical-align:middle;width:2.5em}.fa-stack-1x,.fa-stack-2x{left:0;position:absolute;text-align:center;width:100%}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-align-left:before{content:"\f036"}.fa-android:before{content:"\f17b"}.fa-arrow-alt-circle-down:before{content:"\f358"}.fa-arrow-alt-circle-up:before{content:"\f35b"}.fa-arrow-alt-down:before{content:"\f354"}.fa-arrow-alt-up:before{content:"\f357"}.fa-arrow-right:before{content:"\f061"}.fa-arrows-v:before{content:"\f07d"}.fa-badge-check:before{content:"\f336"}.fa-balance-scale:before{content:"\f24e"}.fa-ban:before{content:"\f05e"}.fa-bars:before{content:"\f0c9"}.fa-bell:before{content:"\f0f3"}.fa-bold:before{content:"\f032"}.fa-book:before{content:"\f02d"}.fa-book-dead:before{content:"\f6b7"}.fa-book-open:before{content:"\f518"}.fa-broom:before{content:"\f51a"}.fa-bug:before{content:"\f188"}.fa-bullhorn:before{content:"\f0a1"}.fa-calendar:before{content:"\f133"}.fa-calendar-alt:before{content:"\f073"}.fa-calendar-day:before{content:"\f783"}.fa-calendar-week:before{content:"\f784"}.fa-candy-cane:before{content:"\f786"}.fa-cat:before{content:"\f6be"}.fa-check:before{content:"\f00c"}.fa-check-circle:before{content:"\f058"}.fa-circle:before{content:"\f111"}.fa-clipboard:before{content:"\f328"}.fa-clipboard-check:before{content:"\f46c"}.fa-clock:before{content:"\f017"}.fa-code:before{content:"\f121"}.fa-cog:before{content:"\f013"}.fa-comment:before{content:"\f075"}.fa-comment-alt-smile:before{content:"\f4aa"}.fa-comment-dots:before{content:"\f4ad"}.fa-comments:before{content:"\f086"}.fa-compress-alt:before{content:"\f422"}.fa-copy:before{content:"\f0c5"}.fa-crown:before{content:"\f521"}.fa-discord:before{content:"\f392"}.fa-dna:before{content:"\f471"}.fa-dollar-sign:before{content:"\f155"}.fa-edit:before{content:"\f044"}.fa-ellipsis-h:before{content:"\f141"}.fa-envelope:before{content:"\f0e0"}.fa-envelope-open-text:before{content:"\f658"}.fa-exclamation-circle:before{content:"\f06a"}.fa-exclamation-triangle:before{content:"\f071"}.fa-expand-alt:before{content:"\f424"}.fa-external-link-alt:before{content:"\f35d"}.fa-eye:before{content:"\f06e"}.fa-eye-evil:before{content:"\f6db"}.fa-eye-slash:before{content:"\f070"}.fa-feather-alt:before{content:"\f56b"}.fa-file-signature:before{content:"\f573"}.fa-filter:before{content:"\f0b0"}.fa-fire:before{content:"\f06d"}.fa-flag:before{content:"\f024"}.fa-frown:before{content:"\f119"}.fa-gavel:before{content:"\f0e3"}.fa-ghost:before{content:"\f6e2"}.fa-gift:before{content:"\f06b"}.fa-github:before{content:"\f09b"}.fa-globe:before{content:"\f0ac"}.fa-grin-beam-sweat:before{content:"\f583"}.fa-home-alt:before{content:"\f80a"}.fa-id-badge:before{content:"\f2c1"}.fa-id-card:before{content:"\f2c2"}.fa-image:before{content:"\f03e"}.fa-infinity:before{content:"\f534"}.fa-info-circle:before{content:"\f05a"}.fa-italic:before{content:"\f033"}.fa-knife-kitchen:before{content:"\f6f5"}.fa-laugh-squint:before{content:"\f59b"}.fa-lights-holiday:before{content:"\f7b2"}.fa-link:before{content:"\f0c1"}.fa-lock:before{content:"\f023"}.fa-lock-alt:before{content:"\f30d"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-microphone-stand:before{content:"\f8cb"}.fa-mistletoe:before{content:"\f7b4"}.fa-music:before{content:"\f001"}.fa-palette:before{content:"\f53f"}.fa-pencil:before{content:"\f040"}.fa-pizza-slice:before{content:"\f818"}.fa-poop:before{content:"\f619"}.fa-quote-right:before{content:"\f10e"}.fa-random:before{content:"\f074"}.fa-reply:before{content:"\f3e5"}.fa-robot:before{content:"\f544"}.fa-save:before{content:"\f0c7"}.fa-scroll-old:before{content:"\f70f"}.fa-search:before{content:"\f002"}.fa-seedling:before{content:"\f4d8"}.fa-sign-out:before{content:"\f08b"}.fa-smile-beam:before{content:"\f5b8"}.fa-smoke:before{content:"\f760"}.fa-snooze:before{content:"\f880"}.fa-snowflake:before{content:"\f2dc"}.fa-sparkles:before{content:"\f890"}.fa-spider:before{content:"\f717"}.fa-square:before{content:"\f0c8"}.fa-store:before{content:"\f54e"}.fa-thumbtack:before{content:"\f08d";padding:2px;}.fa-times:before{content:"\f00d"}.fa-times-circle:before{content:"\f057"}.fa-train:before{content:"\f238"}.fa-trash-alt:before{content:"\f2ed"}.fa-treasure-chest:before{content:"\f723"}.fa-trophy:before{content:"\f091"}.fa-twitter:before{content:"\f099"}.fa-user:before{content:"\f007"}.fa-user-circle:before{content:"\f2bd"}.fa-user-cog:before{content:"\f4fe"}.fa-user-friends:before{content:"\f500"}.fa-user-lock:before{content:"\f502"}.fa-user-minus:before{content:"\f503"}.fa-user-plus:before{content:"\f234"}.fa-user-slash:before{content:"\f506"}.fa-user-tag:before{content:"\f507"}.fa-user-times:before{content:"\f235"}.fa-volume:before{content:"\f6a8"}.fa-volume-mute:before{content:"\f6a9"}@font-face{font-family:'font awesome 5 brands';font-style:normal;font-weight:400;font-display:swap;src:url(../fonts/fa-brands-400.eot);src:url(../fonts/fa-brands-400.eot?#iefix) format("embedded-opentype"),url(../fonts/fa-brands-400.woff2) format("woff2"),url(../fonts/fa-brands-400.woff) format("woff"),url(../fonts/fa-brands-400.ttf) format("truetype"),url(../fonts/fa-brands-400.svg#fontawesome) format("svg")}.fab{font-family:'font awesome 5 brands'!important}@font-face{font-family:'font awesome 5 duotone';font-style:normal;font-weight:900;font-display:swap;src:url(../fonts/fa-duotone-900.eot);src:url(../fonts/fa-duotone-900.eot?#iefix) format("embedded-opentype"),url(../fonts/fa-duotone-900.woff2) format("woff2"),url(../fonts/fa-duotone-900.woff) format("woff"),url(../fonts/fa-duotone-900.ttf) format("truetype"),url(../fonts/fa-duotone-900.svg#fontawesome) format("svg")}.fad{position:relative;font-family:'font awesome 5 duotone'!important;font-weight:900}.fad:before{position:absolute;color:var(--fa-primary-color,inherit);opacity:1;opacity:var(--fa-primary-opacity,1)}.fad:after{color:var(--fa-secondary-color,inherit);opacity:.4;opacity:var(--fa-secondary-opacity,0.4)}.fad.fa-stack-1x,.fad.fa-stack-2x{position:absolute}.fad.fa-stack-1x:before,.fad.fa-stack-2x:before,.fad.fa-fw:before{left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%)}.fad.fa-align-left:after{content:"\10f036"}.fad.fa-arrow-alt-circle-down:after{content:"\10f358"}.fad.fa-arrow-alt-circle-up:after{content:"\10f35b"}.fad.fa-arrow-alt-down:after{content:"\10f354"}.fad.fa-arrow-alt-up:after{content:"\10f357"}.fad.fa-arrow-right:after{content:"\10f061"}.fad.fa-arrows-v:after{content:"\10f07d"}.fad.fa-badge-check:after{content:"\10f336"}.fad.fa-balance-scale:after{content:"\10f24e"}.fad.fa-ban:after{content:"\10f05e"}.fad.fa-bars:after{content:"\10f0c9"}.fad.fa-bell:after{content:"\10f0f3"}.fad.fa-bold:after{content:"\10f032"}.fad.fa-book:after{content:"\10f02d"}.fad.fa-book-dead:after{content:"\10f6b7"}.fad.fa-book-open:after{content:"\10f518"}.fad.fa-broom:after{content:"\10f51a"}.fad.fa-bug:after{content:"\10f188"}.fad.fa-bullhorn:after{content:"\10f0a1"}.fad.fa-calendar:after{content:"\10f133"}.fad.fa-calendar-alt:after{content:"\10f073"}.fad.fa-calendar-day:after{content:"\10f783"}.fad.fa-calendar-week:after{content:"\10f784"}.fad.fa-candy-cane:after{content:"\10f786"}.fad.fa-cat:after{content:"\10f6be"}.fad.fa-check:after{content:"\10f00c"}.fad.fa-check-circle:after{content:"\10f058"}.fad.fa-circle:after{content:"\10f111"}.fad.fa-clipboard:after{content:"\10f328"}.fad.fa-clipboard-check:after{content:"\10f46c"}.fad.fa-clock:after{content:"\10f017"}.fad.fa-code:after{content:"\10f121"}.fad.fa-cog:after{content:"\10f013"}.fad.fa-comment:after{content:"\10f075"}.fad.fa-comment-alt-smile:after{content:"\10f4aa"}.fad.fa-comment-dots:after{content:"\10f4ad"}.fad.fa-comments:after{content:"\10f086"}.fad.fa-compress-alt:after{content:"\10f422"}.fad.fa-copy:after{content:"\10f0c5"}.fad.fa-crown:after{content:"\10f521"}.fad.fa-dna:after{content:"\10f471"}.fad.fa-dollar-sign:after{content:"\10f155"}.fad.fa-edit:after{content:"\10f044"}.fad.fa-ellipsis-h:after{content:"\10f141"}.fad.fa-envelope:after{content:"\10f0e0"}.fad.fa-envelope-open-text:after{content:"\10f658"}.fad.fa-exclamation-circle:after{content:"\10f06a"}.fad.fa-exclamation-triangle:after{content:"\10f071"}.fad.fa-expand-alt:after{content:"\10f424"}.fad.fa-external-link-alt:after{content:"\10f35d"}.fad.fa-eye:after{content:"\10f06e"}.fad.fa-eye-evil:after{content:"\10f6db"}.fad.fa-eye-slash:after{content:"\10f070"}.fad.fa-feather-alt:after{content:"\10f56b"}.fad.fa-file-signature:after{content:"\10f573"}.fad.fa-filter:after{content:"\10f0b0"}.fad.fa-fire:after{content:"\10f06d"}.fad.fa-flag:after{content:"\10f024"}.fad.fa-frown:after{content:"\10f119"}.fad.fa-gavel:after{content:"\10f0e3"}.fad.fa-ghost:after{content:"\10f6e2"}.fad.fa-gift:after{content:"\10f06b"}.fad.fa-globe:after{content:"\10f0ac"}.fad.fa-grin-beam-sweat:after{content:"\10f583"}.fad.fa-home-alt:after{content:"\10f80a"}.fad.fa-id-badge:after{content:"\10f2c1"}.fad.fa-id-card:after{content:"\10f2c2"}.fad.fa-image:after{content:"\10f03e"}.fad.fa-infinity:after{content:"\10f534"}.fad.fa-info-circle:after{content:"\10f05a"}.fad.fa-italic:after{content:"\10f033"}.fad.fa-knife-kitchen:after{content:"\10f6f5"}.fad.fa-laugh-squint:after{content:"\10f59b"}.fad.fa-lights-holiday:after{content:"\10f7b2"}.fad.fa-link:after{content:"\10f0c1"}.fad.fa-lock:after{content:"\10f023"}.fad.fa-lock-alt:after{content:"\10f30d"}.fad.fa-long-arrow-left:after{content:"\10f177"}.fad.fa-long-arrow-right:after{content:"\10f178"}.fad.fa-microphone-stand:after{content:"\10f8cb"}.fad.fa-mistletoe:after{content:"\10f7b4"}.fad.fa-music:after{content:"\10f001"}.fad.fa-palette:after{content:"\10f53f"}.fad.fa-pencil:after{content:"\10f040"}.fad.fa-pizza-slice:after{content:"\10f818"}.fad.fa-poop:after{content:"\10f619"}.fad.fa-quote-right:after{content:"\10f10e"}.fad.fa-random:after{content:"\10f074"}.fad.fa-reply:after{content:"\10f3e5"}.fad.fa-robot:after{content:"\10f544"}.fad.fa-save:after{content:"\10f0c7"}.fad.fa-scroll-old:after{content:"\10f70f"}.fad.fa-search:after{content:"\10f002"}.fad.fa-seedling:after{content:"\10f4d8"}.fad.fa-sign-out:after{content:"\10f08b"}.fad.fa-smile-beam:after{content:"\10f5b8"}.fad.fa-smoke:after{content:"\10f760"}.fad.fa-snooze:after{content:"\10f880"}.fad.fa-snowflake:after{content:"\10f2dc"}.fad.fa-sparkles:after{content:"\10f890"}.fad.fa-spider:after{content:"\10f717"}.fad.fa-square:after{content:"\10f0c8"}.fad.fa-store:after{content:"\10f54e"}.fad.fa-thumbtack:after{content:"\10f08d"}.fad.fa-times:after{content:"\10f00d"}.fad.fa-times-circle:after{content:"\10f057"}.fad.fa-train:after{content:"\10f238"}.fad.fa-trash-alt:after{content:"\10f2ed"}.fad.fa-treasure-chest:after{content:"\10f723"}.fad.fa-trophy:after{content:"\10f091"}.fad.fa-user:after{content:"\10f007"}.fad.fa-user-circle:after{content:"\10f2bd"}.fad.fa-user-cog:after{content:"\10f4fe"}.fad.fa-user-friends:after{content:"\10f500"}.fad.fa-user-lock:after{content:"\10f502"}.fad.fa-user-minus:after{content:"\10f503"}.fad.fa-user-plus:after{content:"\10f234"}.fad.fa-user-slash:after{content:"\10f506"}.fad.fa-user-tag:after{content:"\10f507"}.fad.fa-user-times:after{content:"\10f235"}.fad.fa-volume:after{content:"\10f6a8"}.fad.fa-volume-mute:after{content:"\10f6a9"}@font-face{font-family:'font awesome 5 pro';font-style:normal;font-weight:300;font-display:swap;src:url(../fonts/fa-light-300.eot);src:url(../fonts/fa-light-300.eot?#iefix) format("embedded-opentype"),url(../fonts/fa-light-300.woff2) format("woff2"),url(../fonts/fa-light-300.woff) format("woff"),url(../fonts/fa-light-300.ttf) format("truetype"),url(../fonts/fa-light-300.svg#fontawesome) format("svg")}.fal{font-family:'font awesome 5 pro'!important;;font-weight:300}@font-face{font-family:'font awesome 5 pro';font-style:normal;font-weight:400;font-display:swap;src:url(../fonts/fa-regular-400.eot);src:url(../fonts/fa-regular-400.eot?#iefix) format("embedded-opentype"),url(../fonts/fa-regular-400.woff2) format("woff2"),url(../fonts/fa-regular-400.woff) format("woff"),url(../fonts/fa-regular-400.ttf) format("truetype"),url(../fonts/fa-regular-400.svg#fontawesome) format("svg")}.far{font-family:'font awesome 5 pro'!important;;font-weight:400}@font-face{font-family:'font awesome 5 pro';font-style:normal;font-weight:900;font-display:swap;src:url(../fonts/fa-solid-900.eot);src:url(../fonts/fa-solid-900.eot?#iefix) format("embedded-opentype"),url(../fonts/fa-solid-900.woff2) format("woff2"),url(../fonts/fa-solid-900.woff) format("woff"),url(../fonts/fa-solid-900.ttf) format("truetype"),url(../fonts/fa-solid-900.svg#fontawesome) format("svg")}.fa,.fas{font-family:'font awesome 5 pro'!important;font-weight:900} -.fa-fish:before{content:"\f578"}.fa-gingerbread-man:before{content:"\f79d"}.fa-fireplace:before{content:"\f79a"}.fa-angry:before{content:"\f556"}.fad.fa-gingerbread-man:after{content:"\10f79d"}.fad.fa-fireplace:after{content:"\10f79a"}.fad.fa-angry:after{content:"\10f556"}.fa-stocking:before{content:"\f7d5"}.fad.fa-stocking:after{content:"\10f7d5"}.fa-columns:before{content:"\f0db"}.fad.fa-columns:after{content:"\10f0db"}.fa-shield:before{content:"\f132"}.fad.fa-shield:after{content:"\10f132"}.fa-dice-six:before{content:"\f526"}.fad.fa-dice-six:after{content:"\10f526"}.fa-badge:before{content:"\f335"}.fad.fa-badge:after{content:"\10f335"}.fa-users:before{content:"\f0c0"}.fad.fa-users:after{content:"\10f0c0"}.fa-user-crown:before{content:"\f6a4"}.fad.fa-user-crown:after{content:"\10f6a4"}.fa-radiation-alt:before{content:"\f7ba"}.fad.fa-radiation-alt:after{content:"\10f7ba"}.fa-golf-club:before{content:"\f451"}.fad.fa-golf-club:after{content:"\10f451"}.fa-memory:before{content:"\f538"}.fad.fa-memory:after{content:"\10f538"}.fa-award:before{content:"\f559"}.fad.fa-award:after{content:"\10f559"}.fa-sack-dollar:before{content:"\f81d"}.fad.fa-sack-dollar:after{content:"\10f81d"}.fa-history:before{content:"\f1da"}.fad.fa-history:after{content:"\10f1da"}.fa-flag-usa:before{content:"\f74d"}.fad.fa-flag-usa:after{content:"\10f74d"}.fa-car-tilt:before{content:"\f5e5"}.fad.fa-car-tilt:after{content:"\10f5e5"} - lite-youtube { background-color: #000; position: relative; @@ -4759,4 +4757,6 @@ img.golden { .toast { bottom: 5rem !important; } -} \ No newline at end of file +} + +.fa-fish:before{content:"\f578"}.fa-gingerbread-man:before{content:"\f79d"}.fa-fireplace:before{content:"\f79a"}.fa-angry:before{content:"\f556"}.fad.fa-gingerbread-man:after{content:"\10f79d"}.fad.fa-fireplace:after{content:"\10f79a"}.fad.fa-angry:after{content:"\10f556"}.fa-stocking:before{content:"\f7d5"}.fad.fa-stocking:after{content:"\10f7d5"}.fa-columns:before{content:"\f0db"}.fad.fa-columns:after{content:"\10f0db"}.fa-shield:before{content:"\f132"}.fad.fa-shield:after{content:"\10f132"}.fa-dice-six:before{content:"\f526"}.fad.fa-dice-six:after{content:"\10f526"}.fa-badge:before{content:"\f335"}.fad.fa-badge:after{content:"\10f335"}.fa-users:before{content:"\f0c0"}.fad.fa-users:after{content:"\10f0c0"}.fa-user-crown:before{content:"\f6a4"}.fad.fa-user-crown:after{content:"\10f6a4"}.fa-radiation-alt:before{content:"\f7ba"}.fad.fa-radiation-alt:after{content:"\10f7ba"}.fa-golf-club:before{content:"\f451"}.fad.fa-golf-club:after{content:"\10f451"}.fa-memory:before{content:"\f538"}.fad.fa-memory:after{content:"\10f538"}.fa-award:before{content:"\f559"}.fad.fa-award:after{content:"\10f559"}.fa-sack-dollar:before{content:"\f81d"}.fad.fa-sack-dollar:after{content:"\10f81d"}.fa-history:before{content:"\f1da"}.fad.fa-history:after{content:"\10f1da"}.fa-flag-usa:before{content:"\f74d"}.fad.fa-flag-usa:after{content:"\10f74d"}.fa-car-tilt:before{content:"\f5e5"}.fad.fa-car-tilt:after{content:"\10f5e5"}.fa-campfire:before{content:"\f6ba"}.fad.fa-campfire:after{content:"\10f6ba"} \ No newline at end of file diff --git a/files/classes/comment.py b/files/classes/comment.py index 41fc2af84..09d207620 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -228,7 +228,7 @@ class Comment(Base): @property @lazy - def shortlink_context(self): + def sl(self): return f"/comment/{self.id}?context=8#context" @property diff --git a/files/classes/exiles.py b/files/classes/exiles.py new file mode 100644 index 000000000..b2469e55a --- /dev/null +++ b/files/classes/exiles.py @@ -0,0 +1,12 @@ +from sqlalchemy import * +from sqlalchemy.orm import relationship +from files.__main__ import Base + +class Exile(Base): + + __tablename__ = "exiles" + user_id = Column(Integer, ForeignKey("users.id"), primary_key=True) + sub = Column(String, ForeignKey("subs.name"), primary_key=True) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/files/classes/submission.py b/files/classes/submission.py index 0aacb5870..c300524f6 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -204,6 +204,13 @@ class Submission(Base): def fullname(self): return f"t2_{self.id}" + + @property + @lazy + def sl(self): + return f'/post/{self.id}' + + @property @lazy def shortlink(self): diff --git a/files/classes/user.py b/files/classes/user.py index 7220d0581..84e4f9dcd 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -14,6 +14,7 @@ from .badges import * from .clients import * from .mod_logs import * from .mod import * +from .exiles import * from .sub_block import * from files.__main__ import Base, cache from files.helpers.security import * @@ -153,7 +154,11 @@ class User(Base): @lazy def mods(self, sub): - return self.id == AEVANN_ID or g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none() + return self.id == AEVANN_ID or bool(g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none()) + + @lazy + def exiled_from(self, sub): + return self.admin_level < 2 and bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none()) @property @lazy diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index eed536fa4..c3b54eb58 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -117,9 +117,9 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): if u: sanitized = sanitized.replace(i.group(0), f'''

@{u.username}'s profile picture@{u.username}''', 1) else: - sanitized = re.sub('(^|\s|\n|

)\/?((r|u)\/(\w|-){3,25})', r'\1\2', sanitized, re.A) + sanitized = re.sub('(^|\s|\n|

)\/?((r|u)\/(\w|-){3,25})', r'\1/\2', sanitized, re.A) - sanitized = re.sub('(^|\s|\n|

)\/?(s\/(\w|-){3,25})', r'\1\2', sanitized, re.A) + sanitized = re.sub('(^|\s|\n|

)\/?(s\/(\w|-){3,25})', r'\1/\2', sanitized, re.A) for i in re.finditer('(^|\s|\n|

)@((\w|-){1,25})', sanitized, re.A): u = get_user(i.group(2), graceful=True) diff --git a/files/routes/admin.py b/files/routes/admin.py index 8730f0f05..88009f961 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -85,13 +85,13 @@ def distribute(v, comment): votes = g.db.query(CommentVote).filter_by(comment_id=comment) coinsperperson = int(pool / votes.count()) - cid = notif_comment(f"You won {coinsperperson} coins betting on [{post.permalink}]({post.permalink}) :marseyparty:") + cid = notif_comment(f"You won {coinsperperson} coins betting on [{post.title}]({post.sl}) :marseyparty:") for vote in votes: u = vote.user u.coins += coinsperperson add_notif(cid, u.id) - cid = notif_comment(f"You lost the 200 coins you bet on [{post.permalink}]({post.permalink}) :marseylaugh:") + cid = notif_comment(f"You lost the 200 coins you bet on [{post.title}]({post.sl}) :marseylaugh:") cids = [x.id for x in post.bet_options] cids.remove(comment) votes = g.db.query(CommentVote).filter(CommentVote.comment_id.in_(cids)).all() @@ -1240,7 +1240,7 @@ def sticky_comment(cid, v): g.db.add(ma) if v.id != comment.author_id: - message = f"@{v.username} has pinned your [comment]({comment.permalink})!" + message = f"@{v.username} has pinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() @@ -1267,7 +1267,7 @@ def unsticky_comment(cid, v): g.db.add(ma) if v.id != comment.author_id: - message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" + message = f"@{v.username} has unpinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() diff --git a/files/routes/awards.py b/files/routes/awards.py index b8f03f4d7..5f6f99319 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -227,7 +227,7 @@ def award_post(pid, v): author = post.author if v.id != author.id: - msg = f"@{v.username} has given your [post]({post.permalink}) the {AWARDS[kind]['title']} Award!" + msg = f"@{v.username} has given your [post]({post.sl}) the {AWARDS[kind]['title']} Award!" if note: msg += f"\n\n> {note}" send_repeatable_notification(author.id, msg) @@ -235,7 +235,7 @@ def award_post(pid, v): return {"error": "You can't use this award on yourself."}, 400 if kind == "ban": - link = f"[this post]({post.permalink})" + link = f"[this post]({post.sl})" if not author.is_suspended: author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1) @@ -258,7 +258,7 @@ def award_post(pid, v): author.is_banned = AUTOJANNY_ID author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}" author.unban_utc = int(time.time()) + 30 * 86400 - link = f"[this post]({post.permalink})" + link = f"[this post]({post.sl})" send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!") elif kind == "pin": if post.stickied and post.stickied_utc: @@ -461,7 +461,7 @@ def award_comment(cid, v): author = c.author if v.id != author.id: - msg = f"@{v.username} has given your [comment]({c.permalink}) the {AWARDS[kind]['title']} Award!" + msg = f"@{v.username} has given your [comment]({c.sl}) the {AWARDS[kind]['title']} Award!" if note: msg += f"\n\n> {note}" send_repeatable_notification(author.id, msg) @@ -469,7 +469,7 @@ def award_comment(cid, v): return {"error": "You can't use this award on yourself."}, 400 if kind == "ban": - link = f"[this comment]({c.permalink})" + link = f"[this comment]({c.sl})" if not author.is_suspended: author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1) @@ -492,7 +492,7 @@ def award_comment(cid, v): author.is_banned = AUTOJANNY_ID author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}" author.unban_utc = int(time.time()) + 30 * 86400 - link = f"[this comment]({c.permalink})" + link = f"[this comment]({c.sl})" send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!") elif kind == "pin": if c.is_pinned and c.is_pinned_utc: c.is_pinned_utc += 3600 diff --git a/files/routes/comments.py b/files/routes/comments.py index 82ac3fc13..b0ce382c7 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -148,6 +148,9 @@ def api_comment(v): parent_fullname = request.values.get("parent_fullname").strip() parent_post = get_post(parent_submission, v=v) + sub = parent_post.sub + if sub and v.exiled_from(sub): return {"error": f"You're exiled from /s/{sub}"}, 403 + if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403) if parent_fullname.startswith("t2_"): @@ -926,7 +929,7 @@ def pin_comment(cid, v): g.db.add(comment) if v.id != comment.author_id: - message = f"@{v.username} (OP) has pinned your [comment]({comment.permalink})!" + message = f"@{v.username} (OP) has pinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() @@ -949,7 +952,7 @@ def unpin_comment(cid, v): g.db.add(comment) if v.id != comment.author_id: - message = f"@{v.username} (OP) has unpinned your [comment]({comment.permalink})!" + message = f"@{v.username} (OP) has unpinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() return {"message": "Comment unpinned!"} @@ -969,7 +972,7 @@ def mod_pin(cid, v): g.db.add(comment) if v.id != comment.author_id: - message = f"@{v.username} (Mod) has pinned your [comment]({comment.permalink})!" + message = f"@{v.username} (Mod) has pinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() @@ -989,7 +992,7 @@ def mod_unpin(cid, v): g.db.add(comment) if v.id != comment.author_id: - message = f"@{v.username} (Mod) has unpinned your [comment]({comment.permalink})!" + message = f"@{v.username} (Mod) has unpinned your [comment]({comment.sl})!" send_repeatable_notification(comment.author_id, message) g.db.commit() return {"message": "Comment unpinned!"} diff --git a/files/routes/posts.py b/files/routes/posts.py index 340af2ee0..2be4be84e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -96,11 +96,11 @@ def publish(pid, v): if not post.ghost: notify_users = NOTIFY_USERS(post.body_html, v) | NOTIFY_USERS2(post.title, v) - cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.permalink})") + cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.sl})") for x in notify_users: add_notif(cid, x) - cid = notif_comment(f"@{v.username} has made a new post: [{post.title}]({post.permalink})", autojanny=True) + cid = notif_comment(f"@{v.username} has made a new post: [{post.title}]({post.sl})", autojanny=True) for follow in v.followers: user = get_account(follow.user_id) if post.club and not user.paid_dues: continue @@ -126,7 +126,7 @@ def submit_get(v, sub=None): if request.path.startswith('/s/') and not sub: abort(404) - return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub, ghost=submit_ghost(v,g.db)) + return render_template("submit.html", SUBS=tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub, ghost=submit_ghost(v,g.db)) @app.get("/post/") @app.get("/post//") @@ -603,7 +603,7 @@ def edit_post(pid, v): if not p.private and not p.ghost: notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v) - cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.permalink})") + cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.sl})") for x in notify_users: add_notif(cid, x) @@ -844,13 +844,6 @@ def thumbnail_thread(pid): @limiter.limit("1/second;6/minute;200/hour;1000/day") @auth_required def submit_post(v, sub=None): - if not sub: sub = request.values.get("sub") - - if sub: - sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none() - if not sub: abort(404) - sub = sub[0] - else: sub = None title = request.values.get("title", "").strip()[:500].replace('‎','') @@ -859,15 +852,24 @@ def submit_post(v, sub=None): body = request.values.get("body", "").strip().replace('‎','') def error(error): - print(sub, flush=True) - if request.headers.get("Authorization") or request.headers.get("xhr"): error(error) - return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=error, title=title, url=url, body=body, price=submit_ghost(v,g.db)), 400 + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": error}, 403 + return render_template("submit.html", SUBS=tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=error, title=title, url=url, body=body, ghost=submit_ghost(v,g.db)), 400 - if v.is_suspended: error( "You can't perform this action while banned.") + + if not sub: sub = request.values.get("sub") + + if sub: + sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none() + if not sub: abort(404) + sub = sub[0] + if v.exiled_from(sub): return error(f"You're exiled from /s/{sub}") + else: sub = None + + if v.is_suspended: return error("You can't perform this action while banned.") if v and v.patron: - if request.content_length > 8 * 1024 * 1024: error( "Max file size is 8 MB.") - elif request.content_length > 4 * 1024 * 1024: error( "Max file size is 4 MB.") + if request.content_length > 8 * 1024 * 1024: return error( "Max file size is 8 MB.") + elif request.content_length > 4 * 1024 * 1024: return error( "Max file size is 4 MB.") if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) @@ -1060,7 +1062,7 @@ def submit_post(v, sub=None): file.save("video.mp4") with open("video.mp4", 'rb') as f: try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] - except: error( "Imgur error") + except: return error( "Imgur error") if url.endswith('.'): url += 'mp4' body += f"\n\n{url}" else: @@ -1188,7 +1190,7 @@ def submit_post(v, sub=None): file.save("video.mp4") with open("video.mp4", 'rb') as f: try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] - except: error( "Imgur error") + except: return error( "Imgur error") if url.endswith('.'): url += 'mp4' new_post.url = url else: @@ -1207,11 +1209,11 @@ def submit_post(v, sub=None): notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v) - cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.permalink})") + cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.sl})") for x in notify_users: add_notif(cid, x) - cid = notif_comment(f"@{v.username} has made a new post: [{title}]({new_post.permalink})", autojanny=True) + cid = notif_comment(f"@{v.username} has made a new post: [{title}]({new_post.sl})", autojanny=True) for follow in v.followers: user = get_account(follow.user_id) if new_post.club and not user.paid_dues: continue diff --git a/files/routes/subs.py b/files/routes/subs.py index fa96c06ec..b20814098 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -7,6 +7,119 @@ from .front import frontlist valid_sub_regex = re.compile("^[a-zA-Z0-9_\-]{3,20}$") + + + + +@app.post("/exile/post/") +@is_not_permabanned +def exile_post(v, pid): + try: pid = int(pid) + except: abort(400) + + p = get_post(pid) + sub = p.sub + if not sub: abort(400) + + if not v.mods(sub): abort(403) + + u = p.author + + if u.admin_level < 2 and not u.exiled_from(sub): + exile = Exile(user_id=u.id, sub=sub) + g.db.add(exile) + + send_notification(u.id, f"You have been exiled from /s/{sub} for [{p.title}]({p.sl})") + + g.db.commit() + + return {"message": "User exiled successfully!"} + + + +@app.post("/unexile/post/") +@is_not_permabanned +def unexile_post(v, pid): + try: pid = int(pid) + except: abort(400) + + p = get_post(pid) + sub = p.sub + if not sub: abort(400) + + if not v.mods(sub): abort(403) + + u = p.author + + if u.exiled_from(sub): + exile = g.db.query(Exile).filter_by(user_id=u.id, sub=sub).one_or_none() + g.db.delete(exile) + + send_notification(u.id, f"Your exile from /s/{sub} has been revoked!") + + g.db.commit() + + return {"message": "User unexiled successfully!"} + + + + +@app.post("/exile/comment/") +@is_not_permabanned +def exile_comment(v, cid): + try: cid = int(cid) + except: abort(400) + + c = get_comment(cid) + sub = c.post.sub + if not sub: abort(400) + + if not v.mods(sub): abort(403) + + u = c.author + + if u.admin_level < 2 and not u.exiled_from(sub): + exile = Exile(user_id=u.id, sub=sub) + g.db.add(exile) + + send_notification(u.id, f"You have been exiled from /s/{sub} for [{c.permalink}]({c.sl})") + + g.db.commit() + + return {"message": "User exiled successfully!"} + + + + +@app.post("/unexile/comment/") +@is_not_permabanned +def unexile_comment(v, cid): + try: cid = int(cid) + except: abort(400) + + c = get_comment(cid) + sub = c.post.sub + if not sub: abort(400) + + if not v.mods(sub): abort(403) + + u = c.author + + if u.exiled_from(sub): + exile = g.db.query(Exile).filter_by(user_id=u.id, sub=sub).one_or_none() + g.db.delete(exile) + + send_notification(u.id, f"Your exile from /s/{sub} has been revoked!") + + g.db.commit() + + return {"message": "User unexiled successfully!"} + + + + + + @app.post("/s//block") @auth_required def block_sub(v, sub): diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 29490100f..063a4ff82 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,7 +15,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} diff --git a/files/templates/comments.html b/files/templates/comments.html index 4edda0398..76a35e830 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -214,6 +214,13 @@ {% endfor %} {% endif %} + {% if c.post %} + {% set sub = c.post.sub %} + {% if sub and c.author.exiled_from(sub) %} + + {% endif %} + {% endif %} + {% if c.bannedfor %} {% endif %} @@ -490,7 +497,7 @@ Context - + {% if v %} @@ -571,14 +578,22 @@ {% if v.admin_level > 1 %} {% if "/reported/" in request.path %} - - + + {% else %} - - + + {% endif %} {% endif %} +{% if c.post %} + {% set sub = c.post.sub %} + {% if sub and v.mods(sub) %} + + + {% endif %} +{% endif %} + {% if c.parent_submission and (c.author_id==v.id or v.admin_level > 1) %} @@ -698,7 +713,7 @@ {% if not c.ghost %}

  • Votes
  • {% endif %} - Copy link + Copy link Context @@ -747,6 +762,14 @@ Unpin {% endif %} {% endif %} + + {% if c.post %} + {% set sub = c.post.sub %} + {% if sub and v.mods(sub) %} + Exile user + Unexile user + {% endif %} + {% endif %} {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index f4b8fda8c..df1d53a65 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -7,7 +7,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} {% if sub and sub.css and not request.path.endswith('settings') %} diff --git a/files/templates/log.html b/files/templates/log.html index feac55bcb..a9d988f75 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,7 +6,7 @@ {% block content %} {% if v %} - + {% if v.agendaposter %} - + {% endif %}
    diff --git a/files/templates/login.html b/files/templates/login.html index bc2c6eb9e..229bd46b9 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -18,7 +18,7 @@ {% endblock %} - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index f5f0234a5..3b51a3971 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -14,7 +14,7 @@ 2-Step Login - {{SITE_NAME}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 12639f59d..1d2d1f76b 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -34,7 +34,7 @@ - + {% if v.agendaposter %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 87a6e6d67..19a6fc7ee 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -31,7 +31,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index a8b5ef6c8..6a6f80acb 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -32,7 +32,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %} - + diff --git a/files/templates/submission.html b/files/templates/submission.html index e8e9476b7..aa327a0b9 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -398,7 +398,10 @@ {% endif %} {% if p.sub and v.mods(p.sub) %} - + + + + {% endif %}
    @@ -489,6 +492,10 @@ /s/{{p.sub}}   {% endif %} + {% if p.sub and p.author.exiled_from(p.sub) %} + + {% endif %} + {% if p.bannedfor %} {% endif %} @@ -759,6 +766,10 @@ {% if p.sub and v.mods(p.sub) %} Kick + + Exile user + Unexile user + {% endif %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 783a8af29..dd235724e 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -156,6 +156,10 @@ /s/{{p.sub}}   {% endif %} + {% if p.sub and p.author.exiled_from(p.sub) %} + + {% endif %} + {% if p.bannedfor %} {% endif %} @@ -165,6 +169,7 @@ {% endfor %} {% endif %} + {% if v and v.admin_level > 1 and p.author.shadowbanned %} {% endif %} @@ -297,6 +302,9 @@ {% if p.sub and v.mods(p.sub) %} Kick + + Exile user + Unexile user {% endif %} @@ -455,7 +463,10 @@ {% endif %} {% if p.sub and v.mods(p.sub) %} - + + + + {% endif %} diff --git a/files/templates/submit.html b/files/templates/submit.html index 194376f67..ceac83b73 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -26,7 +26,7 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %} - + {% endif %} {% endblock %} @@ -79,7 +79,7 @@ - {% if SITE_NAME == 'Ruqqus' %} + {% if SITE_NAME == 'Ruqqus' or sub %}