diff --git a/Dockerfile b/Dockerfile index c23df2fbe..c9d85b6af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt update RUN apt -y upgrade -RUN apt install -y supervisor +RUN apt install -y supervisor RUN apt install -y python3-pip RUN apt install -y ffmpeg RUN apt install -y postgresql diff --git a/files/assets/css/classic.css b/files/assets/css/classic.css index 190008d0d..feec9907e 100644 --- a/files/assets/css/classic.css +++ b/files/assets/css/classic.css @@ -174,7 +174,7 @@ blockquote { } blockquote a { - color: skyblue; + color: skyblue; } .unread { diff --git a/files/assets/css/dramblr.css b/files/assets/css/dramblr.css index eed53de89..df0b4fd06 100644 --- a/files/assets/css/dramblr.css +++ b/files/assets/css/dramblr.css @@ -106,7 +106,7 @@ blockquote { } .comment-collapse-icon::before { - color: var(--gray-500) !important + color: var(--gray-500) !important } .text-admin { diff --git a/files/assets/css/light.css b/files/assets/css/light.css index 3a70af306..0e1ed0bbd 100644 --- a/files/assets/css/light.css +++ b/files/assets/css/light.css @@ -6,7 +6,7 @@ --secondary: #c7c7c7; --gray: #c7c7c7; --gray-300: #c7c7c7; - --gray-400: #cfcfcf; + --gray-400: #cfcfcf; --gray-500: #ffffff; --gray-600: #ffffff; --gray-700: #ffffff; diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 790071300..4dfdc836a 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -6574,7 +6574,7 @@ body > .container { .emoji2 { /*background: None!important;*/ - width:60px; + width:60px; height: 85px; overflow: hidden; border: none diff --git a/files/assets/css/midnight.css b/files/assets/css/midnight.css index d4f3b416c..c69ebd9e1 100644 --- a/files/assets/css/midnight.css +++ b/files/assets/css/midnight.css @@ -35,7 +35,7 @@ body, .navbar-light, .navbar-dark, .card, .modal-content, .comment-write textare } .modal .comment-actions .list-group-item { - background-color: var(--gray-600)!important; + background-color: var(--gray-600)!important; } .page-link { diff --git a/files/assets/css/offline.css b/files/assets/css/offline.css index ac42e1e10..7bc8aef64 100644 --- a/files/assets/css/offline.css +++ b/files/assets/css/offline.css @@ -33,7 +33,7 @@ h1, h2, h3, h4, h5, h6 { } .button { - background-color: rgb(var(--background))!important; + background-color: rgb(var(--background))!important; background: 0 0; font-weight: 600; font-size: 1rem; diff --git a/files/assets/emojis.json b/files/assets/emojis.json index 4bfe7f8ab..744f636a6 100644 --- a/files/assets/emojis.json +++ b/files/assets/emojis.json @@ -133,7 +133,7 @@ {"name":"oplus", "class":"Marsey Alphabet", "tags": ["⊕","xor","circled","sum"]}, {"name":"otimes", "class":"Marsey Alphabet", "tags": ["⊗","tensor","circled","product"]}, {"name":"trianglelefteq", "class":"Marsey Alphabet", "tags": ["⊴"]}, - + {"name":"marseyflagmaryland","class":"Marsey Flags"}, {"name":"marseyflagcalifornia","class":"Marsey Flags"}, {"name":"marseyflagtexas","class":"Marsey Flags"}, diff --git a/files/assets/fistmas/css/fistmas.css b/files/assets/fistmas/css/fistmas.css index 9bf9a8b51..ddc838692 100644 --- a/files/assets/fistmas/css/fistmas.css +++ b/files/assets/fistmas/css/fistmas.css @@ -213,40 +213,40 @@ body { background-color: #1f1f1f; background-blend-mode: soft-light; } - + .color { width: 20%; height: 100%; float: left } - + .color p { position: relative; z-index: 1231231; text-align: center; line-height: 90vh; } - + .color:nth-child(1){ background-color: #F5624D; } - + .color:nth-child(2){ background-color: #CC231E; } - + .color:nth-child(3){ background-color: #34A65F; } - + .color:nth-child(4){ background-color: #0F8A5F; } - + .color:nth-child(5){ background-color: #235E6F; } - + #snow:not([data-nonce]) { height: 100%; color: #FFF; diff --git a/files/assets/fistmas/js/snow.js b/files/assets/fistmas/js/snow.js index c77d08218..2b9d84e22 100644 --- a/files/assets/fistmas/js/snow.js +++ b/files/assets/fistmas/js/snow.js @@ -13,7 +13,7 @@ function snow(flakesMax) { // --- common properties --- - + this.autoStart = true; // Whether the snow should start automatically or not. this.excludeMobile = false; // Snow is likely to be bad news for mobile phones' CPUs (and batteries.) Enable at your own risk. this.flakesMax = flakesMax; // Limit total amount of snow made (falling + sticking) @@ -32,9 +32,9 @@ function snow(flakesMax) { this.useTwinkleEffect = false; // Allow snow to randomly "flicker" in and out of view while falling this.usePositionFixed = false; // true = snow does not shift vertically when scrolling. May increase CPU load, disabled by default - if enabled, used only where supported this.usePixelPosition = false; // Whether to use pixel values for snow top/left vs. percentages. Auto-enabled if body is position:relative or targetElement is specified. - + // --- less-used bits --- - + this.freezeOnBlur = true; // Only snow when the window is in focus (foreground.) Saves CPU. this.flakeLeftOffset = 0; // Left margin/gutter space on edge of container (eg. browser window.) Bump up these values if seeing horizontal scrollbars. this.flakeRightOffset = 0; // Right margin/gutter space on edge of container @@ -43,9 +43,9 @@ function snow(flakesMax) { this.vMaxX = 5; // Maximum X velocity range for snow this.vMaxY = 4; // Maximum Y velocity range for snow this.zIndex = 0; // CSS stacking order applied to each snowflake - + // --- "No user-serviceable parts inside" past this point, yadda yadda --- - + var storm = this, features, // UA sniffing and backCompat rendering mode checks for fixed position, etc. @@ -76,20 +76,20 @@ function snow(flakesMax) { })(), didInit = false, docFrag = document.createDocumentFragment(); - + features = (function () { var getAnimationFrame; - + /** * hat tip: paul irish * http://paulirish.com/2011/requestanimationframe-for-smart-animating/ * https://gist.github.com/838785 */ - + function timeoutShim(callback) { window.setTimeout(callback, 1000 / (storm.animationInterval || 20)); } - + var _animationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -97,24 +97,24 @@ function snow(flakesMax) { window.oRequestAnimationFrame || window.msRequestAnimationFrame || timeoutShim; - + // apply to window, avoid "illegal invocation" errors in Chrome getAnimationFrame = _animationFrame ? function () { return _animationFrame.apply(window, arguments); } : null; - + var testDiv; - + testDiv = document.createElement("div"); - + function has(prop) { // test for feature support var result = testDiv.style[prop]; return result !== undefined ? prop : null; } - + // note local scope. var localFeatures = { transform: { @@ -125,34 +125,34 @@ function snow(flakesMax) { w3: has("transform"), prop: null // the normalized property value }, - + getAnimationFrame: getAnimationFrame }; - + localFeatures.transform.prop = localFeatures.transform.w3 || localFeatures.transform.moz || localFeatures.transform.webkit || localFeatures.transform.ie || localFeatures.transform.opera; - + testDiv = null; - + return localFeatures; })(); - + this.timer = null; this.flakes = []; this.disabled = false; this.active = false; this.meltFrameCount = 20; this.meltFrames = []; - + this.setXY = function (o, x, y) { if (!o) { return false; } - + if (storm.usePixelPosition || targetElementIsRelative) { o.style.left = x - storm.flakeWidth + "px"; o.style.top = y - storm.flakeHeight + "px"; @@ -172,7 +172,7 @@ function snow(flakesMax) { } } }; - + this.events = (function () { var old = !window.addEventListener && window.attachEvent, slice = Array.prototype.slice, @@ -180,7 +180,7 @@ function snow(flakesMax) { add: old ? "attachEvent" : "addEventListener", remove: old ? "detachEvent" : "removeEventListener" }; - + function getArgs(oArgs) { var args = slice.call(oArgs), len = args.length; @@ -194,7 +194,7 @@ function snow(flakesMax) { } return args; } - + function apply(args, sType) { var element = args.shift(), method = [evt[sType]]; @@ -204,32 +204,32 @@ function snow(flakesMax) { element[method].apply(element, args); } } - + function addEvent() { apply(getArgs(arguments), "add"); } - + function removeEvent() { apply(getArgs(arguments), "remove"); } - + return { add: addEvent, remove: removeEvent }; })(); - + function rnd(n, min) { if (isNaN(min)) { min = 0; } return Math.random() * n + min; } - + function plusMinus(n) { return parseInt(rnd(2), 10) === 1 ? n * -1 : n; } - + this.randomizeWind = function () { var i; vRndX = plusMinus(rnd(storm.vMaxX, 0.2)); @@ -242,7 +242,7 @@ function snow(flakesMax) { } } }; - + this.scrollHandler = function () { var i; // "attach" snowflakes to bottom of window if no absolute bottom value was given @@ -265,7 +265,7 @@ function snow(flakesMax) { } } }; - + this.resizeHandler = function () { if (window.innerWidth || window.innerHeight) { screenX = window.innerWidth - 16 - storm.flakeRightOffset; @@ -286,14 +286,14 @@ function snow(flakesMax) { docHeight = document.body.offsetHeight; screenX2 = parseInt(screenX / 2, 10); }; - + this.resizeHandlerAlt = function () { screenX = storm.targetElement.offsetWidth - storm.flakeRightOffset; screenY = storm.flakeBottom || storm.targetElement.offsetHeight; screenX2 = parseInt(screenX / 2, 10); docHeight = document.body.offsetHeight; }; - + this.freeze = function () { // pause animation if (!storm.disabled) { @@ -303,7 +303,7 @@ function snow(flakesMax) { } storm.timer = null; }; - + this.resume = function () { if (storm.disabled) { storm.disabled = 0; @@ -312,7 +312,7 @@ function snow(flakesMax) { } storm.timerInit(); }; - + this.toggleSnow = function () { if (!storm.flakes.length) { // first run @@ -328,7 +328,7 @@ function snow(flakesMax) { } } }; - + this.stop = function () { var i; this.freeze(); @@ -347,14 +347,14 @@ function snow(flakesMax) { } } }; - + this.show = function () { var i; for (i = 0; i < this.flakes.length; i++) { this.flakes[i].o.style.display = "block"; } }; - + this.SnowFlake = function (type, x, y) { var s = this; this.type = type; @@ -390,7 +390,7 @@ function snow(flakesMax) { this.o.style.fontWeight = "normal"; this.o.style.zIndex = storm.zIndex; docFrag.appendChild(this.o); - + this.refresh = function () { if (isNaN(s.x) || isNaN(s.y)) { // safety check @@ -398,7 +398,7 @@ function snow(flakesMax) { } storm.setXY(s.o, s.x, s.y); }; - + this.stick = function () { if ( noFixed || @@ -415,7 +415,7 @@ function snow(flakesMax) { s.o.style.display = "block"; } }; - + this.vCheck = function () { if (s.vX >= 0 && s.vX < 0.2) { s.vX = 0.2; @@ -426,7 +426,7 @@ function snow(flakesMax) { s.vY = 0.2; } }; - + this.move = function () { var vX = s.vX * windOffset, yDiff; @@ -481,25 +481,25 @@ function snow(flakesMax) { } } }; - + this.animate = function () { // main animation loop // move, check status, die etc. s.move(); }; - + this.setVelocities = function () { s.vX = vRndX + rnd(storm.vMaxX * 0.12, 0.1); s.vY = vRndY + rnd(storm.vMaxY * 0.12, 0.1); }; - + this.setOpacity = function (o, opacity) { if (!opacitySupported) { return false; } o.style.opacity = opacity; }; - + this.melt = function () { if (!storm.useMeltEffect || !s.melting) { s.recycle(); @@ -519,7 +519,7 @@ function snow(flakesMax) { } } }; - + this.recycle = function () { s.o.style.display = "none"; s.o.style.position = fixedForEverything ? "fixed" : "absolute"; @@ -541,11 +541,11 @@ function snow(flakesMax) { s.o.style.display = "block"; s.active = 1; }; - + this.recycle(); // set up x/y coords etc. this.refresh(); }; - + this.snow = function () { var active = 0, flake = null, @@ -570,7 +570,7 @@ function snow(flakesMax) { features.getAnimationFrame(storm.snow); } }; - + this.mouseMove = function (e) { if (!storm.followMouse) { return true; @@ -583,7 +583,7 @@ function snow(flakesMax) { windOffset = (x / screenX2) * windMultiplier; } }; - + this.createSnow = function (limit, allowInactive) { var i; for (i = 0; i < limit; i++) { @@ -596,12 +596,12 @@ function snow(flakesMax) { } storm.targetElement.appendChild(docFrag); }; - + this.timerInit = function () { storm.timer = true; storm.snow(); }; - + this.init = function () { var i; for (i = 0; i < storm.meltFrameCount; i++) { @@ -628,7 +628,7 @@ function snow(flakesMax) { storm.animationInterval = Math.max(20, storm.animationInterval); storm.timerInit(); }; - + this.start = function (bFromOnLoad) { if (!didInit) { didInit = true; @@ -678,7 +678,7 @@ function snow(flakesMax) { storm.active = true; } }; - + function doDelayedStart() { window.setTimeout(function () { storm.start(true); @@ -686,7 +686,7 @@ function snow(flakesMax) { // event cleanup storm.events.remove(isIE ? document : window, "mousemove", doDelayedStart); } - + function doStart() { if (!storm.excludeMobile || !isMobile) { doDelayedStart(); @@ -694,12 +694,12 @@ function snow(flakesMax) { // event cleanup storm.events.remove(window, "load", doStart); } - + // hooks for starting the snow if (storm.autoStart) { storm.events.add(window, "load", doStart, false); } - + return this; } diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index b8890c181..e6329bd9e 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -86,7 +86,7 @@ function vote(type, id, dir) { } } } - + const xhr = createXhrWithFormKey("/vote/" + type.replace('-mobile','') + "/" + id + "/" + votedirection); xhr[0].send(xhr[1]); } @@ -144,7 +144,7 @@ function buy(mb) { document.getElementById('giveaward').disabled=false; let owned = document.getElementById(`${kind}-owned`) let ownednum = Number(owned.textContent) + 1; - owned.textContent = ownednum + owned.textContent = ownednum } } }; @@ -166,7 +166,7 @@ function giveaward(t) { owned.textContent = ownednum if (ownednum == 0) document.getElementById('giveaward').disabled=true; - } + } ); } diff --git a/files/assets/js/casino/roulette_screen.js b/files/assets/js/casino/roulette_screen.js index c419acb98..e8d1cea8d 100644 --- a/files/assets/js/casino/roulette_screen.js +++ b/files/assets/js/casino/roulette_screen.js @@ -108,7 +108,7 @@ function buildRouletteTable() { for (let i = 25; i < 37; i++) { const correctNumber = CELL_TO_NUMBER_LOOKUP[i]; const isRed = reds.includes(correctNumber); - + html += `
`; const { participants, coin, marseybux } = flatBets.reduce((prev, next) => { diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index f6cf78ed5..815c74d68 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -98,7 +98,7 @@ function delete_commentModal(t, id) { document.getElementById("comment-"+id).remove() } else - { + { document.getElementsByClassName(`comment-${id}-only`)[0].classList.add('deleted'); document.getElementById(`delete-${id}`).classList.add('d-none'); document.getElementById(`undelete-${id}`).classList.remove('d-none'); @@ -123,7 +123,7 @@ function post_reply(id){ form.append('file', e); } catch(e) {} - + const xhr = createXhrWithFormKey("/reply", "POST", form); xhr[0].onload=function(){ let data diff --git a/files/assets/js/core.js b/files/assets/js/core.js index e9b30ff54..95f7569ef 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -63,7 +63,7 @@ function postToast(t, url, data, extraActionsOnSuccess, method="POST") { showToast(success, message); if (!isShopConfirm) { t.disabled = false; - t.classList.remove("disabled"); + t.classList.remove("disabled"); } return success; }; diff --git a/files/assets/js/fart.js b/files/assets/js/fart.js index 57e2dc529..649fc753f 100644 --- a/files/assets/js/fart.js +++ b/files/assets/js/fart.js @@ -4,6 +4,6 @@ let audio = new Audio(`/assets/images/${fart}.webp`); audio.play(); if (audio.paused) { document.addEventListener('click', () => { - if (audio.paused) audio.play(); + if (audio.paused) audio.play(); }, {once : true}) } diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index c12e5ff54..da5bd6267 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -43,7 +43,7 @@ async function getGifs(form) { noGIFs.innerHTML = null; loadGIFs.innerHTML = null; - container.innerHTML = ` + container.innerHTML = `
Agree
diff --git a/files/assets/js/register_service_worker.js b/files/assets/js/register_service_worker.js index 9b5605a66..95db4c377 100644 --- a/files/assets/js/register_service_worker.js +++ b/files/assets/js/register_service_worker.js @@ -65,7 +65,7 @@ function registerServiceWorker(serviceWorkerUrl, applicationServerPublicKey, api .catch(function() { }); } else { - } + } return swRegistration; } diff --git a/files/assets/js/service_worker.js b/files/assets/js/service_worker.js index 347e21deb..7e9464904 100644 --- a/files/assets/js/service_worker.js +++ b/files/assets/js/service_worker.js @@ -75,4 +75,4 @@ self.addEventListener('notificationclick', (e) => { const hadWindowToFocus = clientsArr.some((windowClient) => windowClient.url === e.notification.data.url ? (windowClient.focus(), true) : false); if (!hadWindowToFocus) clients.openWindow(e.notification.data.url).then((windowClient) => windowClient ? windowClient.focus() : null); })); -}); +}); diff --git a/files/assets/js/settings_profile.js b/files/assets/js/settings_profile.js index 27337ce48..f538f605f 100644 --- a/files/assets/js/settings_profile.js +++ b/files/assets/js/settings_profile.js @@ -13,7 +13,7 @@ function updatebgselection(){ const backgrounds = [ { folder: "glitter", - backgrounds: + backgrounds: [ "1.webp", "2.webp", @@ -109,7 +109,7 @@ document.onpaste = function(event) { alert("You can't upload more than 4 files at one time!") return } - + if (files.length) { f=document.getElementById('file-upload'); diff --git a/files/assets/js/settings_security.js b/files/assets/js/settings_security.js index 831c846f1..b1ac74589 100644 --- a/files/assets/js/settings_security.js +++ b/files/assets/js/settings_security.js @@ -38,7 +38,7 @@ function unblock_user(t, url) { }, () => { t.parentElement.parentElement.remove(); - } + } ); } diff --git a/files/assets/js/submission.js b/files/assets/js/submission.js index 6195e1a8d..79714ae8d 100644 --- a/files/assets/js/submission.js +++ b/files/assets/js/submission.js @@ -12,12 +12,12 @@ function highlight_unread(localstoragevar) { catch(e) {} } } - } + } } highlight_unread("comment-counts") -if (!location.href.includes("?context")) { +if (!location.href.includes("?context")) { localStorage.setItem("old-comment-counts", localStorage.getItem("comment-counts")) const comments = JSON.parse(localStorage.getItem("comment-counts")) || {} diff --git a/files/classes/badges.py b/files/classes/badges.py index 5719a7c19..8cc92f227 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -82,7 +82,7 @@ class Badge(Base): text = self.badge.description else: return self.name - + return f'{self.name} - {text}' @property diff --git a/files/classes/comment.py b/files/classes/comment.py index aeb6afb8a..153a60e2b 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -285,7 +285,7 @@ class Comment(Base): body += f''' data-nonce="{{g.nonce}}" data-onclick="poll_vote_no_v()"''' body += f'''>
''' if not self.ghost and self.author.show_sig(v): @@ -322,15 +322,15 @@ class Comment(Base): if self.author.shadowbanned and not (v and v.shadowbanned): return True if (self.wordle_result) and (not self.body or len(self.body_html) <= 100) and 9 > self.level > 1: return True - + if v and v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True - + return False @property @lazy def is_op(self): return self.author_id==self.post.author_id - + @lazy def filtered_flags(self, v): return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned] @@ -356,7 +356,7 @@ class Comment(Base): body += "Correct!" elif wordle_status == 'lost': body += f"Lost. The answer was: {wordle_answer}" - + body += '' return body diff --git a/files/classes/leaderboard.py b/files/classes/leaderboard.py index b948ff479..a5ae36db4 100644 --- a/files/classes/leaderboard.py +++ b/files/classes/leaderboard.py @@ -22,8 +22,8 @@ class Leaderboard: user_func = None value_func = None - def __init__(self, header_name:str, table_header_name:str, html_id:str, table_column_name:str, - user_relative_url:Optional[str], query_function:Callable[..., Tuple[Any, Any, Any]], + def __init__(self, header_name:str, table_header_name:str, html_id:str, table_column_name:str, + user_relative_url:Optional[str], query_function:Callable[..., Tuple[Any, Any, Any]], criteria, v:User, value_func:Optional[Callable[[User], Union[int, Column]]], db:scoped_session, users, limit=LEADERBOARD_LIMIT): self.header_name = header_name self.table_header_name = table_header_name @@ -52,11 +52,11 @@ class Leaderboard: sq = db.query(User.id, func.rank().over(order_by=order_by.desc()).label("rank")).subquery() position = db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1] return (leaderboard, position, None) - + @classmethod def count_and_label(cls, criteria): return func.count(criteria).label("count") - + @classmethod def rank_filtered_rank_label_by_desc(cls, criteria): return func.rank().over(order_by=func.count(criteria).desc()).label("rank") @@ -71,27 +71,27 @@ class Leaderboard: sq_criteria = User.id == sq.c.author_id else: raise ValueError("This leaderboard function only supports Badge.user_id and Marsey.author_id") - + leaderboard = db.query(User, sq.c.count).join(sq, sq_criteria).order_by(sq.c.count.desc()) position = db.query(User.id, sq.c.rank, sq.c.count).join(sq, sq_criteria).filter(User.id == v.id).one_or_none() if position: position = (position[1], position[2]) else: position = (leaderboard.count() + 1, 0) leaderboard = leaderboard.limit(limit).all() return (leaderboard, position[0], position[1]) - + @classmethod def get_blockers_lb(cls, lb_criteria, v:User, db:scoped_session, users:Any, limit): if lb_criteria != UserBlock.target_id: raise ValueError("This leaderboard function only supports UserBlock.target_id") sq = db.query(lb_criteria, cls.count_and_label(lb_criteria)).group_by(lb_criteria).subquery() leaderboard = db.query(User, sq.c.count).join(User, User.id == sq.c.target_id).order_by(sq.c.count.desc()) - + sq = db.query(lb_criteria, cls.count_and_label(lb_criteria), cls.rank_filtered_rank_label_by_desc(lb_criteria)).group_by(lb_criteria).subquery() position = db.query(sq.c.rank, sq.c.count).join(User, User.id == sq.c.target_id).filter(sq.c.target_id == v.id).limit(1).one_or_none() if not position: position = (leaderboard.count() + 1, 0) leaderboard = leaderboard.limit(limit).all() return (leaderboard, position[0], position[1]) - + @classmethod def get_hat_lb(cls, lb_criteria, v:User, db:scoped_session, users:Any, limit): leaderboard = db.query(User, func.count(lb_criteria)).join(lb_criteria).group_by(User).order_by(func.count(lb_criteria).desc()) diff --git a/files/classes/sub_relationship.py b/files/classes/sub_relationship.py index 942cca845..4a0dd427d 100644 --- a/files/classes/sub_relationship.py +++ b/files/classes/sub_relationship.py @@ -13,7 +13,7 @@ class SubRelationship(Base): @declared_attr def user_id(self): return Column(Integer, ForeignKey("users.id"), primary_key=True) - + @declared_attr def sub(self): return Column(String(20), ForeignKey("subs.name"), primary_key=True) @@ -28,7 +28,7 @@ class SubRelationship(Base): def __repr__(self): return f"<{self.__class__.__name__}(user_id={self.user_id}, sub={self.sub})>" - + class SubJoin(SubRelationship): __tablename__ = "sub_joins" diff --git a/files/classes/submission.py b/files/classes/submission.py index 9f8281cae..49e3d5d90 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -145,14 +145,14 @@ class Submission(Base): @property @lazy def is_youtube(self): - return self.domain == "youtube.com" and self.embed_url and self.embed_url.startswith('= PERMS['POST_BETS_DISTRIBUTE']: body += f'''''' body += "
" @@ -314,7 +314,7 @@ class Submission(Base): body += f''' data-nonce="{{g.nonce}}" data-onclick="poll_vote_no_v()"''' body += f'''>''' diff --git a/files/classes/user.py b/files/classes/user.py index 6ce3591c3..01e94aa6a 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -204,7 +204,7 @@ class User(Base): g.db.query(User).filter(User.id == self.id).update({ User.marseybux: User.marseybux + amount }) g.db.flush() - + def charge_account(self, currency, amount, **kwargs): in_db = g.db.query(User).filter(User.id == self.id).with_for_update().one() @@ -214,19 +214,19 @@ class User(Base): if currency == 'coins': account_balance = in_db.coins - + if not should_check_balance or account_balance >= amount: g.db.query(User).filter(User.id == self.id).update({ User.coins: User.coins - amount }) succeeded = True elif currency == 'marseybux': account_balance = in_db.marseybux - + if not should_check_balance or account_balance >= amount: g.db.query(User).filter(User.id == self.id).update({ User.marseybux: User.marseybux - amount }) succeeded = True if succeeded: g.db.flush() - + return succeeded @property @@ -417,7 +417,7 @@ class User(Base): if badge in owned_badges: discount -= discounts[badge] return discount - + @property @lazy def can_view_offsitementions(self): @@ -586,14 +586,14 @@ class User(Base): Notification.user_id == self.id, not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)), )) - + if not self.can_see_shadowbanned: notifs = notifs.filter( User.shadowbanned == None, Comment.is_banned == False, Comment.deleted_utc == 0, ) - + return notifs.count() + self.post_notifications_count + self.modaction_notifications_count + self.reddit_notifications_count @property @@ -603,7 +603,7 @@ class User(Base): - self.message_notifications_count \ - self.post_notifications_count \ - self.modaction_notifications_count \ - - self.reddit_notifications_count + - self.reddit_notifications_count @property @lazy @@ -659,7 +659,7 @@ class User(Base): SubAction.user_id != self.id, SubAction.sub.in_(self.moderated_subs), ).count() - + return 0 @@ -669,8 +669,8 @@ class User(Base): if not self.can_view_offsitementions or self.id == AEVANN_ID: return 0 return g.db.query(Comment).filter( Comment.created_utc > self.last_viewed_reddit_notifs, - Comment.is_banned == False, Comment.deleted_utc == 0, - Comment.body_html.like('%

New site mention% bool: if not self.is_private: return True @@ -752,7 +752,7 @@ class User(Base): return f"{SITE_FULL}/e/chudsey.webp" if self.rainbow: return f"{SITE_FULL}/e/marseysalutepride.webp" - if self.profileurl: + if self.profileurl: if self.profileurl.startswith('/'): return SITE_FULL + self.profileurl return self.profileurl return f"{SITE_FULL}/i/default-profile-pic.webp?v=1008" @@ -927,7 +927,7 @@ class User(Base): if self.patron == 6: return 'Contributed at least $200' return '' - + @classmethod def can_see_content(cls, user:Optional["User"], other:Union[Submission, Comment, Sub]) -> bool: ''' diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 2c10e2ad5..8ded713b8 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -35,7 +35,7 @@ def _archiveorg(url): except: pass -def archive_url(url): +def archive_url(url): gevent.spawn(_archiveorg, url) if url.startswith('https://twitter.com/'): url = url.replace('https://twitter.com/', 'https://nitter.lacontrevoie.fr/') @@ -64,7 +64,7 @@ def execute_snappy(post:Submission, v:User): if SNAPPY_MARSEYS and SNAPPY_QUOTES: if IS_FISTMAS() or random.random() > 0.5: SNAPPY_CHOICES = SNAPPY_QUOTES - else: + else: SNAPPY_CHOICES = SNAPPY_MARSEYS elif SNAPPY_MARSEYS: SNAPPY_CHOICES = SNAPPY_MARSEYS elif SNAPPY_QUOTES: SNAPPY_CHOICES = SNAPPY_QUOTES @@ -350,7 +350,7 @@ def execute_blackjack_custom(v, target, body, type): def execute_blackjack(v, target, body, type): if not execute_blackjack_custom(v, target, body, type): return False - + if not body: return True execute = False @@ -510,8 +510,8 @@ def execute_lawlz_actions(v:User, p:Submission): g.db.add(ma_2) g.db.add(ma_3) -def process_poll_options(target:Union[Submission, Comment], - cls:Union[Type[SubmissionOption], Type[CommentOption]], +def process_poll_options(target:Union[Submission, Comment], + cls:Union[Type[SubmissionOption], Type[CommentOption]], options:Iterable[str], exclusive:int, friendly_name:str, db:scoped_session) -> None: for option in options: diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 7cb4145cf..7feffbe68 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -66,7 +66,7 @@ def notif_comment2(p): search_html = f'% has mentioned you: %' existing = g.db.query(Comment.id).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like(search_html)).first() - + if existing: return existing[0] else: text = f"@{p.author.username} has mentioned you: [{p.title}](/post/{p.id})" diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 01e9f0dfa..ebb457bad 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -85,7 +85,7 @@ CASINO_RELEASE_DAY = 1662825600 AJ_REPLACEMENTS = { ' your ': " you're ", - ' to ': " too ", + ' to ': " too ", ' Your ': " You're ", ' To ': " Too ", @@ -986,7 +986,7 @@ forced_hats = { "earlylife": ("The Merchant", "SHUT IT DOWN, the goys know!"), "marsify": ("Marsified", "I can't pick my own Marseys, help!"), "is_suspended": ("Behind Bars", "This user is banned and needs to do better!"), - "agendaposter": (("Egg_irl", "This user is getting in touch with xir identity!"), + "agendaposter": (("Egg_irl", "This user is getting in touch with xir identity!"), ("Trans Flag", "Just in case you forgot, trans lives matter."), ("Trans Flag II", "Your egg is cracked; wear it with pride!"), ("Pride Flag", "Never forget that this is a primarily gay community. Dude bussy lmao."), diff --git a/files/helpers/config/modaction_types.py b/files/helpers/config/modaction_types.py index a0a9d823e..98c5746ee 100644 --- a/files/helpers/config/modaction_types.py +++ b/files/helpers/config/modaction_types.py @@ -2,78 +2,78 @@ from copy import deepcopy MODACTION_TYPES = { 'chud': { - "str": 'chudded {self.target_link}', - "icon": 'fa-snooze', + "str": 'chudded {self.target_link}', + "icon": 'fa-snooze', "color": 'bg-danger' }, 'approve_app': { - "str": 'approved an application by {self.target_link}', - "icon": 'fa-robot', + "str": 'approved an application by {self.target_link}', + "icon": 'fa-robot', "color": 'bg-success' }, 'badge_grant': { - "str": 'granted badge to {self.target_link}', - "icon": 'fa-badge', + "str": 'granted badge to {self.target_link}', + "icon": 'fa-badge', "color": 'bg-success' }, 'badge_remove': { - "str": 'removed badge from {self.target_link}', - "icon": 'fa-badge', + "str": 'removed badge from {self.target_link}', + "icon": 'fa-badge', "color": 'bg-danger' }, 'ban_comment': { - "str": 'removed {self.target_link}', - "icon": 'fa-comment', + "str": 'removed {self.target_link}', + "icon": 'fa-comment', "color": 'bg-danger' }, 'ban_domain': { - "str": 'banned a domain', - "icon": 'fa-globe', + "str": 'banned a domain', + "icon": 'fa-globe', "color": 'bg-danger' }, 'ban_post': { - "str": 'removed post {self.target_link}', - "icon": 'fa-feather-alt', + "str": 'removed post {self.target_link}', + "icon": 'fa-feather-alt', "color": 'bg-danger' }, 'ban_user': { - "str": 'banned user {self.target_link}', - "icon": 'fa-user-slash', + "str": 'banned user {self.target_link}', + "icon": 'fa-user-slash', "color": 'bg-danger' }, 'delete_report': { - "str": 'deleted report on {self.target_link}', - "icon": 'fa-flag', + "str": 'deleted report on {self.target_link}', + "icon": 'fa-flag', "color": 'bg-danger' }, 'disable_bots': { - "str": 'disabled bots', - "icon": 'fa-robot', + "str": 'disabled bots', + "icon": 'fa-robot', "color": 'bg-danger' }, 'disable_fart_mode': { - "str": 'disabled fart mode', - "icon": 'fa-gas-pump-slash', + "str": 'disabled fart mode', + "icon": 'fa-gas-pump-slash', "color": 'bg-danger' }, 'disable_read_only_mode': { - "str": 'disabled read only mode', - "icon": 'fa-book', + "str": 'disabled read only mode', + "icon": 'fa-book', "color": 'bg-danger' }, 'disable_signups': { - "str": 'disabled signups', - "icon": 'fa-users', + "str": 'disabled signups', + "icon": 'fa-users', "color": 'bg-danger' }, 'disable_login_required': { - "str": 'disabled login required', - "icon": 'fa-users', + "str": 'disabled login required', + "icon": 'fa-users', "color": 'bg-danger' }, 'disable_under_attack': { - "str": 'disabled under attack mode', - "icon": 'fa-shield', + "str": 'disabled under attack mode', + "icon": 'fa-shield', "color": 'bg-muted' }, 'disable_under_siege': { @@ -82,58 +82,58 @@ MODACTION_TYPES = { "color": 'bg-muted' }, 'distinguish_comment': { - "str": 'distinguished {self.target_link}', - "icon": 'fa-crown', + "str": 'distinguished {self.target_link}', + "icon": 'fa-crown', "color": 'bg-success' }, 'distinguish_post': { - "str": 'distinguished {self.target_link}', - "icon": 'fa-crown', + "str": 'distinguished {self.target_link}', + "icon": 'fa-crown', "color": 'bg-success' }, 'distribute': { - "str": 'distributed bet winnings to voters on {self.target_link}', - "icon": 'fa-dollar-sign', + "str": 'distributed bet winnings to voters on {self.target_link}', + "icon": 'fa-dollar-sign', "color": 'bg-success' }, 'edit_post': { - "str": 'edited {self.target_link}', - "icon": 'fa-edit', + "str": 'edited {self.target_link}', + "icon": 'fa-edit', "color": 'bg-primary' }, 'edit_rules': { - "str": 'edited the rules', - "icon": 'fa-columns', + "str": 'edited the rules', + "icon": 'fa-columns', "color": 'bg-primary' }, 'enable_bots': { - "str": 'enabled bots', - "icon": 'fa-robot', + "str": 'enabled bots', + "icon": 'fa-robot', "color": 'bg-success' }, 'enable_fart_mode': { - "str": 'enabled fart mode', - "icon": 'fa-gas-pump', + "str": 'enabled fart mode', + "icon": 'fa-gas-pump', "color": 'bg-success' }, 'enable_read_only_mode': { - "str": 'enabled read only mode', - "icon": 'fa-book', + "str": 'enabled read only mode', + "icon": 'fa-book', "color": 'bg-success' }, 'enable_signups': { - "str": 'enabled signups', - "icon": 'fa-users', + "str": 'enabled signups', + "icon": 'fa-users', "color": 'bg-success' }, 'enable_login_required': { - "str": 'enabled login required', - "icon": 'fa-users', + "str": 'enabled login required', + "icon": 'fa-users', "color": 'bg-success' }, 'enable_under_attack': { - "str": 'enabled under attack mode', - "icon": 'fa-shield', + "str": 'enabled under attack mode', + "icon": 'fa-shield', "color": 'bg-success' }, 'enable_under_siege': { @@ -142,13 +142,13 @@ MODACTION_TYPES = { "color": 'bg-success', }, 'flair_post': { - "str": 'set a flair on {self.target_link}', - "icon": 'fa-tag', + "str": 'set a flair on {self.target_link}', + "icon": 'fa-tag', "color": 'bg-primary' }, 'link_accounts': { - "str": 'linked {self.target_link}', - "icon": 'fa-link', + "str": 'linked {self.target_link}', + "icon": 'fa-link', "color": 'bg-success' }, 'delink_accounts': { @@ -157,8 +157,8 @@ MODACTION_TYPES = { "color": 'bg-danger' }, 'make_admin': { - "str": 'made {self.target_link} an admin', - "icon": 'fa-user-crown', + "str": 'made {self.target_link} an admin', + "icon": 'fa-user-crown', "color": 'bg-success' }, 'mod_mute_user': { @@ -172,169 +172,169 @@ MODACTION_TYPES = { "color": 'bg-success' }, 'monthly': { - "str": 'distributed monthly marseybux', - "icon": 'fa-sack-dollar', + "str": 'distributed monthly marseybux', + "icon": 'fa-sack-dollar', "color": 'bg-success' }, 'move_hole': { - "str": 'changed hole of {self.target_link}', - "icon": 'fa-manhole', + "str": 'changed hole of {self.target_link}', + "icon": 'fa-manhole', "color": 'bg-primary' }, 'nuke_user': { - "str": 'removed all content of {self.target_link}', - "icon": 'fa-radiation-alt', + "str": 'removed all content of {self.target_link}', + "icon": 'fa-radiation-alt', "color": 'bg-danger' }, 'pin_comment': { - "str": 'pinned {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'pinned {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, 'pin_post': { - "str": 'pinned post {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'pinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, 'clear_cloudflare_cache': { - "str": 'cleared cloudflare cache', + "str": 'cleared cloudflare cache', "icon": 'fab fa-cloudflare', "color": 'bg-muted' }, 'reject_app': { - "str": 'rejected an application request by {self.target_link}', - "icon": 'fa-robot', + "str": 'rejected an application request by {self.target_link}', + "icon": 'fa-robot', "color": 'bg-muted' }, 'remove_admin': { - "str": 'removed {self.target_link} as admin', - "icon": 'fa-user-crown', + "str": 'removed {self.target_link} as admin', + "icon": 'fa-user-crown', "color": 'bg-danger' }, 'revert': { - "str": 'reverted {self.target_link} mod actions', - "icon": 'fa-history', + "str": 'reverted {self.target_link} mod actions', + "icon": 'fa-history', "color": 'bg-danger' }, 'revoke_app': { - "str": 'revoked an application by {self.target_link}', - "icon": 'fa-robot', + "str": 'revoked an application by {self.target_link}', + "icon": 'fa-robot', "color": 'bg-muted' }, 'set_flair_locked': { - "str": "set {self.target_link}'s flair (locked)", - "icon": 'fa-award', + "str": "set {self.target_link}'s flair (locked)", + "icon": 'fa-award', "color": 'bg-primary' }, 'set_flair_notlocked': { - "str": "set {self.target_link}'s flair (not locked)", - "icon": 'fa-award', + "str": "set {self.target_link}'s flair (not locked)", + "icon": 'fa-award', "color": 'bg-primary' }, 'set_new': { - "str": 'changed the default sorting of comments on {self.target_link} to `new`', - "icon": 'fa-sparkles', + "str": 'changed the default sorting of comments on {self.target_link} to `new`', + "icon": 'fa-sparkles', "color": 'bg-primary' }, 'set_hot': { - "str": 'changed the default sorting of comments on {self.target_link} to `hot`', - "icon": 'fa-fire', + "str": 'changed the default sorting of comments on {self.target_link} to `hot`', + "icon": 'fa-fire', "color": 'bg-primary' }, 'set_nsfw': { - "str": 'set {self.target_link} as +18', - "icon": 'fa-eye-evil', + "str": 'set {self.target_link} as +18', + "icon": 'fa-eye-evil', "color": 'bg-danger' }, 'set_nsfw_comment': { - "str": 'set {self.target_link} as +18', - "icon": 'fa-eye-evil', + "str": 'set {self.target_link} as +18', + "icon": 'fa-eye-evil', "color": 'bg-danger' }, 'shadowban': { - "str": 'shadowbanned {self.target_link}', - "icon": 'fa-eye-slash', + "str": 'shadowbanned {self.target_link}', + "icon": 'fa-eye-slash', "color": 'bg-danger' }, 'unchud': { - "str": 'unchudded {self.target_link}', - "icon": 'fa-snooze', + "str": 'unchudded {self.target_link}', + "icon": 'fa-snooze', "color": 'bg-success' }, 'unban_comment': { - "str": 'reinstated {self.target_link}', - "icon": 'fa-comment', + "str": 'reinstated {self.target_link}', + "icon": 'fa-comment', "color": 'bg-success' }, 'unban_domain': { - "str": 'unbanned a domain', - "icon": 'fa-globe', + "str": 'unbanned a domain', + "icon": 'fa-globe', "color": 'bg-success' }, 'unban_post': { - "str": 'reinstated post {self.target_link}', - "icon": 'fa-feather-alt', + "str": 'reinstated post {self.target_link}', + "icon": 'fa-feather-alt', "color": 'bg-success' }, 'unban_user': { - "str": 'unbanned user {self.target_link}', - "icon": 'fa-user', + "str": 'unbanned user {self.target_link}', + "icon": 'fa-user', "color": 'bg-success' }, 'undistinguish_comment': { - "str": 'un-distinguished {self.target_link}', - "icon": 'fa-crown', + "str": 'un-distinguished {self.target_link}', + "icon": 'fa-crown', "color": 'bg-muted' }, 'undistinguish_post': { - "str": 'un-distinguished {self.target_link}', - "icon": 'fa-crown', + "str": 'un-distinguished {self.target_link}', + "icon": 'fa-crown', "color": 'bg-muted' }, 'unnuke_user': { - "str": 'approved all content of {self.target_link}', - "icon": 'fa-radiation-alt', + "str": 'approved all content of {self.target_link}', + "icon": 'fa-radiation-alt', "color": 'bg-success' }, 'unpin_comment': { - "str": 'unpinned {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'unpinned {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-muted' }, 'unpin_post': { - "str": 'unpinned post {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'unpinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-muted' }, 'unset_nsfw': { - "str": 'unset {self.target_link} as +18', - "icon": 'fa-eye-evil', + "str": 'unset {self.target_link} as +18', + "icon": 'fa-eye-evil', "color": 'bg-success' }, 'unset_nsfw_comment': { - "str": 'unset {self.target_link} as +18', - "icon": 'fa-eye-evil', + "str": 'unset {self.target_link} as +18', + "icon": 'fa-eye-evil', "color": 'bg-success' }, 'unshadowban': { - "str": 'unshadowbanned {self.target_link}', - "icon": 'fa-eye', + "str": 'unshadowbanned {self.target_link}', + "icon": 'fa-eye', "color": 'bg-success' }, 'update_hat': { - "str": 'updated hat image', - "icon": 'fa-hat-cowboy', + "str": 'updated hat image', + "icon": 'fa-hat-cowboy', "color": 'bg-success' }, 'update_marsey': { - "str": 'updated marsey', - "icon": 'fa-cat', + "str": 'updated marsey', + "icon": 'fa-cat', "color": 'bg-success' }, } -MODACTION_PRIVILEGED_TYPES = {'shadowban', 'unshadowban', +MODACTION_PRIVILEGED_TYPES = {'shadowban', 'unshadowban', 'mod_mute_user', 'mod_unmute_user', 'link_accounts', 'delink_accounts'} -MODACTION_TYPES_FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items() +MODACTION_TYPES_FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items() if not t in MODACTION_PRIVILEGED_TYPES}) diff --git a/files/helpers/config/subaction_types.py b/files/helpers/config/subaction_types.py index 6f8061e40..3a5d5f95d 100644 --- a/files/helpers/config/subaction_types.py +++ b/files/helpers/config/subaction_types.py @@ -1,52 +1,52 @@ SUBACTION_TYPES = { 'exile_user': { - "str": 'exiled user {self.target_link}', - "icon": 'fa-user-slash', + "str": 'exiled user {self.target_link}', + "icon": 'fa-user-slash', "color": 'bg-danger' }, 'unexile_user': { - "str": 'unexiled user {self.target_link}', - "icon": 'fa-user', + "str": 'unexiled user {self.target_link}', + "icon": 'fa-user', "color": 'bg-success' }, 'make_mod': { - "str": 'made {self.target_link} a mod', - "icon": 'fa-user-crown', + "str": 'made {self.target_link} a mod', + "icon": 'fa-user-crown', "color": 'bg-success' }, 'remove_mod': { - "str": 'removed {self.target_link} as mod', - "icon": 'fa-user-crown', + "str": 'removed {self.target_link} as mod', + "icon": 'fa-user-crown', "color": 'bg-danger' }, 'kick_post': { - "str": 'kicked post {self.target_link}', - "icon": 'fa-feather-alt', + "str": 'kicked post {self.target_link}', + "icon": 'fa-feather-alt', "color": 'bg-danger' }, 'move_chudrama': { - "str": 'moved post {self.target_link} to /h/chudrama', - "icon": 'fa-feather-alt', + "str": 'moved post {self.target_link} to /h/chudrama', + "icon": 'fa-feather-alt', "color": 'bg-danger' }, 'flair_post': { - "str": 'set a flair on {self.target_link}', - "icon": 'fa-tag', + "str": 'set a flair on {self.target_link}', + "icon": 'fa-tag', "color": 'bg-primary' }, 'edit_sidebar': { - "str": 'edited the sidebar', - "icon": 'fa-columns', + "str": 'edited the sidebar', + "icon": 'fa-columns', "color": 'bg-primary' }, 'edit_css': { - "str": 'edited the css', - "icon": 'fa-css3-alt', + "str": 'edited the css', + "icon": 'fa-css3-alt', "color": 'bg-primary' }, 'upload_banner': { - "str": 'uploaded a banner', - "icon": 'fa-landscape', + "str": 'uploaded a banner', + "icon": 'fa-landscape', "color": 'bg-primary' }, 'delete_banner': { @@ -55,63 +55,63 @@ SUBACTION_TYPES = { "color": 'bg-danger', }, 'change_sidebar_image': { - "str": 'changed the sidebar image', - "icon": 'fa-image', + "str": 'changed the sidebar image', + "icon": 'fa-image', "color": 'bg-primary' }, 'change_marsey': { - "str": 'changed the hole marsey', - "icon": 'fa-cat', + "str": 'changed the hole marsey', + "icon": 'fa-cat', "color": 'bg-primary' }, 'pin_post': { - "str": 'pinned post {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'pinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, 'unpin_post': { - "str": 'unpinned post {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'unpinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-muted' }, 'pin_comment': { - "str": 'pinned {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'pinned {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, 'unpin_comment': { - "str": 'unpinned {self.target_link}', - "icon": 'fa-thumbtack fa-rotate--45', + "str": 'unpinned {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-muted' }, 'enable_stealth': { - "str": 'enabled stealth mode', - "icon": 'fa-user-ninja', + "str": 'enabled stealth mode', + "icon": 'fa-user-ninja', "color": 'bg-primary' }, 'disable_stealth': { - "str": 'disabled stealth mode', - "icon": 'fa-user-ninja', + "str": 'disabled stealth mode', + "icon": 'fa-user-ninja', "color": 'bg-muted' }, 'set_nsfw': { - "str": 'set nsfw on post {self.target_link}', - "icon": 'fa-eye-evil', + "str": 'set nsfw on post {self.target_link}', + "icon": 'fa-eye-evil', "color": 'bg-danger' }, 'unset_nsfw': { - "str": 'un-set nsfw on post {self.target_link}', - "icon": 'fa-eye-evil', + "str": 'un-set nsfw on post {self.target_link}', + "icon": 'fa-eye-evil', "color": 'bg-success' }, 'set_nsfw_comment': { - "str": 'set nsfw on a {self.target_link}', - "icon": 'fa-eye-evil', + "str": 'set nsfw on a {self.target_link}', + "icon": 'fa-eye-evil', "color": 'bg-danger' }, 'unset_nsfw_comment': { - "str": 'un-set nsfw on a {self.target_link}', - "icon": 'fa-eye-evil', + "str": 'un-set nsfw on a {self.target_link}', + "icon": 'fa-eye-evil', "color": 'bg-success' }, } diff --git a/files/helpers/get.py b/files/helpers/get.py index ea1d9ff8b..00cc25cdb 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -78,7 +78,7 @@ def get_users(usernames:Iterable[str], graceful=False) -> List[User]: return users def get_account(id:Union[str, int], v:Optional[User]=None, graceful=False, include_blocks=False, include_shadowbanned=True) -> Optional[User]: - try: + try: id = int(id) except: if graceful: return None @@ -97,7 +97,7 @@ def get_account(id:Union[str, int], v:Optional[User]=None, graceful=False, inclu def get_accounts_dict(ids:Union[Iterable[str], Iterable[int]], v:Optional[User]=None, graceful=False, include_shadowbanned=True) -> Optional[dict[int, User]]: if not ids: return {} - try: + try: ids = set([int(id) for id in ids]) except: if graceful: return None @@ -132,15 +132,15 @@ def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Option post=post.filter(Submission.id == i ).outerjoin( - vt, - vt.c.submission_id == Submission.id, + vt, + vt.c.submission_id == Submission.id, ).outerjoin( - blocking, - blocking.c.target_id == Submission.author_id, + blocking, + blocking.c.target_id == Submission.author_id, ) post=post.one_or_none() - + if not post: if graceful: return None else: abort(404) @@ -163,7 +163,7 @@ def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra if v: vt = g.db.query(Vote.vote_type, Vote.submission_id).filter( - Vote.submission_id.in_(pids), + Vote.submission_id.in_(pids), Vote.user_id==v.id ).subquery() @@ -180,11 +180,11 @@ def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra ).outerjoin( vt, vt.c.submission_id==Submission.id ).outerjoin( - blocking, - blocking.c.target_id == Submission.author_id, + blocking, + blocking.c.target_id == Submission.author_id, ).outerjoin( - blocked, - blocked.c.user_id == Submission.author_id, + blocked, + blocked.c.user_id == Submission.author_id, ) else: query = g.db.query(Submission).filter(Submission.id.in_(pids)) @@ -245,7 +245,7 @@ def add_block_props(target:Union[Submission, Comment, User], v:Optional[User]): id = target.id else: raise TypeError("add_block_props only supports non-None submissions, comments, and users") - + if hasattr(target, 'is_blocking') and hasattr(target, 'is_blocked'): return target diff --git a/files/helpers/lottery.py b/files/helpers/lottery.py index 5ef82527a..fb77a002f 100644 --- a/files/helpers/lottery.py +++ b/files/helpers/lottery.py @@ -57,7 +57,7 @@ def end_lottery_session(): chance_to_win = str(chance_to_win)[:3] if user.id == winner: notification_text = f'You won {active_lottery.prize} coins in the lottershe! ' \ - + f'Congratulations!\nYour odds of winning were: {chance_to_win}%' + + f'Congratulations!\nYour odds of winning were: {chance_to_win}%' else: notification_text = f'You did not win the lottershe. Better luck next time!\n' \ + f'Your odds of winning were: {chance_to_win}%\nWinner: @{winning_user.username} (won {active_lottery.prize} coins)' diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index f0ef5b0f7..e892fb63c 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -16,8 +16,8 @@ from files.classes.notifications import Notification # Note: while https://api.pushshift.io/meta provides the key # server_ratelimit_per_minute, in practice Cloudflare puts stricter, -# unofficially documented limits at around 60/minute. We get nowhere near this -# with current keyword quantities. If this ever changes, consider reading the +# unofficially documented limits at around 60/minute. We get nowhere near this +# with current keyword quantities. If this ever changes, consider reading the # value from /meta (or just guessing) and doing a random selection of keywords. def offsite_mentions_task(cache:Cache): @@ -83,7 +83,7 @@ def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): 'text': text, }) try: - if not reddit_notifs_users: + if not reddit_notifs_users: cache.set(const.REDDIT_NOTIFS_CACHE_KEY, after + 1) except: print("Failed to set cache value; there may be duplication of reddit notifications", flush=True) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 02bd280b4..1e4bdc2e6 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -150,7 +150,7 @@ def censor_slurs(body:Optional[str], logged_user): def replace_re(body:str, regex:re.Pattern, regex_upper:re.Pattern, sub_func, sub_func_upper): body = regex_upper.sub(sub_func_upper, body) return regex.sub(sub_func, body) - + if not logged_user or logged_user == 'chat' or logged_user.slurreplacer: body = replace_re(body, slur_regex, slur_regex_upper, sub_matcher_slurs, sub_matcher_slurs_upper) if SITE_NAME == 'rDrama': diff --git a/files/helpers/roulette.py b/files/helpers/roulette.py index c07e0eaa6..de1355d5b 100644 --- a/files/helpers/roulette.py +++ b/files/helpers/roulette.py @@ -10,7 +10,7 @@ from files.helpers.alerts import * from files.helpers.get import get_account class RouletteAction(str, Enum): - STRAIGHT_UP_BET = "STRAIGHT_UP_BET", + STRAIGHT_UP_BET = "STRAIGHT_UP_BET", LINE_BET = "LINE_BET" COLUMN_BET = "COLUMN_BET" DOZEN_BET = "DOZEN_BET" diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 92ff4ddaf..7da09e702 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -96,7 +96,7 @@ def allowed_attributes(tag, name, value): if tag == 'table': if name == 'class' and value == 'table': return True - + return False def build_url_re(tlds, protocols): diff --git a/files/helpers/slots.py b/files/helpers/slots.py index 4f5606852..2463a7b2a 100644 --- a/files/helpers/slots.py +++ b/files/helpers/slots.py @@ -54,7 +54,7 @@ def casino_slot_pull(gambler, wager_value, currency): return casino_game.id, casino_game.game_state else: - return None, "{}", + return None, "{}", def build_symbols(for_payout): @@ -132,7 +132,7 @@ def check_slots_command(c:Comment, v:User, u:User): currency = 'coins' else: return - + if u.rehab: if v.id == u.id: abort(403, "You are under Rehab award effect!") @@ -146,7 +146,7 @@ def check_slots_command(c:Comment, v:User, u:User): abort(400, "Invalid wager.") return - if wager < 100: + if wager < 100: if v.id == u.id: abort(400, f"Wager must be 100 {currency} or more") return diff --git a/files/helpers/stats.py b/files/helpers/stats.py index c840df7fa..fd699706b 100644 --- a/files/helpers/stats.py +++ b/files/helpers/stats.py @@ -38,25 +38,25 @@ def chart(kind, site): day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(num_of_weeks)][1:] day_cutoffs.insert(0, calendar.timegm(now)) - daily_times = [time.strftime('%d/%m', time.gmtime(day_cutoffs[i + 1])) + daily_times = [time.strftime('%d/%m', time.gmtime(day_cutoffs[i + 1])) for i in range(len(day_cutoffs) - 1)][::-1] daily_signups = [g.db.query(User).filter( - User.created_utc < day_cutoffs[i], - User.created_utc > day_cutoffs[i + 1]).count() + User.created_utc < day_cutoffs[i], + User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][::-1] post_stats = [g.db.query(Submission).filter( - Submission.created_utc < day_cutoffs[i], - Submission.created_utc > day_cutoffs[i + 1], - Submission.is_banned == False).count() + Submission.created_utc < day_cutoffs[i], + Submission.created_utc > day_cutoffs[i + 1], + Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][::-1] comment_stats = [g.db.query(Comment).filter( - Comment.created_utc < day_cutoffs[i], + Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1], - Comment.is_banned == False, - Comment.author_id != AUTOJANNY_ID).count() + Comment.is_banned == False, + Comment.author_id != AUTOJANNY_ID).count() for i in range(len(day_cutoffs) - 1)][::-1] plt.rcParams['figure.figsize'] = (chart_width, 20) diff --git a/files/helpers/twentyone.py b/files/helpers/twentyone.py index ba9d29a9b..f5ea399d1 100644 --- a/files/helpers/twentyone.py +++ b/files/helpers/twentyone.py @@ -83,7 +83,7 @@ def get_active_twentyone_game_state(gambler): def charge_gambler(gambler, amount, currency): charged = gambler.charge_account(currency, amount) - + if not charged: raise Exception("Gambler cannot afford charge.") @@ -244,7 +244,7 @@ def handle_payout(gambler, state, game): raise Exception("Attempted to payout a game that has not finished.") gambler.pay_account(game.currency, payout) - + if game.currency == 'coins': if status in {BlackjackStatus.BLACKJACK, BlackjackStatus.WON}: distribute_wager_badges(gambler, game.wager, won=True) @@ -259,7 +259,7 @@ def handle_payout(gambler, state, game): def remove_exploitable_information(state): safe_state = state - + if len(safe_state['dealer']) >= 2: safe_state['dealer'][1] = '?' diff --git a/files/routes/admin.py b/files/routes/admin.py index 664c06cf9..b87b58cff 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -51,7 +51,7 @@ def move_acc(v:User, new_id, old_id): old_id = int(old_id) new_id = int(new_id) - + olduser = g.db.get(User, old_id) newuser = g.db.get(User, new_id) @@ -307,7 +307,7 @@ def distribute(v:User, option_id): losing_voters.extend([x.user_id for x in o.votes]) for uid in losing_voters: add_notif(cid, uid) - + ma = ModAction( kind="distribute", user_id=v.id, @@ -455,7 +455,7 @@ def admin_home(v): if v.admin_level >= PERMS['SITE_SETTINGS_UNDER_ATTACK']: under_attack = (get_security_level() or 'high') == 'under_attack' - return render_template("admin/admin_home.html", v=v, + return render_template("admin/admin_home.html", v=v, under_attack=under_attack) @app.post("/admin/site_settings/") @@ -575,7 +575,7 @@ def badge_grant_post(v): if v.id != user.id: text = f"@{v.username} (a site admin) has given you the following profile badge:\n\n![]({new_badge.path})\n\n**{new_badge.name}**\n\n{new_badge.badge.description}" send_repeatable_notification(user.id, text) - + ma = ModAction( kind="badge_grant", user_id=v.id, @@ -851,7 +851,7 @@ def admin_removed(v): def admin_removed_comments(v): try: page = int(request.values.get("page", 1)) except: page = 1 - + ids = g.db.query(Comment.id).join(Comment.author).filter(or_(Comment.is_banned==True, User.shadowbanned != None)).order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() ids=[x[0] for x in ids] next_exists = len(ids) > PAGE_SIZE @@ -926,7 +926,7 @@ def shadowban(user_id, v): _note=f'reason: "{reason}"' ) g.db.add(ma) - + cache.delete_memoized(frontlist) return {"message": f"@{user.username} has been shadowbanned!"} @@ -951,7 +951,7 @@ def unshadowban(user_id, v): target_user_id=user.id, ) g.db.add(ma) - + cache.delete_memoized(frontlist) return {"message": f"@{user.username} has been unshadowbanned!"} @@ -982,7 +982,7 @@ def admin_title_change(user_id, v): if user.flairchanged: kind = "set_flair_locked" else: kind = "set_flair_notlocked" - + ma=ModAction( kind=kind, user_id=v.id, @@ -1379,7 +1379,7 @@ def unsticky_post(post_id, v): if post.stickied: if FEATURES['AWARDS'] and post.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!") if post.author_id == LAWLZ_ID and post.stickied_utc and SITE_NAME == 'rDrama': abort(403, "Can't unpin lawlzposts!") - + post.stickied = None post.stickied_utc = None g.db.add(post) @@ -1424,13 +1424,13 @@ def sticky_comment(cid, v): g.db.add(c) return {"message": "Comment pinned!"} - + @app.post("/unsticky_comment/") @admin_level_required(PERMS['POST_COMMENT_MODERATION']) def unsticky_comment(cid, v): comment = get_comment(cid, v=v) - + if comment.stickied: if FEATURES['AWARDS'] and comment.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!") @@ -1481,7 +1481,7 @@ def remove_comment(c_id, v): @admin_level_required(PERMS['POST_COMMENT_MODERATION']) def approve_comment(c_id, v): comment = get_comment(c_id) - + if comment.author.id == v.id and comment.author.agendaposter and AGENDAPOSTER_PHRASE not in comment.body.lower() and not (comment.parent_submission and comment.post.sub == 'chudrama'): abort(400, "You can't bypass the chud award!") @@ -1572,7 +1572,7 @@ def ban_domain(v): def unban_domain(v:User, domain): existing = g.db.get(BannedDomain, domain) if not existing: abort(400, 'Domain is not banned!') - + g.db.delete(existing) ma = ModAction( kind="unban_domain", @@ -1595,7 +1595,7 @@ def admin_nuke_user(v): for post in g.db.query(Submission).filter_by(author_id=user.id).all(): if post.is_banned: continue - + post.is_banned = True post.ban_reason = v.username g.db.add(post) @@ -1628,7 +1628,7 @@ def admin_nunuke_user(v): for post in g.db.query(Submission).filter_by(author_id=user.id).all(): if not post.is_banned: continue - + post.is_banned = False post.ban_reason = None post.is_approved = v.id diff --git a/files/routes/allroutes.py b/files/routes/allroutes.py index 8d768c687..44021f642 100644 --- a/files/routes/allroutes.py +++ b/files/routes/allroutes.py @@ -63,7 +63,7 @@ def after_request(response:Response): if response.status_code < 400: _set_cloudflare_cookie(response) _commit_and_close_db() - + return response @@ -82,7 +82,7 @@ def _set_cloudflare_cookie(response:Response) -> None: if not logged_in and request.cookies.get("lo"): response.delete_cookie("lo", domain=app.config["COOKIE_DOMAIN"], samesite="Lax") elif logged_in and not request.cookies.get("lo"): - response.set_cookie("lo", CLOUDFLARE_COOKIE_VALUE if logged_in else '', + response.set_cookie("lo", CLOUDFLARE_COOKIE_VALUE if logged_in else '', max_age=SESSION_LIFETIME, samesite="Lax", domain=app.config["COOKIE_DOMAIN"]) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index a59fec65a..82d6af26c 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -371,7 +371,7 @@ def update_marsey(v): return error("Image uploads are not allowed through TOR.") if not file.content_type.startswith('image/'): return error("You need to submit an image!") - + for x in IMAGE_FORMATS: if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'): os.remove(f'/asset_submissions/marseys/original/{name}.{x}') @@ -387,7 +387,7 @@ def update_marsey(v): copyfile(new_path, filename) process_image(filename, v, resize=200, trim=True) purge_files_in_cache([f"https://{SITE}/e/{name}.webp", f"https://{SITE}/assets/images/emojis/{name}.webp", f"https://{SITE}/asset_submissions/marseys/original/{name}.{format}"]) - + if tags and existing.tags != tags and tags != "none": existing.tags = tags g.db.add(existing) diff --git a/files/routes/awards.py b/files/routes/awards.py index c58a40bfd..6cee09d2b 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -103,7 +103,7 @@ def buy(v:User, award): v.lootboxes_bought += 1 lootbox_msg = "You open your lootbox and receive: " + ', '.join(lootbox_items) send_repeatable_notification(v.id, lootbox_msg) - + if v.lootboxes_bought == 10: badge_grant(badge_id=76, user=v) elif v.lootboxes_bought == 50: @@ -131,16 +131,16 @@ def buy(v:User, award): def award_thing(v, thing_type, id): kind = request.values.get("kind", "").strip() - if thing_type == 'post': + if thing_type == 'post': thing = get_post(id) - else: + else: thing = get_comment(id) if not thing.parent_submission and not thing.wall_user_id: abort(404) # don't let users award messages if v.shadowbanned: abort(500) author = thing.author if author.shadowbanned: abort(404) - + AWARDS = deepcopy(AWARDS_ENABLED) if v.house: AWARDS[v.house] = HOUSE_AWARDS[v.house] @@ -288,7 +288,7 @@ def award_thing(v, thing_type, id): if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400 else: author.agendaposter = int(time.time()) + 86400 - + badge_grant(user=author, badge_id=28) elif kind == "flairlock": new_name = note[:100].replace("𒐪","").replace("﷽","").strip() @@ -375,10 +375,10 @@ def award_thing(v, thing_type, id): elif "Vampire" in kind and kind == v.house: if author.bite: author.bite += 172800 else: author.bite = int(time.time()) + 172800 - + if not author.old_house: author.old_house = author.house - + if 'Vampire' not in author.house: author.house = 'Vampire' diff --git a/files/routes/casino.py b/files/routes/casino.py index 6688ec8dd..f510a4e46 100644 --- a/files/routes/casino.py +++ b/files/routes/casino.py @@ -54,7 +54,7 @@ def casino_game_page(v:User, game): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def casino_game_feed(v:User, game): - if v.rehab: + if v.rehab: abort(403, "You are under Rehab award effect!") elif game not in CASINO_GAME_KINDS: abort(404) diff --git a/files/routes/chat.py b/files/routes/chat.py index f61f61236..a6f8e1116 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -83,7 +83,7 @@ def speak(data, v): "text_censored": censor_slurs(text_html, 'chat'), "time": int(time.time()), } - + if v.shadowbanned or not execute_blackjack(v, None, text, "chat"): emit('speak', data) elif recipient: diff --git a/files/routes/comments.py b/files/routes/comments.py index a8eb80546..5258670c9 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -43,7 +43,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): g.db.commit() post = comment.post - + if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()): if v and v.client: abort(403, "This content is not suitable for some users and situations.") else: return render_template("errors/nsfw.html", v=v), 403 @@ -70,9 +70,9 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): execute_shadowban_viewers_and_voters(v, post) execute_shadowban_viewers_and_voters(v, comment) - + if v and v.client: return top_comment.json(db=g.db) - else: + else: if post.is_banned and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr) @@ -107,7 +107,7 @@ def comment(v:User): post_target = get_post(parent.parent_submission, v=v, graceful=True) or get_account(parent.wall_user_id, v=v, include_blocks=True, include_shadowbanned=False) parent_comment_id = parent.id if parent.author_id == v.id: rts = True - if not v.can_post_in_ghost_threads and isinstance(post_target, Submission) and post_target.ghost: + if not v.can_post_in_ghost_threads and isinstance(post_target, Submission) and post_target.ghost: abort(403, f"You need {TRUESCORE_GHOST_MINIMUM} truescore to post in ghost threads") ghost = parent.ghost else: abort(404) @@ -200,7 +200,7 @@ def comment(v:User): abort(415) body = body.strip()[:COMMENT_BODY_LENGTH_LIMIT] - + if v.admin_level >= PERMS['SITE_SETTINGS_SNAPPY_QUOTES'] and posting_to_submission and post_target.id == SNAPPY_THREAD and level == 1: with open(f"snappy_{SITE_NAME}.txt", "a", encoding="utf-8") as f: f.write('\n{[para]}\n' + body) @@ -297,7 +297,7 @@ def comment(v:User): for x in subscribers: notify_users.add(x[0]) - + if parent_user.id != v.id: notify_users.add(parent_user.id) @@ -422,9 +422,9 @@ def edit_comment(cid, v): if int(time.time()) - c.created_utc > 60 * 3: c.edited_utc = int(time.time()) g.db.add(c) - + notify_users = NOTIFY_USERS(body, v) - + for x in notify_users-bots: notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none() if not notif: @@ -481,12 +481,12 @@ def undelete_comment(cid, v): @feature_required('PINS') @auth_required def pin_comment(cid, v): - + comment = get_comment(cid, v=v) - + if not comment.stickied: if v.id != comment.post.author_id: abort(403) - + if comment.post.ghost: comment.stickied = "(OP)" else: comment.stickied = v.username + " (OP)" @@ -498,18 +498,18 @@ def pin_comment(cid, v): send_repeatable_notification(comment.author_id, message) return {"message": "Comment pinned!"} - + @app.post("/unpin_comment/") @auth_required def unpin_comment(cid, v): - + comment = get_comment(cid, v=v) - + if comment.stickied: if v.id != comment.post.author_id: abort(403) - if not comment.stickied.endswith(" (OP)"): + if not comment.stickied.endswith(" (OP)"): abort(403, "You can only unpin comments you have pinned!") comment.stickied = None @@ -602,7 +602,7 @@ def handle_wordle_action(cid, v): comment.wordle_result = f'{guesses}_{status}_{answer}' g.db.add(comment) - + return {"response" : comment.wordle_html(v)} @@ -613,7 +613,7 @@ def toggle_comment_nsfw(cid, v): if comment.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - + if comment.over_18 and v.is_suspended_permanently: abort(403) diff --git a/files/routes/feeds.py b/files/routes/feeds.py index 792fa71ad..7bc4beb8e 100644 --- a/files/routes/feeds.py +++ b/files/routes/feeds.py @@ -22,7 +22,7 @@ def feeds_user(sort='hot', t='all'): t=t, v=None, ) - + posts = get_posts(ids) doc, tag, text = Doc().tagtext() @@ -54,7 +54,7 @@ def feeds_user(sort='hot', t='all'): with tag("published"): text(datetime.datetime.utcfromtimestamp(post.created_utc).isoformat()+"Z") - + with tag("author"): with tag("name"): text(post.author_name) diff --git a/files/routes/front.py b/files/routes/front.py index 1d36c2d47..e604e7cc0 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -35,7 +35,7 @@ def front_all(v, sub=None, subdomain=None): sub = get_sub_by_name(sub, graceful=True) if sub and not User.can_see(v, sub): abort(403) - + if (request.path.startswith('/h/') or request.path.startswith('/s/')) and not sub: abort(404) try: page = max(int(request.values.get("page", 1)), 1) @@ -52,7 +52,7 @@ def front_all(v, sub=None, subdomain=None): sort=request.values.get("sort", defaultsorting) t=request.values.get('t', defaulttime) - + try: gt=int(request.values.get("after", 0)) except: gt=0 @@ -79,7 +79,7 @@ def front_all(v, sub=None, subdomain=None): ) posts = get_posts(ids, v=v, eager=True) - + if v: if v.hidevotedon: posts = [x for x in posts if not hasattr(x, 'voted') or not x.voted] award_timers(v) @@ -91,7 +91,7 @@ def front_all(v, sub=None, subdomain=None): @cache.memoize(timeout=86400) def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, sub=None, site=None, pins=True, holes=True): posts = g.db.query(Submission) - + if v and v.hidevotedon: posts = posts.outerjoin(Vote, and_(Vote.submission_id == Submission.id, Vote.user_id == v.id) @@ -148,7 +148,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' pins = g.db.query(Submission).filter(Submission.sub == sub.name, Submission.hole_pinned != None) else: pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) - + if v: pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) for pin in pins: @@ -184,7 +184,7 @@ def random_post(v:User): @auth_required def random_user(v:User): u = g.db.query(User.username).filter(User.song != None, User.shadowbanned == None).order_by(func.random()).first() - + if u: u = u[0] else: abort(404, "No users have set a profile anthem so far!") diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index d8c27e568..fd0f344e5 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -63,14 +63,14 @@ def calc_users(): ua = str(user_agents.parse(g.agent)) if 'spider' not in ua.lower() and 'bot' not in ua.lower(): loggedout[session["session_id"]] = (timestamp, ua) - + loggedin = {k: v for k, v in loggedin.items() if (timestamp - v) < LOGGEDIN_ACTIVE_TIME} loggedout = {k: v for k, v in loggedout.items() if (timestamp - v[0]) < LOGGEDIN_ACTIVE_TIME} cache.set(LOGGED_IN_CACHE_KEY, loggedin) cache.set(LOGGED_OUT_CACHE_KEY, loggedout) loggedin_counter = len(loggedin) loggedout_counter = len(loggedout) - return {'loggedin_counter':loggedin_counter, + return {'loggedin_counter':loggedin_counter, 'loggedout_counter':loggedout_counter, 'loggedin_chat':loggedin_chat} @@ -82,7 +82,7 @@ def inject_constants(): return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL, "AUTOJANNY_ID":AUTOJANNY_ID, "MODMAIL_ID":MODMAIL_ID, "VAPID_PUBLIC_KEY":VAPID_PUBLIC_KEY, "listdir":listdir, "os_path":path, "AEVANN_ID":AEVANN_ID, - "PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR, + "PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES, "HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED, "GUMROAD_LINK":GUMROAD_LINK, "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION, @@ -95,9 +95,9 @@ def inject_constants(): "site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see, "TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, "TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, - "DONATE_LINK":DONATE_LINK, "DONATE_SERVICE":DONATE_SERVICE, "BAN_EVASION_DOMAIN":BAN_EVASION_DOMAIN, + "DONATE_LINK":DONATE_LINK, "DONATE_SERVICE":DONATE_SERVICE, "BAN_EVASION_DOMAIN":BAN_EVASION_DOMAIN, "HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS), - "PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS, - "TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME, + "PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS, + "TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME, "DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users } diff --git a/files/routes/login.py b/files/routes/login.py index d05ab03af..21966fd02 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -346,7 +346,7 @@ def sign_up_post(v:Optional[User]): check_for_alts(new_user) send_notification(new_user.id, WELCOME_MSG) - + if SIGNUP_FOLLOW_ID: signup_autofollow = get_account(SIGNUP_FOLLOW_ID) new_follow = Follow(user_id=new_user.id, target_id=signup_autofollow.id) @@ -502,7 +502,7 @@ def request_2fa_disable(): token=generate_hash(f"{user.id}+{user.username}+disable2fa+{valid}+{user.mfa_secret}+{user.login_nonce}") action_url=f"{SITE_FULL}/reset_2fa?id={user.id}&t={valid}&token={token}" - + send_mail(to_address=user.email, subject="2FA Removal Request", html=render_template("email/2fa_remove.html", diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 0b754bd21..7323b443c 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -329,7 +329,7 @@ def notifications(v:User): total.extend(c.replies2) if c not in listing: listing.append(c) - + total.extend(listing) total_cids = [x.id for x in total] diff --git a/files/routes/oauth.py b/files/routes/oauth.py index f411128d8..85d5b2f73 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -97,7 +97,7 @@ def delete_oauth_app(v, aid): abort(404) app = g.db.get(OauthApp, aid) if not app: abort(404) - + if app.author_id != v.id: abort(403) for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): diff --git a/files/routes/polls.py b/files/routes/polls.py index ac43d2fa3..bcead7b44 100644 --- a/files/routes/polls.py +++ b/files/routes/polls.py @@ -22,7 +22,7 @@ def vote_option(option_id, v): if option.exclusive == 2: if option.post.total_bet_voted(v): abort(403, "You can't bet on a closed poll!") - if not v.charge_account('coins', POLL_BET_COINS): + if not v.charge_account('coins', POLL_BET_COINS): abort(400, f"You don't have {POLL_BET_COINS} coins!") g.db.add(v) autojanny = get_account(AUTOJANNY_ID) diff --git a/files/routes/posts.py b/files/routes/posts.py index 13dc5aa1d..37922a67b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -45,7 +45,7 @@ def publish(pid, v): post.private = False post.created_utc = int(time.time()) g.db.add(post) - + if not post.ghost: notify_users = NOTIFY_USERS(f'{post.title} {post.body}', v) @@ -189,7 +189,7 @@ def view_more(v, pid, sort, offset): except: abort(400) try: ids = set(int(x) for x in request.values.get("ids").split(',')) except: abort(400) - + if v: # shadowban check is done in sort_objects # output is needed: see comments.py @@ -209,7 +209,7 @@ def view_more(v, pid, sort, offset): comments = sort_objects(sort, comments, Comment, include_shadowbanned=False) - + comments = comments.offset(offset).all() comments2 = [] @@ -226,7 +226,7 @@ def view_more(v, pid, sort, offset): ids.add(comment.id) count += g.db.query(Comment).filter_by(parent_submission=post.id, parent_comment_id=comment.id).count() + 1 if count > 20: break - + if len(comments) == len(comments2): offset = 0 else: offset += 1 comments = comments2 @@ -255,7 +255,7 @@ def more_comments(v, cid): if comments: p = comments[0].post else: p = None - + return render_template("comments.html", v=v, comments=comments, p=p, render_replies=True) @app.post("/edit_post/") @@ -320,7 +320,7 @@ def edit_post(pid, v): for text in [p.body, p.title, p.url]: if not execute_blackjack(v, p, text, 'submission'): break - if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: + if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: abort(400, f"Submission body_html too long!") p.body_html = body_html @@ -367,13 +367,13 @@ def thumbnail_thread(pid:int, vid:int): return f"{post_url}/{fragment_url}" post = db.get(Submission, pid) - + if not post or not post.url: time.sleep(5) post = db.get(Submission, pid) if not post or not post.url: return - + fetch_url = post.url if fetch_url.startswith('/') and '\\' not in fetch_url: @@ -404,12 +404,12 @@ def thumbnail_thread(pid:int, vid:int): ] for tag_name in meta_tags: - + tag = soup.find( - 'meta', + 'meta', attrs={ - "name": tag_name, + "name": tag_name, "content": True } ) @@ -510,7 +510,7 @@ def is_repost(): params=parsed_url.params, query=urlencode(filtered, doseq=True), fragment=parsed_url.fragment) - + url = urlunparse(new_url) url = url.rstrip('/') @@ -539,7 +539,7 @@ def submit_post(v:User, sub=None): def error(error): if g.is_api_or_xhr: abort(400, error) - + SUBS = [x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()] return render_template("submit.html", SUBS=SUBS, v=v, error=error, title=title, url=url, body=body), 400 @@ -555,7 +555,7 @@ def submit_post(v:User, sub=None): title_html = filter_emojis_only(title, graceful=True, count_marseys=True, torture=torture) if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html): return error("You can only type marseys!") - if len(title_html) > POST_TITLE_HTML_LENGTH_LIMIT: + if len(title_html) > POST_TITLE_HTML_LENGTH_LIMIT: return error("Rendered title is too big!") if sub == 'changelog' and not v.admin_level >= PERMS['POST_TO_CHANGELOG']: @@ -610,7 +610,7 @@ def submit_post(v:User, sub=None): params=parsed_url.params, query=urlencode(filtered, doseq=True), fragment=parsed_url.fragment) - + url = urlunparse(new_url) url = url.rstrip('/') @@ -660,7 +660,7 @@ def submit_post(v:User, sub=None): if not url and not body and not request.files.get("file") and not request.files.get("file-url"): return error("Please enter a url or some text.") - if not IS_LOCALHOST: + if not IS_LOCALHOST: dup = g.db.query(Submission).filter( Submission.author_id == v.id, Submission.deleted_utc == 0, @@ -738,7 +738,7 @@ def submit_post(v:User, sub=None): submission_id=post.id ) g.db.add(vote) - + if request.files.get('file-url') and not g.is_tor: file = request.files['file-url'] @@ -761,7 +761,7 @@ def submit_post(v:User, sub=None): post.url = process_audio(file, v) else: abort(415) - + if not post.thumburl and post.url: gevent.spawn(thumbnail_thread, post.id, v.id) @@ -889,7 +889,7 @@ def mark_post_nsfw(pid, v): if post.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (post.sub and v.mods(post.sub)): abort(403) - + if post.over_18 and v.is_suspended_permanently: abort(403) @@ -923,7 +923,7 @@ def unmark_post_nsfw(pid, v): if post.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (post.sub and v.mods(post.sub)): abort(403) - + if post.over_18 and v.is_suspended_permanently: abort(403) @@ -1056,7 +1056,7 @@ def get_post_title(v): try: x = gevent.with_timeout(POST_TITLE_TIMEOUT, requests.get, url, headers=titleheaders, timeout=POST_TITLE_TIMEOUT, proxies=proxies) except: abort(400) - + content_type = x.headers.get("Content-Type") if not content_type or "text/html" not in content_type: abort(400) diff --git a/files/routes/push_notifs.py b/files/routes/push_notifs.py index 13591b168..bfb986103 100644 --- a/files/routes/push_notifs.py +++ b/files/routes/push_notifs.py @@ -19,5 +19,5 @@ def push_subscribe(v): subscription_json=subscription_json, ) g.db.add(subscription) - + return '' diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 1a2890c83..26baba8f9 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -58,7 +58,7 @@ def flag_post(pid, v): moved = move_post(post, v, reason) if moved: return {"message": moved} - + existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none() if existing: abort(409, "You already reported this post!") flag = Flag(post_id=post.id, user_id=v.id, reason=reason) @@ -74,7 +74,7 @@ def flag_post(pid, v): def flag_comment(cid, v): comment = get_comment(cid) - + existing = g.db.query(CommentFlag.comment_id).filter_by(user_id=v.id, comment_id=comment.id).one_or_none() if existing: abort(409, "You already reported this comment!") @@ -125,7 +125,7 @@ def remove_report_comment(v, cid, uid): uid = int(uid) except: abort(404) report = g.db.query(CommentFlag).filter_by(comment_id=cid, user_id=uid).one_or_none() - + if report: g.db.delete(report) @@ -143,7 +143,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]: sub_from = post.sub sub_to = get_sub_by_name(reason, graceful=True) sub_to = sub_to.name if sub_to else None - + can_move_post = v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (post.sub and v.mods(sub_from)) if sub_from != 'chudrama': # posts can only be moved out of /h/chudrama by admins can_move_post = can_move_post or post.author_id == v.id @@ -158,7 +158,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]: abort(403, f"You need to be a member of House {sub_to.capitalize()} to post in /h/{sub_to}") else: abort(403, f"@{post.author.username} needs to be a member of House {sub_to.capitalize()} for their post to be moved to /h/{sub_to}") - + post.sub = sub_to post.hole_pinned = None g.db.add(post) diff --git a/files/routes/routehelpers.py b/files/routes/routehelpers.py index 893d7bb49..ef0813929 100644 --- a/files/routes/routehelpers.py +++ b/files/routes/routehelpers.py @@ -41,7 +41,7 @@ def get_alt_graph_ids(uid:int) -> List[int]: ).select_from(Alt, alt_graph_cte).filter( or_(alt_graph_cte.c.user_id == Alt.user1, alt_graph_cte.c.user_id == Alt.user2) ) - + alt_graph_cte = alt_graph_cte.union(alt_graph_cte_inner) return set([x[0] for x in g.db.query(User.id).filter(User.id == alt_graph_cte.c.user_id, User.id != uid).all()]) @@ -86,7 +86,7 @@ def check_for_alts(current:User, include_current_session=True): if a.user1 != current_id: add_alt(a.user1, current_id) if a.user2 != past_id: add_alt(a.user2, past_id) if a.user2 != current_id: add_alt(a.user2, current_id) - + past_accs.add(current_id) if include_current_session: session["history"] = list(past_accs) @@ -110,7 +110,7 @@ def execute_shadowban_viewers_and_voters(v:Optional[User], target:Union[Submissi max_upvotes = min(ti, 13) rand = randint(0, max_upvotes) if target.upvotes >= rand: return - + amount = randint(0, 3) if amount != 1: return diff --git a/files/routes/search.py b/files/routes/search.py index a21c19863..4b4f34fb7 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -59,13 +59,13 @@ def searchposts(v:User): posts = g.db.query(Submission.id) \ .join(Submission.author) \ .filter(Submission.author_id.notin_(v.userblocks)) - + if v.admin_level < PERMS['POST_COMMENT_MODERATION']: posts = posts.filter( Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False) - + if 'author' in criteria: posts = posts.filter(Submission.ghost == False) author = get_user(criteria['author'], v=v, include_shadowbanned=False) @@ -95,7 +95,7 @@ def searchposts(v:User): words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) \ for x in criteria['q']] posts = posts.filter(*words) - + if 'over18' in criteria: posts = posts.filter(Submission.over_18==True) if 'domain' in criteria: @@ -187,7 +187,7 @@ def searchcomments(v:User): Comment.author_id.notin_(v.userblocks), ) - + if 'post' in criteria: try: post = int(criteria['post']) except: abort(404) @@ -282,21 +282,21 @@ def searchusers(v:User): t = request.values.get('t', 'all').lower() term=query.lstrip('@') term = term.replace('\\','').replace('_','\_').replace('%','') - + users=g.db.query(User).filter( or_( User.username.ilike(f'%{term}%'), User.original_username.ilike(f'%{term}%') ) ) - + if v.admin_level < PERMS['USER_SHADOWBAN']: users = users.filter(User.shadowbanned == None) users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc()) - + total=users.count() - + users = users.offset(PAGE_SIZE * (page-1)).limit(PAGE_SIZE+1).all() next_exists=(len(users)>PAGE_SIZE) users=users[:PAGE_SIZE] diff --git a/files/routes/settings.py b/files/routes/settings.py index 24ea58548..2a227d759 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -111,7 +111,7 @@ def settings_personal_post(v): updated = False # begin common selectors # - + def update_flag(column_name:str, request_name:str): if not request.values.get(request_name, ''): return False request_flag = request.values.get(request_name, '') == 'true' @@ -119,7 +119,7 @@ def settings_personal_post(v): setattr(v, column_name, request_flag) return True return False - + def update_potentially_permanent_flag(column_name:str, request_name:str, friendly_name:str, badge_id:Optional[int]): if not request.values.get(request_name): return False current_value = getattr(v, column_name) @@ -161,14 +161,14 @@ def settings_personal_post(v): updated = True v.poor = request.values.get("poor", v.poor) == 'true' session['poor'] = v.poor - + slur_filter_updated = updated or update_potentially_permanent_flag("slurreplacer", "slurreplacer", "slur replacer", 192) if isinstance(slur_filter_updated, bool): updated = slur_filter_updated else: g.db.add(v) return slur_filter_updated - + profanity_filter_updated = updated or update_potentially_permanent_flag("profanityreplacer", "profanityreplacer", "profanity replacer", 190) if isinstance(profanity_filter_updated, bool): updated = profanity_filter_updated @@ -191,7 +191,7 @@ def settings_personal_post(v): updated = True v.spider = int(request.values.get("spider") == 'true') if v.spider: badge_grant(user=v, badge_id=179) - else: + else: badge = v.has_badge(179) if badge: g.db.delete(badge) @@ -317,7 +317,7 @@ def settings_personal_post(v): updated = True cache.delete_memoized(frontlist) else: abort(400) - + updated = updated or set_selector_option("defaultsortingcomments", "defaultsortingcomments", COMMENT_SORTS, "comment sort") updated = updated or set_selector_option("defaultsorting", "defaultsorting", SORTS, "post sort") updated = updated or set_selector_option("defaulttime", "defaulttime", TIME_FILTERS, "time filter") @@ -337,7 +337,7 @@ def settings_personal_post(v): if v.house: if v.house.replace(' Founder', '') == house: abort(409, f"You're already in House {house}") cost = HOUSE_SWITCH_COST - else: + else: cost = HOUSE_JOIN_COST success = v.charge_account('coins', cost) @@ -345,7 +345,7 @@ def settings_personal_post(v): success = v.charge_account('marseybux', cost) if not success: abort(403) - if house == "None": house = '' + if house == "None": house = '' v.house = house updated = True @@ -389,7 +389,7 @@ def set_color(v:User, attr:str, color:Optional[str]): @auth_required def namecolor(v): return set_color(v, "namecolor", request.values.get("namecolor")) - + @app.post("/settings/themecolor") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=lambda:f'{request.host}-{session.get("lo_user")}') @@ -430,7 +430,7 @@ def gumroad(v): g.db.add(v) badge_grant(badge_id=20+tier, user=v) - + return {"message": f"{patron} rewards claimed!"} @@ -640,7 +640,7 @@ def settings_security(v:User): def settings_block_user(v): user = get_user(request.values.get("username"), graceful=True) if not user: abort(404, "This user doesn't exist.") - + if user.unblockable: if not v.shadowbanned: send_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!") @@ -778,12 +778,12 @@ def settings_song_change(v): if not yt_id_regex.fullmatch(id): return render_template("settings/personal.html", v=v, error="Not a YouTube link"), 400 - if path.isfile(f'/songs/{id}.mp3'): + if path.isfile(f'/songs/{id}.mp3'): v.song = id g.db.add(v) return render_template("settings/personal.html", v=v, msg="Profile Anthem successfully updated!") - - + + req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json() duration = req['items'][0]['contentDetails']['duration'] if duration == 'P0D': @@ -794,7 +794,7 @@ def settings_song_change(v): if "M" in duration: duration = int(duration.split("PT")[1].split("M")[0]) - if duration > 15: + if duration > 15: return render_template("settings/personal.html", v=v, error="Duration of the video must not exceed 15 minutes."), 400 @@ -835,7 +835,7 @@ def settings_song_change(v): @auth_required def settings_title_change(v): if v.flairchanged: abort(403) - + customtitleplain = sanitize_settings_text(request.values.get("title"), 100) if len(customtitleplain) > 100: diff --git a/files/routes/static.py b/files/routes/static.py index f35c2177b..8e27ae211 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -142,7 +142,7 @@ def log(v:User): actions = [] else: actions = g.db.query(ModAction) - if not (v and v.admin_level >= PERMS['USER_SHADOWBAN']): + if not (v and v.admin_level >= PERMS['USER_SHADOWBAN']): actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED_TYPES)) if admin_id: @@ -156,7 +156,7 @@ def log(v:User): if kind: actions = actions.filter_by(kind=kind) actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all() - + next_exists=len(actions) > PAGE_SIZE actions=actions[:PAGE_SIZE] admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).order_by(User.username).all()] @@ -228,7 +228,7 @@ def submit_contact(v): execute_blackjack(v, new_comment, new_comment.body_html, 'modmail') execute_under_siege(v, new_comment, new_comment.body_html, 'modmail') new_comment.top_comment_id = new_comment.id - + admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != AEVANN_ID) for admin in admins.all(): @@ -254,7 +254,7 @@ def badge_list(site): counts = {} for c in counts_raw: counts[c[0]] = (c[1], float(c[1]) * 100 / max(users, 1)) - + return badges, counts @app.get("/badges") diff --git a/files/routes/subs.py b/files/routes/subs.py index c39665ca3..0117c37f4 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -37,7 +37,7 @@ def exile_post(v:User, pid): _note=f'for {p.title_html}' ) g.db.add(ma) - + return {"message": f"@{u.username} has been exiled from /h/{sub} successfully!"} @app.post("/exile/comment/") @@ -92,11 +92,11 @@ def unexile(v:User, sub, uid): target_user_id=u.id ) g.db.add(ma) - + if g.is_api_or_xhr: return {"message": f"@{u.username} has been unexiled from /h/{sub} successfully!"} - + return redirect(f'/h/{sub}/exilees') @app.post("/h//block") @@ -205,7 +205,7 @@ def sub_blockers(v:User, sub): .filter_by(sub=sub.name) \ .order_by(nullslast(SubBlock.created_utc.desc()), User.username).all() - return render_template("sub/blockers.html", + return render_template("sub/blockers.html", v=v, sub=sub, users=users, verb="blocking") @@ -219,7 +219,7 @@ def sub_followers(v:User, sub): .filter_by(sub=sub.name) \ .order_by(nullslast(SubSubscription.created_utc.desc()), User.username).all() - return render_template("sub/blockers.html", + return render_template("sub/blockers.html", v=v, sub=sub, users=users, verb="following") @@ -265,7 +265,7 @@ def add_mod(v:User, sub): @is_not_permabanned def remove_mod(v:User, sub): sub = get_sub_by_name(sub).name - + if not v.mods(sub): abort(403) if v.shadowbanned: abort(500) @@ -510,7 +510,7 @@ def delete_sub_banner(v:User, sub:str, index:int): @limiter.limit("1/10 second;30/day") @limiter.limit("1/10 second;30/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') @is_not_permabanned -def delete_all_sub_banners(v:User, sub:str): +def delete_all_sub_banners(v:User, sub:str): sub = get_sub_by_name(sub) if not v.mods(sub.name): abort(403) if v.shadowbanned: return redirect(f'/h/{sub}/settings') @@ -542,7 +542,7 @@ def sub_sidebar(v:User, sub): sub = get_sub_by_name(sub) if not v.mods(sub.name): abort(403) if v.shadowbanned: return redirect(f'/h/{sub}/settings') - + file = request.files["sidebar"] name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) @@ -573,7 +573,7 @@ def sub_marsey(v:User, sub): sub = get_sub_by_name(sub) if not v.mods(sub.name): abort(403) if v.shadowbanned: return redirect(f'/h/{sub}/settings') - + file = request.files["marsey"] name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) @@ -692,12 +692,12 @@ def sub_stealth(v:User, sub): @feature_required('PINS') @is_not_permabanned def mod_pin(cid, v): - + comment = get_comment(cid, v=v) - + if not comment.stickied: if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - + comment.stickied = v.username + " (Mod)" g.db.add(comment) @@ -719,9 +719,9 @@ def mod_pin(cid, v): @app.post("/unmod_pin/") @is_not_permabanned def mod_unpin(cid, v): - + comment = get_comment(cid, v=v) - + if comment.stickied: if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) @@ -776,7 +776,7 @@ def hole_log(v:User, sub): if kind: actions = actions.filter_by(kind=kind) actions = actions.order_by(SubAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all() - + next_exists=len(actions)>25 actions=actions[:25] mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()] diff --git a/files/routes/users.py b/files/routes/users.py index bf725226b..6d813db57 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -96,7 +96,7 @@ def upvoting_downvoting(v, username, uid, cls, vote_cls, vote_dir, template, sta listing = [p.id for p in listing] next_exists = len(listing) > PAGE_SIZE listing = listing[:PAGE_SIZE] - + if cls == Submission: listing = get_posts(listing, v=v, eager=True) elif cls == Comment: @@ -238,7 +238,7 @@ def all_upvoters_downvoters(v:User, username:str, vote_dir:int, is_who_simps_hat users = g.db.query(User).filter(User.id.in_(votes.keys())) if not v.can_see_shadowbanned: users = users.filter(User.shadowbanned == None) - + users2 = [(user, votes[user.id]) for user in users.all()] users = sorted(users2, key=lambda x: x[1], reverse=True) @@ -255,7 +255,7 @@ def all_upvoters_downvoters(v:User, username:str, vote_dir:int, is_who_simps_hat try: page = int(request.values.get("page", 1)) except: page = 1 - + users = users[PAGE_SIZE * (page-1):] next_exists = (len(users) > PAGE_SIZE) users = users[:PAGE_SIZE] @@ -340,7 +340,7 @@ def transfer_currency(v:User, username:str, currency_name:Literal['coins', 'mars send_repeatable_notification(receiver.id, notif_text) g.db.add(v) return {"message": f"{amount - tax} {currency_name} have been transferred to @{receiver.username}"} - + @app.post("/@/transfer_coins") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=lambda:f'{request.host}-{session.get("lo_user")}') @@ -445,7 +445,7 @@ def subscribe(v, post_id): new_sub = Subscription(user_id=v.id, submission_id=post_id) g.db.add(new_sub) return {"message": "Subscribed to post successfully!"} - + @app.post("/unsubscribe/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=lambda:f'{request.host}-{session.get("lo_user")}') @@ -629,7 +629,7 @@ def is_available(name:str): if len(name)<3 or len(name)>25: return {name:False} - + name2 = name.replace('\\', '').replace('_','\_').replace('%','') x = g.db.query(User).filter( @@ -648,7 +648,7 @@ def is_available(name:str): def user_id(id): user = get_account(id) return redirect(user.url) - + @app.get("/u/") @auth_required def redditor_moment_redirect(v:User, username:str): @@ -785,10 +785,10 @@ def u_username_wall(v:Optional[User], username:str): next_exists = (len(comments) > PAGE_SIZE) comments = comments[:PAGE_SIZE] - + if (v and v.client) or request.path.endswith(".json"): return {"data": [c.json(g.db) for c in comments]} - + return render_template("userpage/wall.html", u=u, v=v, listing=comments, page=page, next_exists=next_exists, is_following=is_following, standalone=True, render_replies=True, wall=True) @@ -837,12 +837,12 @@ def u_username_wall_comment(v:User, username:str, cid): c = c.parent_comment context -= 1 top_comment = c - + if v: # this is required because otherwise the vote and block # props won't save properly unless you put them in a list output = get_comments_v_properties(v, False, None, Comment.top_comment_id == c.top_comment_id)[1] - + if v and v.client: return top_comment.json(db=g.db) return render_template("userpage/wall.html", u=u, v=v, listing=[top_comment], page=1, is_following=is_following, standalone=True, render_replies=True, wall=True, comment_info=comment_info) @@ -899,7 +899,7 @@ def u_username(v:Optional[User], username:str): if u.unban_utc: if (v and v.client) or request.path.endswith(".json"): return {"data": [x.json(g.db) for x in listing]} - + return render_template("userpage/submissions.html", unban=u.unban_string, u=u, @@ -913,7 +913,7 @@ def u_username(v:Optional[User], username:str): if (v and v.client) or request.path.endswith(".json"): return {"data": [x.json(g.db) for x in listing]} - + return render_template("userpage/submissions.html", u=u, v=v, @@ -955,7 +955,7 @@ def u_username_comments(username, v=None): try: page = max(int(request.values.get("page", "1")), 1) except: page = 1 - + sort=request.values.get("sort","new") t=request.values.get("t","all") @@ -990,7 +990,7 @@ def u_username_comments(username, v=None): if (v and v.client) or request.path.endswith(".json"): return {"data": [c.json(g.db) for c in listing]} - + return render_template("userpage/comments.html", u=u, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True) @@ -1064,7 +1064,7 @@ def unfollow_user(username, v): if follow: g.db.delete(follow) - + g.db.flush() target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count() g.db.add(target) @@ -1087,7 +1087,7 @@ def remove_follow(username, v): if not follow: return {"message": f"@{target.username} has been removed as a follower!"} g.db.delete(follow) - + g.db.flush() v.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=v.id).count() g.db.add(v) @@ -1129,7 +1129,7 @@ def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone ids = ids[:PAGE_SIZE] extra = None - if not v.admin_level >= PERMS['POST_COMMENT_MODERATION']: + if not v.admin_level >= PERMS['POST_COMMENT_MODERATION']: extra = lambda q:q.filter(cls.is_banned == False, cls.deleted_utc == 0) if cls is Submission: @@ -1138,7 +1138,7 @@ def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone listing = get_comments(ids, v=v, extra=extra) else: raise TypeError("Only supports Submissions and Comments. This is probably the result of a bug with *this* function") - + if v.client: return {"data": [x.json(g.db) for x in listing]} return render_template(template, u=v, v=v, listing=listing, page=page, next_exists=next_exists, standalone=standalone) @@ -1183,7 +1183,7 @@ def fp(v:User, fp): if existing: continue add_alt(user1=v.id, user2=u.id) print(v.username + ' + ' + u.username, flush=True) - + check_for_alts(v) g.db.add(v) return '', 204 @@ -1282,13 +1282,13 @@ def settings_kofi(v:User): abort(400, f"You must have a verified email to verify {patron} status and claim your rewards!") transactions = g.db.query(Transaction).filter_by(email=v.email, claimed=None).all() - + if not transactions: abort(400, f"{patron} rewards already claimed") highest_tier = 0 marseybux = 0 - + for transaction in transactions: tier = kofi_tiers[transaction.amount] marseybux += marseybux_li[tier] diff --git a/files/routes/votes.py b/files/routes/votes.py index 9725d2062..3e0149989 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -87,7 +87,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): else: abort(400) existing = existing.one_or_none() - + if IS_FISTMAS(): coin_mult = 2 coin_value = coin_delta * coin_mult @@ -125,7 +125,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): real=real, coins=coin_value ) - elif vote_cls == CommentVote: + elif vote_cls == CommentVote: vote = CommentVote(user_id=v.id, vote_type=new, comment_id=target_id, diff --git a/files/routes/wrappers.py b/files/routes/wrappers.py index 37f923b03..12d3fb90f 100644 --- a/files/routes/wrappers.py +++ b/files/routes/wrappers.py @@ -18,7 +18,7 @@ def get_logged_in_user(): token = request.headers.get("Authorization","").strip() if token: client = g.db.query(ClientAuth).filter(ClientAuth.access_token == token).one_or_none() - if client: + if client: v = client.user v.client = client else: @@ -65,7 +65,7 @@ def get_logged_in_user(): if f'@{v.username}, ' not in f.read(): t = time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(time.time())) log_file(f'@{v.username}, {v.truescore}, {ip}, {t}\n', 'eg.log') - + g.is_api_or_xhr = bool((v and v.client) or request.headers.get("xhr")) return v diff --git a/files/templates/admin/app.html b/files/templates/admin/app.html index 296cabcc6..7db739490 100644 --- a/files/templates/admin/app.html +++ b/files/templates/admin/app.html @@ -29,7 +29,7 @@ {% if not app.client_id%} - + {% else %} diff --git a/files/templates/admin/apps.html b/files/templates/admin/apps.html index 8ae130ac7..43d7d7c1d 100644 --- a/files/templates/admin/apps.html +++ b/files/templates/admin/apps.html @@ -35,7 +35,7 @@ {% if not app.client_id %} - + {% else %} diff --git a/files/templates/admin/badge_admin.html b/files/templates/admin/badge_admin.html index 1f63d2fd6..1a6349938 100644 --- a/files/templates/admin/badge_admin.html +++ b/files/templates/admin/badge_admin.html @@ -33,7 +33,7 @@

-
+
Formatting help
diff --git a/files/templates/submit_hats.html b/files/templates/submit_hats.html index cff9b8fea..7bfd65605 100644 --- a/files/templates/submit_hats.html +++ b/files/templates/submit_hats.html @@ -41,7 +41,7 @@
- + @@ -60,7 +60,7 @@
- +
@@ -78,7 +78,7 @@ > - + diff --git a/files/templates/submit_marseys.html b/files/templates/submit_marseys.html index b76af9b08..98559c88b 100644 --- a/files/templates/submit_marseys.html +++ b/files/templates/submit_marseys.html @@ -36,7 +36,7 @@
- + @@ -55,10 +55,10 @@
- +
- +
@@ -67,7 +67,7 @@ - +
diff --git a/files/templates/update_assets.html b/files/templates/update_assets.html index b2b5dfb46..719efeec6 100644 --- a/files/templates/update_assets.html +++ b/files/templates/update_assets.html @@ -35,12 +35,12 @@
- + - + diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index 57d4a0810..a8a328a8b 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -73,7 +73,7 @@ {% endif %} - +
{% if v.admin_level >= PERMS['ADMIN_ADD'] %} diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index a93c806a0..30520ae88 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -60,7 +60,7 @@ {% if u.customtitle %}

{{u.customtitle | safe}}

{% endif %} - + {% if v and (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']) -%}
Profile Views | Simps | Haters | Simps For | Hates | Voted @@ -152,7 +152,7 @@
- +   @@ -182,16 +182,16 @@ {% if v and v.id == u.id %} Edit Profile {% endif %} - + {% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %} {% endif %} {% if v and v.id == u.id %} - +