fdsdsf
This commit is contained in:
parent
904af5bfd0
commit
bbea88ccbc
8 changed files with 28 additions and 25 deletions
|
@ -64,7 +64,7 @@ document.getElementById("reportCommentButton").onclick = function() {
|
||||||
this.innerHTML='Reporting comment';
|
this.innerHTML='Reporting comment';
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", '/flag/comment/'+id, true);
|
xhr.open("POST", '/report/comment/'+id, true);
|
||||||
var form = new FormData()
|
var form = new FormData()
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
form.append("reason", document.getElementById("reason-comment").value);
|
form.append("reason", document.getElementById("reason-comment").value);
|
||||||
|
|
|
@ -8,7 +8,7 @@ report_postModal = function(id) {
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", '/flag/post/'+id, true);
|
xhr.open("POST", '/report/post/'+id, true);
|
||||||
var form = new FormData()
|
var form = new FormData()
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
form.append("reason", document.getElementById("reason").value);
|
form.append("reason", document.getElementById("reason").value);
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Submission(Base):
|
||||||
url = Column(String)
|
url = Column(String)
|
||||||
body = Column(String)
|
body = Column(String)
|
||||||
body_html = Column(String)
|
body_html = Column(String)
|
||||||
|
flair = Column(String)
|
||||||
ban_reason = Column(String)
|
ban_reason = Column(String)
|
||||||
embed_url = Column(String)
|
embed_url = Column(String)
|
||||||
|
|
||||||
|
|
|
@ -4,33 +4,32 @@ from flask import g
|
||||||
from files.__main__ import app, limiter
|
from files.__main__ import app, limiter
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
@app.post("/flag/post/<pid>")
|
@app.post("/report/post/<pid>")
|
||||||
@limiter.limit("1/second")
|
@limiter.limit("1/second")
|
||||||
@auth_desired
|
@auth_required
|
||||||
def api_flag_post(pid, v):
|
def api_flag_post(pid, v):
|
||||||
|
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
|
|
||||||
if v and not v.shadowbanned:
|
if not v.shadowbanned:
|
||||||
existing = g.db.query(Flag.id).filter_by(user_id=v.id, post_id=post.id).first()
|
|
||||||
|
|
||||||
if existing: return "", 409
|
|
||||||
|
|
||||||
reason = request.values.get("reason", "").strip()[:100]
|
reason = request.values.get("reason", "").strip()[:100]
|
||||||
if "<" in reason: return {"error": f"Reasons can't contain <"}
|
if "<" in reason: return {"error": f"Reasons can't contain <"}
|
||||||
|
|
||||||
|
if not reason.startswith('!'):
|
||||||
|
existing = g.db.query(Flag.id).filter_by(user_id=v.id, post_id=post.id).first()
|
||||||
|
if existing: return "", 409
|
||||||
|
|
||||||
for i in re.finditer(':(.{1,30}?):', reason):
|
for i in re.finditer(':(.{1,30}?):', reason):
|
||||||
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'):
|
||||||
reason = reason.replace(f':{i.group(1)}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{i.group(1)}:" title=":{i.group(1)}:" delay="0" height=20 src="https://{site}/assets/images/emojis/{i.group(1)}.webp">')
|
reason = reason.replace(f':{i.group(1)}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{i.group(1)}:" title=":{i.group(1)}:" delay="0" height=20 src="https://{site}/assets/images/emojis/{i.group(1)}.webp">')
|
||||||
|
|
||||||
if len(reason) > 350: return {"error": f"Too long."}
|
if len(reason) > 350: return {"error": f"Too long."}
|
||||||
|
|
||||||
flag = Flag(post_id=post.id,
|
if reason.startswith('!') and v.admin_level > 1:
|
||||||
user_id=v.id,
|
post.flair = reason[1:]
|
||||||
reason=reason,
|
g.db.add(post)
|
||||||
)
|
else:
|
||||||
|
flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
|
||||||
|
|
||||||
g.db.add(flag)
|
g.db.add(flag)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -38,14 +37,14 @@ def api_flag_post(pid, v):
|
||||||
return {"message": "Post reported!"}
|
return {"message": "Post reported!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/flag/comment/<cid>")
|
@app.post("/report/comment/<cid>")
|
||||||
@limiter.limit("1/second")
|
@limiter.limit("1/second")
|
||||||
@auth_desired
|
@auth_required
|
||||||
def api_flag_comment(cid, v):
|
def api_flag_comment(cid, v):
|
||||||
|
|
||||||
comment = get_comment(cid)
|
comment = get_comment(cid)
|
||||||
|
|
||||||
if v and not v.shadowbanned:
|
if not v.shadowbanned:
|
||||||
existing = g.db.query(CommentFlag.id).filter_by(
|
existing = g.db.query(CommentFlag.id).filter_by(
|
||||||
user_id=v.id, comment_id=comment.id).first()
|
user_id=v.id, comment_id=comment.id).first()
|
||||||
|
|
||||||
|
|
|
@ -749,7 +749,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
||||||
<script src="/assets/js/comments_v.js?v=81"></script>
|
<script src="/assets/js/comments_v.js?v=82"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
||||||
|
|
|
@ -32,4 +32,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/report_post_modal.js?v=54"></script>
|
<script src="/assets/js/report_post_modal.js?v=55"></script>
|
|
@ -401,12 +401,14 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if p.realurl(v) %}
|
{% if p.realurl(v) %}
|
||||||
<h1 id="post-title" class="card-title post-title text-left mb-md-3"><a {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}">
|
<h1 id="post-title" class="card-title post-title text-left mb-md-3"><a {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}">
|
||||||
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">{{cc}}</span>{% endif %}
|
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{cc}}</span>{% endif %}
|
||||||
|
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair}}</span>{% endif %}
|
||||||
{{p.realtitle(v) | safe}}
|
{{p.realtitle(v) | safe}}
|
||||||
</a></h1>
|
</a></h1>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1 id="post-title" class="card-title post-title text-left mb-md-3">
|
<h1 id="post-title" class="card-title post-title text-left mb-md-3">
|
||||||
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">{{cc}}</span>{% endif %}
|
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{cc}}</span>{% endif %}
|
||||||
|
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair}}</span>{% endif %}
|
||||||
{{p.realtitle(v) | safe}}
|
{{p.realtitle(v) | safe}}
|
||||||
</h1>
|
</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -902,7 +904,7 @@
|
||||||
|
|
||||||
{% if not p.comment_count %}
|
{% if not p.comment_count %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="/assets/js/comments_v.js?v=81"></script>
|
<script src="/assets/js/comments_v.js?v=82"></script>
|
||||||
{% include "award_modal.html" %}
|
{% include "award_modal.html" %}
|
||||||
{% include "emoji_modal.html" %}
|
{% include "emoji_modal.html" %}
|
||||||
{% include "gif_modal.html" %}
|
{% include "gif_modal.html" %}
|
||||||
|
|
|
@ -198,7 +198,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5 class="card-title post-title text-left w-lg-75 mb-0 pb-0 pb-md-1"><a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %} class="stretched-link">
|
<h5 class="card-title post-title text-left w-lg-75 mb-0 pb-0 pb-md-1"><a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %} class="stretched-link">
|
||||||
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">{{cc}}</span>{% endif %}
|
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{cc}}</span>{% endif %}
|
||||||
|
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair}}</span>{% endif %}
|
||||||
{{p.realtitle(v) | safe}}
|
{{p.realtitle(v) | safe}}
|
||||||
</a></h5>
|
</a></h5>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue