remotes/1693045480750635534/spooky-22
Aevann1 2021-07-29 00:39:08 +02:00
commit 237ee3620a
11 changed files with 67 additions and 21 deletions

View File

@ -277,6 +277,28 @@ class User(Base, Stndrd, Age_times):
def __repr__(self):
return f"<User(username={self.username})>"
@property
def unban_string(self):
if self.unban_utc == 0:
return "permanently banned"
wait = self.unban_utc - int(time.time())
if wait < 60:
text = f"{wait}s"
else:
days = wait//(24*60*60)
wait -= days*24*60*60
hours = wait//(60*60)
wait -= hours*60*60
mins = wait//60
text = f"{days}d {hours:02d}h {mins:02d}m"
return f"Unban in {text}"
@property
@lazy
def post_notifications_count(self):

View File

@ -633,7 +633,7 @@ def ban_user(user_id, v):
user = g.db.query(User).filter_by(id=user_id).first()
if user.admin_level != 0: abort(403)
if user.admin_level >= v.admin_level: abort(403)
# check for number of days for suspension
days = int(request.form.get("days")) if request.form.get('days') else 0
@ -642,7 +642,7 @@ def ban_user(user_id, v):
if not user: abort(400)
if user.admin_level > 0: abort(403)
#if user.admin_level > 0: abort(403)
if days > 0:
if message:

View File

