2022-06-15 19:33:21 +00:00
|
|
|
from flask import g
|
|
|
|
from files.classes.badges import Badge
|
|
|
|
from files.helpers.alerts import send_repeatable_notification
|
2022-06-06 04:07:38 +00:00
|
|
|
|
2022-06-15 19:33:21 +00:00
|
|
|
def badge_grant(user, badge_id):
|
|
|
|
|
|
|
|
if user.has_badge(badge_id): return
|
2022-06-06 04:07:38 +00:00
|
|
|
|
|
|
|
badge = Badge(
|
|
|
|
badge_id=int(badge_id),
|
2022-06-15 19:33:21 +00:00
|
|
|
user_id=user.id
|
2022-06-06 04:07:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
g.db.add(badge)
|
2022-06-15 19:33:21 +00:00
|
|
|
g.db.flush()
|
|
|
|
|
|
|
|
send_repeatable_notification(user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}")
|