actions: move user-only actions to useractions, which gets rid of a circular dependency

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-01 18:46:56 -05:00
parent cd33fa9046
commit 6caebac946
10 changed files with 31 additions and 27 deletions

View File

@ -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):

View File

@ -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 *

View File

@ -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

View File

@ -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 *

View File

@ -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}")

View File

@ -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

View File

@ -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 *

View File

@ -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

View File

@ -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")

View File

@ -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 *