@ -433,7 +433,7 @@ def api_comment(v):
included. \n\n*This is an automated message; if you need help,
you can message us [here](/contact).*"""
body = body.replace("\n", "\n\n")
#body = body.replace("\n", "\n\n")
with CustomRenderer(post_id=parent_id) as renderer:
body_md = renderer.render(mistletoe.Document(body))
@ -920,7 +920,7 @@ def toggle_comment_pin(cid, v):
comment = get_comment(cid, v=v)
if v.admin_level != 6 and v.id != comment.post.author_id:
if v.admin_level < 1 and v.id != comment.post.author_id:
abort(403)
comment.is_pinned = not comment.is_pinned

View File

@ -338,7 +338,8 @@ def sign_up_post(v):
email=email,
created_utc=int(time.time()),
referred_by=ref_id or None,
ban_evade = int(any([x.is_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]))
ban_evade = int(any([x.is_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])),
agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])
)
except Exception as e:

View File

@ -465,6 +465,9 @@ def settings_block_user(v):
if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!")
if request.args.get("notoast"): return "", 204
if v.admin_level == 1: return jsonify({"message": f"@{user.username} banned!"})
return jsonify({"message": f"@{user.username} blocked."})
@ -487,6 +490,9 @@ def settings_unblock_user(v):
if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!")
if request.args.get("notoast"): return "", 204
if v.admin_level == 1: return jsonify({"message": f"@{user.username} unbanned!"})
return jsonify({"message": f"@{user.username} unblocked."})

View File

@ -304,9 +304,9 @@ def u_username(username, v=None):
listing = get_posts(ids, v=v)
if u.unban_utc:
unban = datetime.fromtimestamp(u.unban_utc).strftime('%c')
#unban = datetime.fromtimestamp(u.unban_utc).strftime('%c')
return {'html': lambda: render_template("userpage.html",
unban=unban,
unban=u.unban_string,
u=u,
v=v,
listing=listing,

View File

@ -121,7 +121,7 @@
{% if c.distinguish_level %}<i class="fas fa-broom text-admin" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Drama Badmin, speaking officially"></i>&nbsp;{% endif %}
{% if c.is_op %}<i class="fas fa-microphone-stand text-info" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="OP"></i>&nbsp;{% endif %}
{% if c.is_bot %}<i class="fad fa-robot text-info" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Bot"></i>&nbsp;{% endif %}
{% if c.is_blocking %}<i class="fas fa-user-minus text-warning" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="You're blocking this user, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
{% if c.is_blocking %}<i class="fas fa-user-minus text-warning" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{% if v and v.admin_level >= 2 %}You're blocking this user, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}.{% else %}Comment author is banned{% endif %}"></i>&nbsp;{% endif %}
{% if c.is_blocked %}<i class="fas fa-user-minus text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="This user is blocking you, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
<a {% if c.author.animatedname %}class="{% if c.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;" href="/@{{c.author.username}}"><img src="{{c.author.profile_url}}" class="profile-pic-25 mr-2"/>{{c.author.username}}</a>{% if c.author.customtitle %}&nbsp;<bdi style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>{% endif %}
@ -318,6 +318,11 @@
><i class="fas fa-user-slash fa-fw"></i>Block user</a>
{% endif %}
{% if not v.id==c.author_id and v.admin_level == 1 %}
<a class="dropdown-item text-danger" href="javascript:void(0)" onclick="post_toast('/settings/block?username={{c.author.username}}')"
><i class="fas fa-user-slash fa-fw"></i>Ban user</a>
{% endif %}
{% if v.admin_level>=3 %}
{% if not c.is_banned %}
<a class="dropdown-item removeDropdownItem" id="moderate-{{c.base36id}}" href="javascript:void(0)" onclick="removeComment('{{c.base36id}}')"><i class="fas fa-comment-times fa-fw"></i>Remove</a>
@ -331,7 +336,7 @@
{% endif %}
{% endif %}
{% if v and c.post and (v.admin_level == 6 or v.id == c.post.author_id) %}
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) %}
<div class="dropdown-divider"></div>
{% if c.level == 1 %}
<a class="dropdown-item text-info" id="pin-comment-{{c.base36id}}" href="javascript:void(0)" data-dismiss="modal" data-target="#actionsModal-{{c.base36id}}" onclick="post('/comment_pin/{{c.base36id}}', function(){window.location.reload(true);})"><i class="fas fa-thumbtack fa-rotate--45 fa-fw text-info"></i>{{"Unpin" if c.is_pinned else "Pin"}}</a>
@ -518,7 +523,7 @@
{% endif %}
{% endif %}
{% if v and c.post and (v.admin_level == 6 or v.id == c.post.author_id) %}
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) %}
{% if c.level == 1 %}
<li class="list-group-item"><a class="d-block text-info" id="pin-comment-{{c.base36id}}" href="javascript:void(0)" data-dismiss="modal" data-target="#actionsModal-{{c.base36id}}" onclick="post('/comment_pin/{{c.base36id}}', function(){window.location.reload(true);})"><i class="fas fa-thumbtack fa-rotate--45 text-info"></i>{{'Unpin' if c.is_pinned else 'Pin'}}</a>
</li>

View File

@ -227,7 +227,7 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
{% if p.repost_id %}<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
{% if p.flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">&nbsp;&nbsp;<img src="{{p.author.profile_url}}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.url}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">&nbsp;&nbsp;<img src="{{p.author.profile_url}}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title="">&nbsp;{{p.age_string}}</span>
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if v and v.newtabexternal %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
@ -389,6 +389,13 @@
><i class="fas fa-user-slash text-danger"></i>Unblock user</a></li>
{% endif %}
{% if not v.id==p.author_id and v.admin_level == 1 %}
<li id="sex-user-{{p.base36id}}" class="list-inline-item{% if p.is_blocking %} d-none{% endif %}"><a href="javascript:void(0)" onclick="post_toast('/settings/block?username={{p.author.username}}', callback=function(){document.getElementById('block-user-{{p.base36id}}').classList.toggle('d-none');document.getElementById('unblock-user-{{p.base36id}}').classList.toggle('d-none');})"
><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
<li id="unsex-user-{{p.base36id}}" class="list-inline-item{% if not p.is_blocking %} d-none{% endif %}"><a href="javascript:void(0)" onclick="post_toast('/settings/unblock?username={{p.author.username}}', callback=function(){document.getElementById('block-user-{{p.base36id}}').classList.toggle('d-none');document.getElementById('unblock-user-{{p.base36id}}').classList.toggle('d-none');})"
><i class="fas fa-user-slash text-danger"></i>Unban user</a></li>
{% endif %}
{% if v.admin_level >=3 and v.id!=p.author_id %}
{% if p.author.is_banned %}
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post_toast('/api/unban_user/{{p.author_id}}')"

View File

@ -121,7 +121,7 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
{% if p.repost_id %}&nbsp;<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
{% if p.flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name"><img src="{{p.author.profile_url}}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.url}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name"><img src="{{p.author.profile_url}}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title="">&nbsp;{{p.age_string}}</span>
&nbsp;
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" target="_blank">{{p.domain}}</a>{% else %}text post{% endif %})

View File

@ -65,9 +65,9 @@
<a href="{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}"><img src="{{u.profile_url}}" class="profile-pic profile-pic-100 mb-5"></a>
</div>
<div class="ml-3 w-100">
{% if u.is_banned %}
{% if u.is_suspended %}
<h5 style="color:#ff66ac;">BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}</h5>
{% if unban %} <h5 style="color:#ff66ac;">until {{unban}}</h5>{% endif %}
{% if unban %} <h5 style="color:#ff66ac;">{{unban}}</h5>{% endif %}
{% endif %}
<div class="d-flex align-items-center mt-1 mb-2">
@ -77,13 +77,13 @@
<i class="fad fa-user-tag text-info align-middle ml-2" data-toggle="tooltip" data-placement="bottom" title="Original Username: @{{u.original_username}}"></i>
</span>
{% endif %}
{% if u.admin_level > 1 %}
{% if u.admin_level > 1 or (u.admin_level == 1 and (not v or v.admin_level < 2)) %}
<span>
<i class="fas fa-broom text-admin align-middle ml-2" data-toggle="tooltip" data-placement="bottom" title="Badmin"></i>
</span>
{% elif u.admin_level == 1 %}
<span>
<i class="fas fa-broom align-middle ml-2" data-toggle="tooltip" data-placement="bottom" title="Former Admin"></i>
<i class="fas fa-broom align-middle ml-2" data-toggle="tooltip" data-placement="bottom" title="Fake Admin"></i>
</span>
{% endif %}
{% if v and v.has_follower(u) %}
@ -157,7 +157,7 @@
<a href="/settings/profile" class="btn btn-secondary">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
{% endif %}
{% if v and v.id != u.id and v.admin_level > 0 and u.admin_level == 0 %}
{% if v and v.id != u.id and v.admin_level > 1 and u.admin_level <= 1 %}
<br><br>
<div class="body d-lg-flex border-bottom">
<div class="w-lg-100">
@ -280,9 +280,9 @@
<a href="{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}"><img src="{{u.profile_url}}" class="profile-pic-65 bg-white border-2 border-white mb-2"></a>
</div>
<div class="mt-n3 py-3">
{% if u.is_banned %}
{% if u.is_suspended %}
<h5 style="color:#ff66ac;">BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}</h5>
{% if unban %} <h5 style="color:#ff66ac;">until {{unban}}</h5>{% endif %}
{% if unban %} <h5 style="color:#ff66ac;">{{unban}}</h5>{% endif %}
{% endif %}
<a class="text-black"><h1 class="h5 d-inline-block" style="color: #{{u.namecolor}}">{{u.username}}</h1></a>
@ -337,7 +337,7 @@
<input type="submit" value="Submit" class="btn btn-primary mt-3">
</form>
{% if v.admin_level > 0 and u.admin_level == 0 %}
{% if v.admin_level > 1 and u.admin_level <= 1 %}
<br><br>
<div class="body d-lg-flex border-bottom">

View File

@ -38,10 +38,15 @@
<div class="text-center py-7 py-md-8">
<span class="fa-stack fa-2x text-muted mb-4">
<i class="fas fa-square text-danger opacity-25 fa-stack-2x"></i>
<i class="fas text-danger fa-user-cog fa-stack-1x text-lg"></i>
{% if v.admin_level == 1 %}<i class="fas text-danger fa-gavel fa-stack-1x text-lg"></i>{% else %}<i class="fas text-danger fa-user-cog fa-stack-1x text-lg"></i>{% endif %}
</span>
{% if v.admin_level == 1 %}
<h2 class="h5">@{{u.username}} is banned</h2>
<p class="text-muted">This account has been suspended.</p>
{% else %}
<h2 class="h5">You are blocking @{{u.username}}.</h2>
<p class="text-muted">So we aren't going to show you their profile.</p>
{% endif %}
</div>
</div>
</div>