do this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4197134#context
parent
883c96a830
commit
6958b70975
|
@ -135,6 +135,7 @@ class Comment(Base):
|
|||
ban_reason = Column(String)
|
||||
treasure_amount = Column(String)
|
||||
slots_result = Column(String)
|
||||
ping_cost = Column(Integer)
|
||||
blackjack_result = Column(String)
|
||||
casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
|
||||
chudded = Column(Boolean, default=False)
|
||||
|
|
|
@ -60,6 +60,7 @@ class Post(Base):
|
|||
new = Column(Boolean)
|
||||
notify = Column(Boolean)
|
||||
chudded = Column(Boolean, default=False)
|
||||
ping_cost = Column(Integer)
|
||||
|
||||
author = relationship("User", primaryjoin="Post.author_id==User.id")
|
||||
oauth_app = relationship("OauthApp")
|
||||
|
|
|
@ -122,7 +122,7 @@ def add_notif(cid, uid, text, pushnotif_url=''):
|
|||
push_notif({uid}, 'New notification', text, pushnotif_url)
|
||||
|
||||
|
||||
def NOTIFY_USERS(text, v, oldtext=None, ghost=False):
|
||||
def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
|
||||
# Restrict young accounts from generating notifications
|
||||
if v.age < NOTIFICATION_SPAM_AGE_THRESHOLD:
|
||||
return set()
|
||||
|
@ -176,6 +176,9 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False):
|
|||
if cost > v.coins:
|
||||
abort(403, f"You need {cost} coins to mention these ping groups!")
|
||||
|
||||
if log_cost:
|
||||
log_cost.ping_cost = cost
|
||||
|
||||
g.db.query(User).filter(User.id.in_(members)).update({ User.coins: User.coins + mul })
|
||||
|
||||
v.charge_account('coins', cost)
|
||||
|
|
|
@ -331,7 +331,7 @@ def comment(v:User):
|
|||
execute_zozbot(c, level, post_target, v)
|
||||
|
||||
if not v.shadowbanned:
|
||||
notify_users = NOTIFY_USERS(body, v, ghost=c.ghost)
|
||||
notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, log_cost=c)
|
||||
|
||||
if notify_users == 'everyone':
|
||||
alert_everyone(c.id)
|
||||
|
@ -642,7 +642,7 @@ def edit_comment(cid, v):
|
|||
if v.marseyawarded and marseyaward_body_regex.search(body_html):
|
||||
abort(403, "You can only type marseys!")
|
||||
|
||||
notify_users = NOTIFY_USERS(body, v, c.body, ghost=c.ghost)
|
||||
notify_users = NOTIFY_USERS(body, v, c.body, ghost=c.ghost, log_cost=c)
|
||||
|
||||
if notify_users == 'everyone':
|
||||
alert_everyone(c.id)
|
||||
|
|
|
@ -45,7 +45,7 @@ def publish(pid, v):
|
|||
p.created_utc = int(time.time())
|
||||
g.db.add(p)
|
||||
|
||||
notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v, ghost=p.ghost)
|
||||
notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v, ghost=p.ghost, log_cost=p)
|
||||
|
||||
if notify_users:
|
||||
cid, text = notif_comment2(p)
|
||||
|
@ -665,7 +665,7 @@ def submit_post(v:User, sub=None):
|
|||
gevent.spawn(thumbnail_thread, p.id, v.id)
|
||||
|
||||
if not p.private:
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, ghost=p.ghost)
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, ghost=p.ghost, log_cost=p)
|
||||
|
||||
if notify_users:
|
||||
cid, text = notif_comment2(p)
|
||||
|
@ -1023,7 +1023,7 @@ def edit_post(pid, v):
|
|||
|
||||
|
||||
if not p.private:
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, f'{p.title} {p.body}', ghost=p.ghost)
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, f'{p.title} {p.body}', ghost=p.ghost, log_cost=p)
|
||||
if notify_users:
|
||||
cid, text = notif_comment2(p)
|
||||
if notify_users == 'everyone':
|
||||
|
|
|
@ -223,11 +223,15 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if c.ping_cost %}
|
||||
<em class="ml-2">spent {{c.ping_cost}} coins on pings</em>
|
||||
{% endif %}
|
||||
|
||||
{% if c.slots_result %}
|
||||
<em style="position: relative; top: 2px; margin-left: 0.5rem">{{c.slots_result}}</em>
|
||||
<em class="ml-2">{{c.slots_result}}</em>
|
||||
{% elif c.casino_game_id %}
|
||||
{% set game_state = c.casino_game.game_state_json %}
|
||||
<em style="position: relative; top: 2px; margin-left: 0.5rem">{{game_state['symbols'].replace(',','')}} {{game_state['text']}}</em>
|
||||
<em class="ml-2">{{game_state['symbols'].replace(',','')}} {{game_state['text']}}</em>
|
||||
{% endif %}
|
||||
|
||||
{% if c.blackjack_result %}
|
||||
|
|
|
@ -96,6 +96,10 @@
|
|||
{% endif %}
|
||||
<span class="ml-2 d-inline-block">{{p.views}} thread views</span>
|
||||
#{{p.id}}
|
||||
|
||||
{% if p.ping_cost %}
|
||||
<em class="ml-2">spent {{p.ping_cost}} coins on pings</em>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
alter table comments add column ping_cost int;
|
||||
alter table posts add column ping_cost int;
|
Loading…
Reference in New Issue