also show over_18 emojis to ppl who went through a nsfw warning in the past hour

pull/211/head
Aevann 2023-10-04 16:45:13 +03:00
parent 7665e74262
commit dc7970db23
6 changed files with 10 additions and 7 deletions

View File

@ -316,7 +316,7 @@ class Comment(Base):
@lazy
def emoji_award_emojis(self, v, OVER_18_EMOJIS):
if v and v.over_18:
if g.show_over_18:
return [x.note for x in self.awards if x.kind == "emoji"]
return [x.note for x in self.awards if x.kind == "emoji" and x.note not in OVER_18_EMOJIS]
@ -429,7 +429,8 @@ class Comment(Base):
if comment_info: return False
if self.over_18 and not (v and v.over_18) and not (any(path.startswith(x) for x in ('/post/','/comment/','/h/')) and self.post.over_18): return True
if self.over_18 and not (any(path.startswith(x) for x in ('/post/','/comment/','/h/')) and self.post.over_18) and not g.show_over_18:
return True
if self.is_banned: return True

View File

@ -264,7 +264,7 @@ class Post(Base):
@lazy
def emoji_award_emojis(self, v, OVER_18_EMOJIS):
if v and v.over_18:
if g.show_over_18:
return [x.note for x in self.awards if x.kind == "emoji"]
return [x.note for x in self.awards if x.kind == "emoji" and x.note not in OVER_18_EMOJIS]

View File

@ -62,7 +62,7 @@ def post_pid_comment_cid(cid, v, pid=None, anything=None, sub=None):
post = get_post(post, v=v)
if not (v and v.client) and post.over_18 and not (v and v.over_18) and not session.get('over_18_cookies', 0) >= int(time.time()):
if not (v and v.client) and post.over_18 and not g.show_over_18:
return render_template("errors/nsfw.html", v=v), 403
try: context = min(int(request.values.get("context", 8)), 8)

View File

@ -101,7 +101,7 @@ def post_id(pid, v, anything=None, sub=None):
p = get_post(pid, v=v)
if not User.can_see(v, p): abort(403)
if not g.is_api_or_xhr and p.over_18 and not (v and v.over_18) and session.get('over_18_cookies', 0) < int(time.time()):
if not g.is_api_or_xhr and p.over_18 and not g.show_over_18:
return render_template("errors/nsfw.html", v=v)
gevent.spawn(_add_post_view, pid)

View File

@ -65,7 +65,7 @@ def marseys_redirect():
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def emoji_list(v, kind):
emojis = get_emoji_list(kind, v.over_18)
emojis = get_emoji_list(kind, g.show_over_18)
authors = get_accounts_dict([e.author_id for e in emojis], v=v, graceful=True)
if FEATURES['ASSET_SUBMISSIONS']:
@ -111,7 +111,7 @@ def get_emojis(over_18):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def emojis(v):
return get_emojis(v.over_18)
return get_emojis(g.show_over_18)

View File

@ -121,6 +121,8 @@ def get_logged_in_user():
if v and session.get("event_music") and not IS_EVENT():
session.pop("event_music")
g.show_over_18 = (v and v.over_18) or session.get('over_18_cookies', 0) >= int(time.time())
return v
def auth_desired(f):