diff --git a/docker-compose.yml b/docker-compose.yml index e823967f1..4ab8a4343 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,6 +45,7 @@ services: - GUMROAD_TOKEN=3435tdfsdudebussylmaoxxt43 - GUMROAD_LINK=https://marsey1.gumroad.com/l/tfcvri - CARD_VIEW=1 + - DISABLE_DOWNVOTES=0 links: - "redis" - "postgres" @@ -56,7 +57,9 @@ services: redis: image: redis - command: redis-server --pidfile /redis_6379.pid --dbfilename dump.rdb --dir ./ + command: redis-server /drama/redis.conf + volumes: + - ./redis.conf:/drama/redis.conf ports: - "6379:6379" diff --git a/env b/env new file mode 100644 index 000000000..1e7849c8a --- /dev/null +++ b/env @@ -0,0 +1,38 @@ +export PYTHONPATH="/service" +export REDIS_URL="redis://redis" +export DATABASE_URL="postgresql://postgres@postgres:5432/postgres" +export DATABASE_CONNECTION_POOL_URL="postgresql://postgres@postgres:5432/postgres" +export MASTER_KEY="-KTVciAUQFpFh2WdJ/oiHJlxl6FvzRZp8kYzAAv3l2OA=" +export DOMAIN="localhost" +export SITE_NAME="Drama" +export CLOUDFLARE_ZONE="3435tdfsdudebussylmaoxxt43" +export CLOUDFLARE_KEY="3435tdfsdudebussylmaoxxt43" +export GIPHY_KEY="3435tdfsdudebussylmaoxxt43" +export MAILGUN_KEY="3435tdfsdudebussylmaoxxt43" +export MAILGUN_DOMAIN="rdrama.net" +export FORCE_HTTPS="0" +export DISCORD_SERVER_ID="3435tdfsdudebussylmaoxxt43" +export DISCORD_CLIENT_ID="3435tdfsdudebussylmaoxxt43" +export DISCORD_CLIENT_SECRET="3435tdfsdudebussylmaoxxt43" +export DISCORD_BOT_TOKEN="3435tdfsdudebussylmaoxxt43" +export IMGUR_KEY="3435tdfsdudebussylmaoxxt43" +export IBB_KEY="3435tdfsdudebussylmaoxxt43" +export HCAPTCHA_SECRET="3435tdfsdudebussylmaoxxt43" +export YOUTUBE_KEY="3435tdfsdudebussylmaoxxt43" +export PUSHER_KEY="3435tdfsdudebussylmaoxxt43" +export SPAM_SIMILARITY_THRESHOLD="0.5" +export SPAM_SIMILAR_COUNT_THRESHOLD="5" +export SPAM_URL_SIMILARITY_THRESHOLD="0.1" +export COMMENT_SPAM_SIMILAR_THRESHOLD="0.5" +export COMMENT_SPAM_COUNT_THRESHOLD="5" +export READ_ONLY="0" +export BOT_DISABLE="0" +export COINS_NAME="Dramacoins" +export DEFAULT_TIME_FILTER="all" +export DEFAULT_THEME="dark" +export DEFAULT_COLOR="ff66ac #YOU HAVE TO PICK ONE OF THOSE COLORS OR SHIT WILL BREAK: ff66ac, 805ad5, 62ca56, 38a169, 80ffff, 2a96f3, eb4963, ff0000, f39731, 30409f, 3e98a7, e4432d, 7b9ae4, ec72de, 7f8fa6, f8db58" +export SLOGAN="Dude bussy lmao" +export GUMROAD_TOKEN="3435tdfsdudebussylmaoxxt43" +export GUMROAD_LINK="https://marsey1.gumroad.com/l/tfcvri" +export CARD_VIEW="1" +export DISABLE_DOWNVOTES="0" \ No newline at end of file diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 45341872b..7f9401f41 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -286,12 +286,6 @@ ACTIONTYPES={ "color": "bg-danger", "title": 'removed admin @{self.target_user.username}' }, - "dethrone_self":{ - "str":'stepped down as guildmaster', - "icon":"fa-user-crown", - "color": "bg-danger", - "title": 'stepped down as guildmaster' - }, "add_mod":{ "str":'added admin {self.target_link}', "icon":"fa-user-crown", @@ -369,11 +363,5 @@ ACTIONTYPES={ "icon":"fa-user-cog", "color": "bg-muted", "title": "changed permissions on invitation to {self.target_user.username}" - }, - "create_guild":{ - "str": 'created +{self.board.name}', - "icon": "fa-chess-rook", - "color": "bg-primary", - "title": "created +{self.board.name}" } } \ No newline at end of file diff --git a/files/classes/user.py b/files/classes/user.py index 5fefc9e55..e35389fc4 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -52,6 +52,7 @@ class User(Base, Stndrd, Age_times): passhash = deferred(Column(String)) post_count = Column(Integer, default=0) comment_count = Column(Integer, default=0) + received_award_count = Column(Integer, default=0) created_utc = Column(Integer, default=0) suicide_utc = Column(Integer, default=0) rent_utc = Column(Integer, default=0) @@ -66,6 +67,7 @@ class User(Base, Stndrd, Age_times): shadowbanned = Column(Boolean, default=False) over_18 = Column(Boolean, default=False) hidevotedon = Column(Boolean, default=False) + highlightcomments = Column(Boolean, default=True) slurreplacer = Column(Boolean, default=True) flairchanged = Column(Boolean, default=False) newtab = Column(Boolean, default=False) @@ -353,18 +355,6 @@ class User(Base, Stndrd, Age_times): return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True) - @property - @lazy - def received_awards_num(self): - - posts_idlist = g.db.query(Submission.id).filter_by(author_id=self.id).subquery() - comments_idlist = g.db.query(Comment.id).filter_by(author_id=self.id).subquery() - - post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).count() - comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).count() - - return post_awards + comment_awards - @property @lazy def post_notifications_count(self): diff --git a/files/helpers/const.py b/files/helpers/const.py index 5f5ac1936..093c1c0af 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1,12 +1,12 @@ from os import environ SLURS = { - " fag":" cute twink", - " Fag":" Cute twink", - " FAG":" CUTE TWINK", " faggot":" cute twink", " Faggot":" Cute twink", " FAGGOT":" CUTE TWINK", + " fag":" cute twink", + " Fag":" Cute twink", + " FAG":" CUTE TWINK", " kill yourself":" keep yourself safe", " KILL YOURSELF":" KEEP YOURSELF SAFE", " nigger":" 🏀", @@ -33,12 +33,12 @@ SLURS = { " TROON":" 🚂🚃🚃", " NoNewNormal": "HorseDewormerAddicts", " nonewnormal": "horsedewormeraddicts", - "fag ":"cute twink ", - "Fag ":"Cute twink ", - "FAG ":"CUTE TWINK ", "faggot ":"cute twink ", "Faggot ":"Cute twink ", "FAGGOT ":"CUTE TWINK ", + "fag ":"cute twink ", + "Fag ":"Cute twink ", + "FAG ":"CUTE TWINK ", "kill yourself ":"keep yourself safe ", "KILL YOURSELF ":"KEEP YOURSELF SAFE ", "nigger ":"🏀 ", @@ -69,14 +69,14 @@ SLURS = { LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him,", '![](https://i.kym-cdn.com/photos/images/newsfeed/001/038/094/0a1.jpg)', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!'] -AGENDAPOSTER_MSG = """Hi {username},\n\nYour comment has been automatically removed because you forgot +AGENDAPOSTER_MSG = """Hi @{username},\n\nYour comment has been automatically removed because you forgot to include `trans lives matter`.\n\nDon't worry, we're here to help! We won't let you post or comment anything that doesn't express your love and acceptance towards the trans community. Feel free to resubmit your comment with `trans lives matter` included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" -VAXX_MSG = """Hi {username}, it appears that you may be trying to spread dangerous misinformation regarding ineffective COVID-19 treatments based on pseudoscientific hearsay. Your post has been removed because it contained the word ivermectin. We ask that you understand that horse dewormer neither treats, nor prevents, COVID-19. For more information, please read up on what the FDA has to say on the matter: +VAXX_MSG = """Hi @{username}, it appears that you may be trying to spread dangerous misinformation regarding ineffective COVID-19 treatments based on pseudoscientific hearsay. Your post has been removed because it contained the word ivermectin. We ask that you understand that horse dewormer neither treats, nor prevents, COVID-19. For more information, please read up on what the FDA has to say on the matter: https://www.fda.gov/consumers/consumer-updates/why-you-should-not-use-ivermectin-treat-or-prevent-covid-19 diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 16586fa77..414c091e1 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -22,6 +22,14 @@ def post_embed(id, v): return render_template("submission_listing.html", listing=[p], v=v) +@app.template_filter("favorite_emojis") +def favorite_emojis(x): + str = "" + emojis = sorted(x.items(), key=lambda x: x[1], reverse=True)[:25] + for k, v in emojis: + str += f'' + return str + @app.context_processor def inject_constants(): constants = [c for c in dir(const) if not c.startswith("_")] diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index f97463828..c2e9c2924 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -209,16 +209,26 @@ def sanitize(sanitized, noimages=False): start = '<s>' end = '</s>' + + if not session.get("favorite_emojis"): session["favorite_emojis"] = {} + if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '').replace(end, '') for i in re.finditer('

