Skip to content

Commit

Permalink
bugfixing push notification
Browse files Browse the repository at this point in the history
  • Loading branch information
MuslemRahimi committed Feb 20, 2025
1 parent 25ac689 commit eea73a3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/cron_push_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ def format_number(num, decimal=False):
return f"{num:,.0f}" # Format smaller numbers with commas

async def push_notification(title, text, user_id, link=None):
if link == None:
url = f"{origin}/notifications",
else:
url = f"{origin}/{link}",
data = {
"title": title,
"body": text,
"url": url,
"url": f"{origin}/notifications" if link == None else f"{origin}/{link}",
"userId": user_id,
"key": stocknear_api_key,
}
Expand Down Expand Up @@ -152,7 +148,16 @@ async def push_wiim(user_id):
user_subscribed = True
break
if user_subscribed:
await push_notification(f'Why Priced Moved for {symbol}', data['text'], user_id, link=f"{asset_type}/{symbol}")
if asset_type == 'stock':
link = f"stocks/{symbol}"
elif asset_type == 'etf':
link = f"etf/{symbol}"
elif asset_type == 'index':
link = f"index/{symbol}"
else:
link = None

await push_notification(f'Why Priced Moved for {symbol}', data['text'], user_id, link=link)
except:
pass
except Exception as e:
Expand Down

0 comments on commit eea73a3

Please sign in to comment.