forked from MarseyWorld/MarseyWorld
fix 500 error when no keyword notifs are present
parent
0214ce34aa
commit
f797a50010
|
@ -1169,13 +1169,6 @@ class User(Base):
|
|||
l = [i for i in l if i]
|
||||
return l
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def notif_words(self):
|
||||
l = self.keyword_notifs.lower().split('\n')
|
||||
l = [i for i in l if i]
|
||||
return l
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def lottery_stats(self):
|
||||
|
|
|
@ -153,12 +153,12 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
|
|||
|
||||
criteria = (Notification.user_id == User.id, Notification.read == False)
|
||||
|
||||
keyword_users = g.db.query(User).options(load_only(User.id, User.keyword_notifs)).outerjoin(Notification, and_(*criteria)).group_by(User.id).having(func.count(Notification.user_id) < 100).filter(User.keyword_notifs != None)
|
||||
keyword_users = g.db.query(User.id, User.keyword_notifs).outerjoin(Notification, and_(*criteria)).group_by(User.id, User.keyword_notifs).having(func.count(Notification.user_id) < 100).filter(User.keyword_notifs != None)
|
||||
|
||||
for user in keyword_users:
|
||||
for word in user.notif_words:
|
||||
for id, keyword_notifs in keyword_users:
|
||||
for word in keyword_notifs.lower().split('\n'):
|
||||
if word in text:
|
||||
notify_users.add(user.id)
|
||||
notify_users.add(id)
|
||||
|
||||
|
||||
names = set(m.group(1) for m in mention_regex.finditer(text))
|
||||
|
|
Loading…
Reference in New Issue