:([^ ]{1,30}?):

', sanitized): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f'

:{i.group(1)}:

', f'

') + if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1 + else: session["favorite_emojis"][i.group(1)] = 1 + for i in re.finditer(':([^ ]{1,30}?):', sanitized): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f':{i.group(1)}:', f'') + if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1 + else: session["favorite_emojis"][i.group(1)] = 1 + + sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.", "https://").replace("https://m.", "https://") for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)', sanitized): diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index eaccee9ea..546505b0e 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -23,7 +23,10 @@ def get_logged_in_user(): uid = session.get("user_id") nonce = session.get("login_nonce", 0) if not uid: x= (None, None) - v = g.db.query(User).filter_by(id=uid).first() + try: + if g.db: v = g.db.query(User).filter_by(id=uid).first() + else: v = None + except: v = None if v and v.agendaposter_expires_utc and v.agendaposter_expires_utc < g.timestamp: v.agendaposter_expires_utc = 0 @@ -59,6 +62,8 @@ def check_ban_evade(v): post.ban_reason="ban evasion" g.db.add(post) + g.db.commit() + ma=ModAction( kind="ban_post", user_id=AUTOJANNY_ACCOUNT, diff --git a/files/routes/admin.py b/files/routes/admin.py index 30ac2dfbc..bac91253b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -22,12 +22,6 @@ from files.helpers.discord import add_role IMGUR_KEY = environ.get("IMGUR_KEY", "").strip() -@app.get("/imgurcredits") -@admin_level_required(6) -def imgurcredits(v): - req = requests.get('https://api.imgur.com/3/credits', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}).json() - return req - @app.post("/@/make_admin") @admin_level_required(6) def make_admin(v, username): @@ -38,6 +32,16 @@ def make_admin(v, username): return "", 204 +@app.post("/@/make_fake_admin") +@admin_level_required(6) +def make_fake_admin(v, username): + user = get_user(username) + if not user: abort(404) + user.admin_level = 1 + g.db.add(user) + return "", 204 + + @app.post("/@/remove_admin") @admin_level_required(6) def remove_admin(v, username): @@ -650,6 +654,24 @@ def unshadowban(user_id, v): return "", 204 +@app.post("/admin/verify/") +@admin_level_required(6) +@validate_formkey +def verify(user_id, v): + user = g.db.query(User).filter_by(id=user_id).first() + user.verified = "Verified" + g.db.add(user) + return "", 204 + +@app.post("/admin/unverify/") +@admin_level_required(6) +@validate_formkey +def unverify(user_id, v): + user = g.db.query(User).filter_by(id=user_id).first() + user.verified = None + g.db.add(user) + return "", 204 + @app.post("/admin/title_change/") @admin_level_required(6) @@ -1189,4 +1211,4 @@ def multiple_plots(**kwargs): plt.savefig("image.png") plt.clf() - return upload_imgur(png=True) \ No newline at end of file + return upload_imgur(png=True) diff --git a/files/routes/awards.py b/files/routes/awards.py index 512072e81..fcb1e77e4 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -106,6 +106,9 @@ def award_post(pid, v): if kind in ACTIONS: ACTIONS[kind](post=post) + post.author.received_award_count += 1 + g.db.add(post.author) + return "", 204 @@ -167,6 +170,9 @@ def award_comment(cid, v): if kind in ACTIONS: ACTIONS[kind](comment=c) + c.author.received_award_count += 1 + g.db.add(c.author) + return "", 204 @app.get("/admin/user_award") diff --git a/files/routes/posts.py b/files/routes/posts.py index e7b62b403..b07b62388 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -665,7 +665,8 @@ def submit_post(v): except: embed = None elif "youtu" in domain: - yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) + try: yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) + except: embed = None if not yt_id or len(yt_id) != 11: embed = None else: params = parse_qs(urlparse(url).query) @@ -1032,7 +1033,7 @@ def submit_post(v): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - if "rdrama" in request.host or (new_post.url and not "weebzone" in request.host): + if "rdrama" in request.host or (new_post.url and not "weebzone" in request.host and not "marsey.tech" in request.host): c = Comment(author_id=261, distinguish_level=6, parent_submission=new_post.id, diff --git a/files/routes/settings.py b/files/routes/settings.py index d7e3faaff..c579774cc 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -62,6 +62,10 @@ def settings_profile_post(v): updated = True v.cardview = request.values.get("cardview", None) == 'true' + if request.values.get("highlightcomments", v.highlightcomments) != v.highlightcomments: + updated = True + v.highlightcomments = request.values.get("highlightcomments", None) == 'true' + if request.values.get("newtab", v.newtab) != v.newtab: updated = True v.newtab = request.values.get("newtab", None) == 'true' diff --git a/files/routes/users.py b/files/routes/users.py index dffedb955..c38b3d857 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -140,24 +140,11 @@ def leaderboard(v): users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all() users3 = users.order_by(User.post_count.desc()).limit(10).all() users4 = users.order_by(User.comment_count.desc()).limit(10).all() + users5 = users.order_by(User.received_award_count.desc()).limit(10).all() if "pcm" in request.host: - users5 = users.order_by(User.basedcount.desc()).limit(10).all() - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5) - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4) - - -@app.get("/award_leaderboard") -@auth_desired -def award_leaderboard(v): - return render_template("award_leaderboard.html", v=v, users=a_leaderboard()) - - -@cache.memoize(timeout=86400) -def a_leaderboard(): - users = g.db.query(User).options(lazyload('*')).all() - users = sorted(users, key=lambda x: x.received_awards_num, reverse=True)[:10] - return users - + users6 = users.order_by(User.basedcount.desc()).limit(10).all() + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6) + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5) @app.get("/@/css") def get_css(username): diff --git a/files/templates/award_leaderboard.html b/files/templates/award_leaderboard.html deleted file mode 100644 index 3846340a4..000000000 --- a/files/templates/award_leaderboard.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "settings2.html" %} - -{% block pagetitle %}Leaderboard - awards received{% endblock %} - -{% block content %} -


