diff --git a/.gitignore b/.gitignore index 2f844f36d..049e87560 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ cache/ __pycache__/ *.py[cod] *$py.class -chart.png +chart.webp # C extensions *.so diff --git a/files/classes/award.py b/files/classes/award.py index c8a9c8e29..8f8c8206e 100644 --- a/files/classes/award.py +++ b/files/classes/award.py @@ -24,9 +24,9 @@ if site_name == "Drama": "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -43,9 +43,9 @@ else: "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", diff --git a/files/classes/user.py b/files/classes/user.py index 07004aa89..a370bee66 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -41,9 +41,9 @@ if site_name == "Drama": "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -60,9 +60,9 @@ else: "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -459,16 +459,11 @@ class User(Base): if self.bannerurl: return self.bannerurl else: return f"https://{site}/assets/images/{site_name}/preview.webp" - @cache.memoize(timeout=3600) - def defaultpicture(self): - pic = random.randint(1, 150) - return f"https://{site}/assets/images/defaultpictures/{pic}.webp" - @property @lazy def profile_url(self): if self.profileurl: return self.profileurl - elif "rdrama" in site: return self.defaultpicture() + elif "rdrama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp" else: return f"https://{site}/assets/images/default-profile-pic.webp" @property diff --git a/files/routes/admin.py b/files/routes/admin.py index 6f829d2b5..e838dda54 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -164,21 +164,21 @@ def monthly(v): if u.patron == 1: grant_awards["shit"] = 1 - grant_awards["stars"] = 1 + grant_awards["fireflies"] = 1 elif u.patron == 2: grant_awards["shit"] = 3 - grant_awards["stars"] = 3 + grant_awards["fireflies"] = 3 elif u.patron == 3: grant_awards["shit"] = 5 - grant_awards["stars"] = 5 + grant_awards["fireflies"] = 5 grant_awards["ban"] = 1 elif u.patron == 4: grant_awards["shit"] = 10 - grant_awards["stars"] = 10 + grant_awards["fireflies"] = 10 grant_awards["ban"] = 3 elif u.patron == 5 or u.patron == 8: grant_awards["shit"] = 20 - grant_awards["stars"] = 20 + grant_awards["fireflies"] = 20 grant_awards["ban"] = 6 @@ -402,25 +402,25 @@ def badge_grant_post(v): if badge_id == 21: if user.discord_id: add_role(user, "1") grant_awards["shit"] = 1 - grant_awards["stars"] = 1 + grant_awards["fireflies"] = 1 elif badge_id == 22: if user.discord_id: add_role(user, "2") grant_awards["shit"] = 3 - grant_awards["stars"] = 3 + grant_awards["fireflies"] = 3 elif badge_id == 23: if user.discord_id: add_role(user, "3") grant_awards["shit"] = 5 - grant_awards["stars"] = 5 + grant_awards["fireflies"] = 5 grant_awards["ban"] = 1 elif badge_id in [24, 28]: if user.discord_id: add_role(user, "4") grant_awards["shit"] = 10 - grant_awards["stars"] = 10 + grant_awards["fireflies"] = 10 grant_awards["ban"] = 3 elif badge_id == 25: if user.discord_id: add_role(user, "5") grant_awards["shit"] = 20 - grant_awards["stars"] = 20 + grant_awards["fireflies"] = 20 grant_awards["ban"] = 6 if len(grant_awards): @@ -631,20 +631,6 @@ def admin_removed(v): ) -@app.post("/admin/image_purge") -@admin_level_required(5) -def admin_image_purge(v): - - name = request.values.get("url") - image = g.db.query(Image).options(lazyload('*')).filter(Image.text == name).first() - if image: - requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}) - headers = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"} - data = {'files': [name]} - url = f"https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache" - requests.post(url, headers=headers, json=data) - return redirect("/admin/image_purge") - @app.post("/admin/image_ban") @admin_level_required(4) @@ -1330,6 +1316,6 @@ def chart(v): posts_chart.legend(loc='upper left', frameon=True) comments_chart.legend(loc='upper left', frameon=True) - plt.savefig("chart.png") + plt.savefig("chart.webp") plt.clf() - return send_file("../chart.png") \ No newline at end of file + return send_file("../chart.webp") \ No newline at end of file diff --git a/files/routes/awards.py b/files/routes/awards.py index 2f7c224e6..567031c51 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -28,9 +28,9 @@ def shop(v): "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -47,9 +47,9 @@ def shop(v): "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -105,9 +105,9 @@ def buy(v, award): "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -124,9 +124,9 @@ def buy(v, award): "color": "text-black-50", "price": 1000 }, - "stars": { - "kind": "stars", - "title": "Stars", + "fireflies": { + "kind": "fireflies", + "title": "fireflies", "description": "Puts stars on the post.", "icon": "fas fa-sparkles", "color": "text-warning", @@ -181,7 +181,7 @@ ACTIONS = { ALLOW_MULTIPLE = ( "ban", "shit", - "stars" + "fireflies" ) @app.post("/post//awards") diff --git a/files/routes/posts.py b/files/routes/posts.py index b592df802..bc513325e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -63,6 +63,10 @@ def publish(pid, v): cache.delete_memoized(frontlist) + for follow in v.followers: + user = get_account(follow.user_id) + send_notification(AUTOJANNY_ACCOUNT, user, f"@{v.username} has made a new post: [{post.title}](https://{site}{post.permalink})") + g.db.commit() return {"message": "Post published!"} @@ -616,10 +620,6 @@ def submit_post(v): if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/") - if "i.imgur.com" in url and "_d." not in url: - url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") - if "_d." in url: url += "?maxwidth=9999" - repost = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter( SubmissionAux.url.ilike(url), Submission.deleted_utc == 0, diff --git a/files/routes/settings.py b/files/routes/settings.py index d8112d515..1e0bdad7d 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -318,25 +318,25 @@ def gumroad(v): if tier == 1: if v.discord_id: add_role(v, "1") grant_awards["shit"] = 1 - grant_awards["stars"] = 1 + grant_awards["fireflies"] = 1 elif tier == 2: if v.discord_id: add_role(v, "2") grant_awards["shit"] = 3 - grant_awards["stars"] = 3 + grant_awards["fireflies"] = 3 elif tier == 3: if v.discord_id: add_role(v, "3") grant_awards["shit"] = 5 - grant_awards["stars"] = 5 + grant_awards["fireflies"] = 5 grant_awards["ban"] = 1 elif tier == 4: if v.discord_id: add_role(v, "4") grant_awards["shit"] = 10 - grant_awards["stars"] = 10 + grant_awards["fireflies"] = 10 grant_awards["ban"] = 3 elif tier == 5 or tier == 8: if v.discord_id: add_role(v, "5") grant_awards["shit"] = 20 - grant_awards["stars"] = 20 + grant_awards["fireflies"] = 20 grant_awards["ban"] = 6 thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index 97f3679f7..a2373e269 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -23,7 +23,6 @@ #### Safety * [Banned Domains](/admin/banned_domains) -* [Remove image from imgur and from cloudflare cache](/admin/image_purge) * [Perceptive Hash Image Ban](/admin/image_ban) * [Multi Vote Analysis](/admin/alt_votes) diff --git a/files/templates/admin/image_purge.html b/files/templates/admin/image_purge.html deleted file mode 100644 index bb1604805..000000000 --- a/files/templates/admin/image_purge.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -Purge Image - -{% endblock %} - -{% block content %} -

