forked from rDrama/rDrama
fix invalid usurpations
parent
674ce1f24d
commit
5300c55d2d
|
@ -283,15 +283,11 @@ def group_usurp(v, group_name):
|
|||
if not v.is_member_of_group(group):
|
||||
abort(403, "Only members of groups can usurp them!")
|
||||
|
||||
search_html = f'''%src="/pp/{group.owner_id}">@%</a> (<a href="/!{group.name}" rel="nofollow">!{group.name}</a>'s owner) has % your application!</p>%'''
|
||||
|
||||
one_month_ago = time.time() - 2629800
|
||||
|
||||
is_active = g.db.query(Comment.id).filter(
|
||||
Comment.author_id == AUTOJANNY_ID,
|
||||
Comment.parent_post == None,
|
||||
Comment.body_html.like(search_html),
|
||||
Comment.created_utc > one_month_ago,
|
||||
less_than_month_old_memberships = g.db.query(GroupMembership.user_id).filter(
|
||||
GroupMembership.group_name == group.name,
|
||||
GroupMembership.approved_utc > one_month_ago,
|
||||
).first()
|
||||
|
||||
month_old_applications = g.db.query(GroupMembership.user_id).filter(
|
||||
|
@ -300,7 +296,7 @@ def group_usurp(v, group_name):
|
|||
GroupMembership.created_utc < one_month_ago,
|
||||
).first()
|
||||
|
||||
if is_active or not month_old_applications:
|
||||
if less_than_month_old_memberships 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:")
|
||||
|
|
Loading…
Reference in New Issue