-
Top 10 by awards received
-

-
-
-	
-		
-		
-		
-	
-
-{% for user in users %}
-	
-		
-		
-		
-	
-{% endfor %}
-
#NameAwards
{{users.index(user)+1}}{{user.username}}{{user.received_awards_num}}
-
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index 7a72bce64..adaa7aef8 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -116,7 +116,7 @@
- {% if last_view_utc and c.created_utc > last_view_utc and not (v and v.id==c.author_id) %}{% endif %} + {% if last_view_utc and c.created_utc > last_view_utc and not (v and v.id==c.author_id) and (not v or v.highlightcomments) %}{% endif %} {% if c.awards %} {% for a in c.awards[:5] %} @@ -255,12 +255,12 @@ {% endif %} {% elif v %} -
  • +
  • {% else %} -
  • +
  • {% endif %} @@ -305,7 +305,7 @@ {% endif %} {% if v and v.admin_level==6 and v.id==c.author_id %} -
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • +
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • {% endif %} @@ -355,9 +355,9 @@
  • {% endif %} {% elif v %} -
  • +
  • {% else %} -
  • +
  • {% endif %}
    @@ -463,7 +463,7 @@ {% if v %} {% if v.admin_level>=1 and v.id==c.author_id %} -
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • +
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • {% endif %} {% if v.admin_level>=3 %}
  • Approve
  • diff --git a/files/templates/default.html b/files/templates/default.html index 7806aa247..97f069014 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -1064,9 +1064,9 @@ - + - +{% if "marsey.tech" not in request.host %}{% endif %} {% include "header.html" %} @@ -1161,7 +1161,7 @@ {% include "expanded_image_modal.html" %} - + diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 3054e8047..b16000ea1 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -1,4 +1,5 @@ +