only count month-old applications

pull/222/head
Aevann 2024-02-11 13:57:17 +02:00
parent 7e8ee81a16
commit e2b19c6d03
1 changed files with 7 additions and 8 deletions

View File

@ -294,15 +294,14 @@ def group_usurp(v, group_name):
Comment.created_utc > one_month_ago,
).first()
if is_active:
abort(403, f"@{group.owner.username} has reviewed a membership application in the past month, so you can't usurp them!")
membership_applications = g.db.query(GroupMembership.user_id).filter_by(
group_name=group.name,
approved_utc=None,
month_old_applications = g.db.query(GroupMembership.user_id).filter_by(
GroupMembership.group_name == group.name,
GroupMembership.approved_utc == None,
GroupMembership.created_utc < one_month_ago,
).first()
if not membership_applications:
abort(403, f"There is currently no membership applications to !{group.name}, so usurping is not necessary!")
if is_active or not month_old_applications:
abort(403, f"@{group.owner.username} has reviewed a membership application in the past month, so you can't usurp them!")
send_repeatable_notification(group.owner_id, f"@{v.username} has usurped control of !{group.name} from you. This was possible because you spent more than a month not reviewing membership applications. Be active next time sweaty :!marseycheeky:")