Skip to content

Commit

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

async def push_notification(title, text, user_id):
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": f"{origin}/notifications",
"url": url,
"userId": user_id,
"key": stocknear_api_key,
}
Expand Down Expand Up @@ -148,7 +152,7 @@ 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)
await push_notification(f'Why Priced Moved for {symbol}', data['text'], user_id, link=f"{asset_type}/{symbol}")
except:
pass
except Exception as e:
Expand Down Expand Up @@ -305,7 +309,6 @@ async def run():
result = pb.collection('notificationChannels').get_list(query_params={"filter": f"user='{user_id}'"})
channels = result.items
for channel in channels:

if channel.wiim == True:
await push_wiim(user_id=user_id)

Expand Down

0 comments on commit 25ac689

Please sign in to comment.