diff --git a/files/classes/submission.py b/files/classes/submission.py index fb898fae76..681ba8d8e6 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -32,7 +32,6 @@ class Submission(Base): views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) - created_str = Column(String) stickied = Column(String) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) @@ -60,14 +59,6 @@ class Submission(Base): awards = relationship("AwardRelationship", viewonly=True) def __init__(self, *args, **kwargs): - - if "created_utc" not in kwargs: - kwargs["created_utc"] = int(time.time()) - kwargs["created_str"] = time.strftime( - "%I:%M %p on %d %b %Y", time.gmtime( - kwargs["created_utc"])) - - super().__init__(*args, **kwargs) def __repr__(self): diff --git a/files/helpers/const.py b/files/helpers/const.py index df8f5f9e1b..d8cf744b03 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -106,7 +106,7 @@ Thank you.""" WELCOME_MSG = "Hi there! It's me, your soon-to-be favorite rDrama user @carpathianflorist here to give you a brief rundown on some of the sick features we have here. You'll probably want to start by following me, though. So go ahead and click my name and then smash that Follow button. This is actually really important, so go on. Hurry.\n\nThanks!\n\nNext up: If you're a member of the media, similarly just shoot me a DM and I'll set about verifying you and then we can take care of your sad journalism stuff.\n\n**FOR EVERYONE ELSE**\n\n Begin by navigating to [the settings page](https://rdrama.net/settings/profile) (we'll be prettying this up so it's less convoluted soon, don't worry) and getting some basic customization done.\n\n### Themes\n\nDefinitely change your theme right away, the default one (Midnight) is pretty enough, but why not use something *exotic* like Win98, or *flashy* like Tron? Even Coffee is super tasteful and way more fun than the default. More themes to come when we get around to it!\n\n### Avatar/pfp\n\nYou'll want to set this pretty soon; without uploading one, I put together a randomly-assigned selection of 180ish pictures of furries, ugly goths, mujahideen, anime girls, and My Little Ponys which are used by everyone who was too lazy to set a pfp. Set the banner too while you're at it. Your profile is important!\n\n### Flairs\n\nSince you're already on the settings page, you may as well set a flair, too. As with your username, you can - obviously - choose the color of this, either with a hex value or just from the preset colors. And also like your username, you can change this at any time. [Paypigs](https://marsey1.gumroad.com/l/tfcvri) can even further relive the glory days of 90s-00s internet and set obnoxious signatures.\n\n### PROFILE ANTHEMS\n\nSpeaking of profiles, hey, remember MySpace? Do you miss autoplaying music assaulting your ears every time you visited a friend's page? Yeah, we brought that back. Enter a YouTube URL, wait a few seconds for it to process, and then BAM! you've got a profile anthem which people cannot mute. Unless they spend 20,000 dramacoin in the shop for a mute button. Which you can then remove from your profile by spending 40,000 dramacoin on an unmuteable anthem. Get fucked poors!\n\n### Dramacoin?\n\nDramacoin is basically our take on the karma system. Except unlike the karma system, it's not gay and boring and stupid and useless. Dramacoin can be spent at [Marsey's Dramacoin Emporium](https://rdrama.net/shop) on upgrades to your user experience (many more coming than what's already listed there), and best of all on tremendously annoying awards to fuck with your fellow dramautists. We're always adding more, so check back regularly in case you happen to miss one of the announcement posts. Holiday-themed awards are currently unavailable while we resolve an internal dispute, but they **will** return, no matter what some other janitors insist.\n\nLike karma, dramacoin is obtained by getting upvotes on your threads and comments. *Unlike* karma, it's also obtained by getting downvotes on your threads and comments. Downvotes don't really do anything here - they pay the same amount of dramacoin and they increase thread/comment ranking just the same as an upvote. You just use them to express petty disapproval and hopefully start a fight. Because all votes are visible here. To hell with your anonymity.\n\nDramacoin can also be traded amongst users from their profiles. Note that there is a 3% transaction fee.\n\n**Dramacoin and shop items cannot be purchased with real money and this will not change.** Though we are notoriously susceptible to bribes, so definitely shoot your shot. It'll probably go well, honestly.\n\n### Badges\n\nRemember all those neat little metallic icons you saw on my profile when you were following me? If not, scroll back up and go have a look. And doublecheck to make sure you pressed the Follow button. Anyway, those are badges. You earn them by doing a variety of things. Some of them even offer benefits, like discounts at the shop. A [complete list of badges and their requirements can be found here](https://rdrama.net/badges), though I add more pretty regularly, so keep an eye on the changelog.\n\n### Other stuff\n\nWe're always adding new features, and we take a fun-first approach to development. If you have a suggestion for something that would be fun, funny, annoying - or best of all, some combination of all three - definitely make a thread about it. Or just DM me if you're shy. Weirdo. Anyway there's also the [leaderboards](https://rdrama.net/leaderboard), boring stuff like two-factor authentication you can toggle on somewhere in the settings page (psycho), the ability to save posts and comments, close to a thousand emojis already (several hundred of which are rDrama originals), and on and on and on and on. This is just the basics, mostly to help you get acquainted with some of the things you can do here to make it more easy on the eyes, customizable, and enjoyable. If you don't enjoy it, just go away! We're not changing things to suit you! Get out of here loser! And no, you can't delete your account :na:\n\nI love you.
*xoxo Carp* 💋" -if SITE == 'rdrama.net': +if 'rdrama.net' in SITE: BASEDBOT_ID = 0 KIPPY_ID = 7150 NOTIFICATIONS_ID = 1046 diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index a029b7ce35..29d7ea1f18 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -46,6 +46,9 @@ def auth_desired(f): def wrapper(*args, **kwargs): v = get_logged_in_user() + + if request.host == 'old.rdrama.net' and not (v and v.admin_level): abort(403) + check_ban_evade(v) resp = make_response(f(*args, v=v, **kwargs)) @@ -63,6 +66,8 @@ def auth_required(f): if not v: abort(401) + if request.host == 'old.rdrama.net' and not v.admin_level: abort(403) + check_ban_evade(v) g.v = v @@ -82,6 +87,8 @@ def is_not_banned(f): if not v: abort(401) + if request.host == 'old.rdrama.net' and not v.admin_level: abort(403) + check_ban_evade(v) if v.is_suspended: return {"error": "You can't perform this action while being banned."}, 403 diff --git a/files/routes/admin.py b/files/routes/admin.py index 843324f44f..9ed0134812 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -987,7 +987,7 @@ def api_sticky_post(post_id, v): @app.post("/ban_comment/") @limiter.limit("1/second") -@admin_level_required(1) +@admin_level_required(2) @validate_formkey def api_ban_comment(c_id, v): @@ -1012,7 +1012,7 @@ def api_ban_comment(c_id, v): @app.post("/unban_comment/") @limiter.limit("1/second") -@admin_level_required(1) +@admin_level_required(2) @validate_formkey def api_unban_comment(c_id, v): diff --git a/files/routes/comments.py b/files/routes/comments.py index 995d4eccc4..236f279ee5 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -194,7 +194,7 @@ def api_comment(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) body += f"\n\n![]({url})" @@ -724,7 +724,7 @@ def edit_comment(cid, v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) body += f"\n\n![]({url})" body_md = CustomRenderer().render(mistletoe.Document(body)) diff --git a/files/routes/posts.py b/files/routes/posts.py index 94ab8362e4..1181a0db6f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -53,6 +53,7 @@ def publish(pid, v): post = get_post(pid) if not post.author_id == v.id: abort(403) post.private = False + post.created_utc = int(time.time()) g.db.add(post) notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id) @@ -97,7 +98,7 @@ def post_id(pid, anything=None, v=None): try: pid = int(pid) except Exception as e: pass - if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new' + if 'rdrama.net' in request.host and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new' elif v: defaultsortingcomments = v.defaultsortingcomments else: defaultsortingcomments = "top" @@ -424,7 +425,7 @@ def edit_post(pid, v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) body += f"\n\n![]({url})" @@ -918,7 +919,7 @@ def submit_post(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) body += f"\n\n![]({url})" @@ -958,7 +959,8 @@ def submit_post(v): body_html=body_html, embed_url=embed, title=title[:500], - title_html=title_html + title_html=title_html, + created_utc=int(time.time()) ) g.db.add(new_post) @@ -1017,7 +1019,7 @@ def submit_post(v): if file.content_type.startswith('image/'): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - new_post.url = request.host_url + process_image(name) + new_post.url = request.host_url[:-1] + process_image(name) elif file.content_type.startswith('video/'): file.save("video.mp4") diff --git a/files/routes/settings.py b/files/routes/settings.py index 7fff7f0903..cd668a8d83 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -130,7 +130,7 @@ def settings_profile_post(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) bio += f"\n\n![]({url})" @@ -320,7 +320,7 @@ def settings_profile_post(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = request.host_url + process_image(name) + url = request.host_url[:-1] + process_image(name) bio += f"\n\n![]({url})" @@ -726,7 +726,7 @@ def settings_images_profile(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - highres = request.host_url + process_image(name) + highres = request.host_url[:-1] + process_image(name) if not highres: abort(400) @@ -762,7 +762,7 @@ def settings_images_banner(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - bannerurl = request.host_url + process_image(name) + bannerurl = request.host_url[:-1] + process_image(name) if bannerurl: if v.bannerurl and '/images/' in v.bannerurl : os.remove('/images/' + v.bannerurl.split('/images/')[1]) diff --git a/files/routes/users.py b/files/routes/users.py index 26f268ca85..71b6e132d3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -209,13 +209,13 @@ def transfer_coins(v, username): if not v.patron and not receiver.patron: tax = math.ceil(amount*0.03) tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first() - if request.host == 'rdrama.net': tax_receiver.coins += tax/3 + if 'rdrama.net' in request.host: tax_receiver.coins += tax/3 else: tax_receiver.coins += tax log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})" send_notification(TAX_RECEIVER_ID, log_message) g.db.add(tax_receiver) - if request.host == 'rdrama.net': + if 'rdrama.net' in request.host: carp = g.db.query(User).filter_by(id=CARP_ID).first() carp.coins += tax/3 log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})" @@ -493,7 +493,7 @@ def redditor_moment_redirect(username): @auth_required def followers(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) + # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() return render_template("followers.html", v=v, u=u, users=users) @@ -502,7 +502,7 @@ def followers(username, v): @auth_required def following(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) + # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() return render_template("following.html", v=v, u=u, users=users) @@ -510,7 +510,7 @@ def following(username, v): @app.get("/views") @auth_required def visitors(v): - if request.host == 'rdrama.net' and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v) + if 'rdrama.net' in request.host and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v) viewers=sorted(v.viewers, key = lambda x: x.last_view_utc, reverse=True) return render_template("viewers.html", v=v, viewers=viewers) diff --git a/files/templates/comments.html b/files/templates/comments.html index 7ad4ab6993..0e9a09b03b 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -558,4 +558,4 @@ .comment.collapsed .invisible-on-collapse { visibility: hidden; } - \ No newline at end of file + diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index f75fa626ee..7a89f36c12 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -81,4 +81,4 @@ {% endif %} - \ No newline at end of file + diff --git a/files/templates/report_post_modal.html b/files/templates/report_post_modal.html index 04653e078b..c0657c6fd8 100644 --- a/files/templates/report_post_modal.html +++ b/files/templates/report_post_modal.html @@ -37,4 +37,4 @@ - \ No newline at end of file + diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index a1a28d21a5..f682cc5927 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -396,4 +396,4 @@ background: -webkit-linear-gradient(left, red, orange, yellow, green, blue, indigo, violet ); text-shadow:-1px -1px 0 black,1px -1px 0 black,-1px 1px 0 black,1px 1px 0 black; } - \ No newline at end of file + diff --git a/schema.sql b/schema.sql index 61b39ebe54..20a46a1af4 100644 --- a/schema.sql +++ b/schema.sql @@ -560,7 +560,6 @@ CREATE TABLE public.submissions ( is_banned boolean, over_18 boolean, distinguish_level integer, - created_str character varying(255), deleted_utc integer NOT NULL, domain_ref integer, is_approved integer NOT NULL,