Imgur and Cloudflare Image Purge

-

Paste an image link here to remove it from imgur and from cloudflare cache. You need to enter the full url of the image like this "https://i.imgur.com/63OclpM_d.png?maxwidth=9999"

- -
- - - -
- - -{% endblock %} \ No newline at end of file diff --git a/files/templates/email/2fa_remove.html b/files/templates/email/2fa_remove.html index 34cffae45..850ea1d76 100644 --- a/files/templates/email/2fa_remove.html +++ b/files/templates/email/2fa_remove.html @@ -1,37 +1,37 @@ {% extends "email/default.html" %} -{% block image %}verify.png{% endblock %} +{% block image %}verify.webp{% endblock %} {% block title %}Remove Two-Factor Authentication{% endblock %} {% block preheader %}Remove Two-Factor Authentication.{% endblock %} {% block content %} -

We received a request to remove two-factor authentication from your account. In 72 hours, click the link below.

-

If you didn't make this request, change your password and use the Log Out Everywhere feature in your Security Settings to permanently invalidate the link.

- - - - - - -

Please note that {{'SITE_NAME' | app_config}} will never ask you for your email, password, or two-factor token via email, text, or phone.

- - - - - +

We received a request to remove two-factor authentication from your account. In 72 hours, click the link below.

+

If you didn't make this request, change your password and use the Log Out Everywhere feature in your Security Settings to permanently invalidate the link.

+ + + + + + +

Please note that {{'SITE_NAME' | app_config}} will never ask you for your email, password, or two-factor token via email, text, or phone.

+ + + + + {% endblock %} diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index 3f3e44d77..2bc3342a0 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -9,7 +9,7 @@
- {% if v %} - {% else %} - {% if v and v.id==p.author_id %} {% if p.private %} - + {% endif %} @@ -119,21 +119,21 @@ {% endif %} {% endif %} - + {% if v and v.id!=p.author_id %} {% endif %} {% if v %} - + - + {% endif %} {% if v %} - - + + {% if v.admin_level >=3 or v.id == p.author.id and v.paid_dues %} @@ -158,7 +158,7 @@ {% endif %} {% if v.admin_level >=4 and p.oauth_app %} - + {% endif %} {% endif %} @@ -179,8 +179,8 @@ {% endif %} {% if v and v.admin_level == 6 and v.id!=p.author_id %} - - + + {% endif %}
@@ -207,13 +207,13 @@ {% endif %} -{% if p.award_count("stars") %} - - {% set minbugs = 10*p.award_count("stars") if p.award_count("stars") <= 5 else 50 %} - {% set maxbugs = 20*p.award_count("stars") if p.award_count("stars") <= 5 else 100 %} +{% if p.award_count("fireflies") %} + + {% set minbugs = 10*p.award_count("fireflies") if p.award_count("fireflies") <= 5 else 50 %} + {% set maxbugs = 20*p.award_count("fireflies") if p.award_count("fireflies") <= 5 else 100 %}