forked from rDrama/rDrama
fix two bugs in ping group charging logic for friends and enemies
parent
bbc7ba4de0
commit
929a228325
|
@ -137,7 +137,7 @@ def add_notif(cid, uid, text, pushnotif_url='', check_existing=True):
|
||||||
push_notif({uid}, 'New notification', text, pushnotif_url)
|
push_notif({uid}, 'New notification', text, pushnotif_url)
|
||||||
|
|
||||||
|
|
||||||
def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=True, commenters_ping_post_id=None):
|
def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=True, commenters_ping_post_id=None, charge=True):
|
||||||
# Restrict young accounts from generating notifications
|
# Restrict young accounts from generating notifications
|
||||||
if v.age < NOTIFICATION_SPAM_AGE_THRESHOLD:
|
if v.age < NOTIFICATION_SPAM_AGE_THRESHOLD:
|
||||||
return set()
|
return set()
|
||||||
|
@ -178,13 +178,14 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
|
||||||
abort(403, f"Only admins can mention !focusgroup")
|
abort(403, f"Only admins can mention !focusgroup")
|
||||||
|
|
||||||
if i.group(1) == 'everyone':
|
if i.group(1) == 'everyone':
|
||||||
cost = g.db.query(User).count() * 5
|
if charge:
|
||||||
if cost > v.coins + v.marseybux:
|
cost = g.db.query(User).count() * 5
|
||||||
abort(403, f"You need {cost} currency to mention these ping groups!")
|
if cost > v.coins + v.marseybux:
|
||||||
|
abort(403, f"You need {cost} currency to mention these ping groups!")
|
||||||
|
|
||||||
v.charge_account('coins/marseybux', cost)
|
v.charge_account('coins/marseybux', cost)
|
||||||
if obj:
|
if obj:
|
||||||
obj.ping_cost += cost
|
obj.ping_cost += cost
|
||||||
return 'everyone'
|
return 'everyone'
|
||||||
elif i.group(1) == 'jannies':
|
elif i.group(1) == 'jannies':
|
||||||
group = None
|
group = None
|
||||||
|
@ -224,13 +225,14 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
|
||||||
if i.group(1) in {'biofoids','neofoids','jannies'}:
|
if i.group(1) in {'biofoids','neofoids','jannies'}:
|
||||||
coin_receivers.update(member_ids)
|
coin_receivers.update(member_ids)
|
||||||
|
|
||||||
if cost:
|
if charge:
|
||||||
v.charge_account('coins/marseybux', cost)
|
if cost:
|
||||||
if obj:
|
v.charge_account('coins/marseybux', cost)
|
||||||
obj.ping_cost += cost
|
if obj:
|
||||||
|
obj.ping_cost += cost
|
||||||
|
|
||||||
if coin_receivers:
|
if coin_receivers:
|
||||||
g.db.query(User).options(load_only(User.id)).filter(User.id.in_(coin_receivers)).update({ User.coins: User.coins + 5 })
|
g.db.query(User).options(load_only(User.id)).filter(User.id.in_(coin_receivers)).update({ User.coins: User.coins + 5 })
|
||||||
|
|
||||||
if len(notify_users) > 400 and v.admin_level < PERMS['POST_COMMENT_INFINITE_PINGS']:
|
if len(notify_users) > 400 and v.admin_level < PERMS['POST_COMMENT_INFINITE_PINGS']:
|
||||||
abort(403, "You can only notify a maximum of 400 users.")
|
abort(403, "You can only notify a maximum of 400 users.")
|
||||||
|
|
|
@ -277,8 +277,12 @@ def settings_personal_post(v):
|
||||||
add_notif(cid, x, text, pushnotif_url=f'{SITE_FULL}{v.url}')
|
add_notif(cid, x, text, pushnotif_url=f'{SITE_FULL}{v.url}')
|
||||||
|
|
||||||
if v.friends:
|
if v.friends:
|
||||||
removed_users = NOTIFY_USERS(v.friends, v) - NOTIFY_USERS(friends, v)
|
try:
|
||||||
notify_removed_users(removed_users, 'friends')
|
removed_users = NOTIFY_USERS(v.friends, v, charge=False) - NOTIFY_USERS(friends, v, charge=False)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
notify_removed_users(removed_users, 'friends')
|
||||||
|
|
||||||
v.friends = friends
|
v.friends = friends
|
||||||
v.friends_html=friends_html
|
v.friends_html=friends_html
|
||||||
|
@ -307,8 +311,12 @@ def settings_personal_post(v):
|
||||||
add_notif(cid, x, text, pushnotif_url=f'{SITE_FULL}{v.url}')
|
add_notif(cid, x, text, pushnotif_url=f'{SITE_FULL}{v.url}')
|
||||||
|
|
||||||
if v.enemies:
|
if v.enemies:
|
||||||
removed_users = NOTIFY_USERS(v.enemies, v) - NOTIFY_USERS(enemies, v)
|
try:
|
||||||
notify_removed_users(removed_users, 'enemies')
|
removed_users = NOTIFY_USERS(v.enemies, v, charge=False) - NOTIFY_USERS(enemies, v, charge=False)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
notify_removed_users(removed_users, 'enemies')
|
||||||
|
|
||||||
v.enemies = enemies
|
v.enemies = enemies
|
||||||
v.enemies_html=enemies_html
|
v.enemies_html=enemies_html
|
||||||
|
|
Loading…
Reference in New Issue