Compare commits

...

2 Commits

Author SHA1 Message Date
Aevann e6274e06f3 delete ability of jannies to clear internal cache 2022-12-22 22:52:36 +02:00
Aevann f0eee0aa68 fix 500 error on voting 2022-12-22 22:51:56 +02:00
6 changed files with 5 additions and 28 deletions

View File

@ -287,7 +287,6 @@ PERMS = { # Minimum admin_level to perform action.
'SITE_SETTINGS_SNAPPY_QUOTES': 3,
'SITE_SETTINGS_UNDER_ATTACK': 3,
'SITE_CACHE_PURGE_CDN': 3,
'SITE_CACHE_DUMP_INTERNAL': 2,
'SITE_WARN_ON_INVALID_AUTH': 1,
'NOTIFICATIONS_ADMIN_PING': 2,
'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 2,

View File

@ -96,11 +96,6 @@ MODACTION_TYPES = {
"icon": 'fa-dollar-sign',
"color": 'bg-success'
},
'clear_internal_cache': {
"str": 'cleared internal cache',
"icon": 'fa-trash-alt',
"color": 'bg-muted'
},
'edit_post': {
"str": 'edited {self.target_link}',
"icon": 'fa-edit',

View File

@ -410,19 +410,6 @@ def clear_cloudflare_cache(v):
g.db.add(ma)
return {"message": "Cloudflare cache cleared!"}
@app.post("/admin/clear_internal_cache")
@admin_level_required(PERMS['SITE_CACHE_DUMP_INTERNAL'])
def admin_clear_internal_cache(v):
online = cache.get(CHAT_ONLINE_CACHE_KEY)
cache.clear()
cache.set(CHAT_ONLINE_CACHE_KEY, online)
ma = ModAction(
kind="clear_internal_cache",
user_id=v.id
)
g.db.add(ma)
return {"message": "Internal cache cleared!"}
@app.post("/admin/under_attack")
@admin_level_required(PERMS['SITE_SETTINGS_UNDER_ATTACK'])
def under_attack(v):

View File

@ -3,7 +3,7 @@ from files.helpers.config.const import *
from files.helpers.get import *
from files.routes.wrappers import *
from files.__main__ import app, limiter
from files.routes.routehelpers import get_alt_graph
@app.get("/votes/<link>")
@auth_required
@ -89,10 +89,8 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
if v.id == target.author.id:
coin_delta = 0
v_alts_id = [x.id for x in v.get_alt_graph(self.id)]
alt = False
if target.author.id in v.alt_ids or v.id in target.author.alt_ids:
if target.author.id in [x.id for x in get_alt_graph(v.id)]:
coin_delta = -1
alt = True
@ -135,7 +133,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
target.author.truescore += coin_delta
g.db.add(target.author)
real = alt or new != 1 or v.is_votes_real
real = new != 1 or (not alt and v.is_votes_real)
vote = None
if vote_cls == Vote:
vote = Vote(user_id=v.id,

View File

@ -124,14 +124,11 @@
<br>
{% endif %}
{% if v.admin_level >= PERMS['SITE_CACHE_PURGE_CDN'] or v.admin_level >= PERMS['SITE_CACHE_DUMP_INTERNAL'] %}
{% if v.admin_level >= PERMS['SITE_CACHE_PURGE_CDN'] %}
<h4>Caching</h4>
{% if v.admin_level >= PERMS['SITE_CACHE_PURGE_CDN'] %}
<button type="button" class="btn btn-primary mt-3" onclick="postToastSwitch(this,'/admin/clear_cloudflare_cache');" style="margin-bottom: 2em;">CLEAR CLOUDFLARE CACHE</button>
{% endif %}
{% if v.admin_level >= PERMS['SITE_CACHE_DUMP_INTERNAL'] %}
<button type="button" class="btn btn-primary mt-3 ml-2" onclick="postToastSwitch(this,'/admin/clear_internal_cache');" style="margin-bottom: 2em;">CLEAR INTERNAL CACHE</button>
{% endif %}
{% endif %}
<h4>Server Status</h4>

View File

@ -0,0 +1 @@
delete from modactions where kind='clear_internal_cache';