actions: move user-only actions to useractions, which gets rid of a circular dependency
parent
cd33fa9046
commit
6caebac946
|
@ -1,5 +1,4 @@
|
|||
from flask import g
|
||||
from files.classes.badges import Badge
|
||||
from files.helpers.alerts import send_repeatable_notification
|
||||
from files.helpers.const import *
|
||||
from files.helpers.get import *
|
||||
|
@ -8,27 +7,6 @@ from files.helpers.slots import execute_slots_command
|
|||
import random
|
||||
from urllib.parse import quote
|
||||
|
||||
def badge_grant(user, badge_id, description=None, url=None, notify=True):
|
||||
assert user != None
|
||||
if user.has_badge(badge_id):
|
||||
return
|
||||
|
||||
badge = Badge(
|
||||
badge_id=int(badge_id),
|
||||
user_id=user.id,
|
||||
description=description,
|
||||
url=url,
|
||||
)
|
||||
|
||||
g.db.add(badge)
|
||||
g.db.flush()
|
||||
|
||||
if notify:
|
||||
send_repeatable_notification(user.id,
|
||||
f"@AutoJanny has given you the following profile badge:\n\n" +
|
||||
f"![]({badge.path})\n\n**{badge.name}**\n\n{badge.badge.description}")
|
||||
|
||||
|
||||
headers = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
|
||||
|
||||
def archiveorg(url):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from files.__main__ import app, limiter, db_session
|
||||
from files.helpers.wrappers import *
|
||||
from files.helpers.actions import badge_grant
|
||||
from files.helpers.useractions import badge_grant
|
||||
from files.helpers.alerts import *
|
||||
from files.helpers.get import *
|
||||
from files.helpers.const import *
|
||||
|
|
|
@ -4,7 +4,7 @@ from files.helpers.const import *
|
|||
from files.helpers.alerts import send_repeatable_notification
|
||||
from files.helpers.roulette import spin_roulette_wheel
|
||||
from files.helpers.get import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from files.classes import *
|
||||
from files.__main__ import cache
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from random import choice
|
|||
from sqlalchemy import *
|
||||
from files.helpers.alerts import *
|
||||
from files.helpers.wrappers import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from flask import g
|
||||
from .const import *
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
from flask import g
|
||||
from files.classes.badges import Badge
|
||||
from files.helpers.alerts import send_repeatable_notification
|
||||
|
||||
def badge_grant(user, badge_id, description=None, url=None, notify=True):
|
||||
assert user != None
|
||||
if user.has_badge(badge_id):
|
||||
return
|
||||
|
||||
badge = Badge(
|
||||
badge_id=int(badge_id),
|
||||
user_id=user.id,
|
||||
description=description,
|
||||
url=url,
|
||||
)
|
||||
|
||||
g.db.add(badge)
|
||||
g.db.flush()
|
||||
|
||||
if notify:
|
||||
send_repeatable_notification(user.id,
|
||||
f"@AutoJanny has given you the following profile badge:\n\n" +
|
||||
f"![]({badge.path})\n\n**{badge.name}**\n\n{badge.badge.description}")
|
|
@ -7,7 +7,7 @@ from files.helpers.security import *
|
|||
from files.helpers.wrappers import *
|
||||
from files.helpers.const import *
|
||||
from files.helpers.get import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from files.classes import *
|
||||
from files.__main__ import app, limiter
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from files.helpers.get import *
|
|||
from files.helpers.media import *
|
||||
from files.helpers.const import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from files.helpers.cloudflare import *
|
||||
from files.classes import *
|
||||
from flask import *
|
||||
|
|
|
@ -5,6 +5,7 @@ from files.helpers.get import *
|
|||
from files.helpers.const import *
|
||||
from files.helpers.regex import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from files.classes.award import *
|
||||
from .front import frontlist
|
||||
from flask import g, request
|
||||
|
|
|
@ -3,7 +3,7 @@ from files.classes.hats import *
|
|||
from files.helpers.alerts import *
|
||||
from files.helpers.wrappers import *
|
||||
from files.helpers.const import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from flask import g
|
||||
|
||||
@app.get("/hats")
|
||||
|
|
|
@ -4,6 +4,7 @@ from files.helpers.sanitize import *
|
|||
from files.helpers.const import *
|
||||
from files.helpers.regex import *
|
||||
from files.helpers.actions import *
|
||||
from files.helpers.useractions import *
|
||||
from files.helpers.get import *
|
||||
from files.helpers.security import *
|
||||
from files.mail import *
|
||||
|
|
Loading…
Reference in New Issue