Skip to content

Commit

Permalink
Merge pull request #7 from sepid-org/notification-system
Browse files Browse the repository at this point in the history
update and change it
  • Loading branch information
AmooHashem authored Jul 16, 2024
2 parents f4eff4e + 890ff43 commit 98226a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from apps.fsm.models import RegistrationForm, RegistrationReceipt, Team, AnswerSheet
from apps.fsm.serializers.answer_sheet_serializers import MyRegistrationReceiptSerializer
from proxies.email_service.main import EmailServiceProxy
from proxies.instant_messaging.send_notif import NotifServiceProxy


def generate_tokens_for_user(user):
Expand Down Expand Up @@ -77,6 +78,8 @@ def create_or_get_user(user_data, website):
name=user.full_name,
subject=f'به آکادمی خوش آمدید!',
)
user_notif = NotifServiceProxy(website='academy')
user_notif.send_notification(reciver=user.id , message='به آکادمی خوش آمدید!')

return user

Expand Down
22 changes: 22 additions & 0 deletions proxies/instant_messaging/send_notif.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import requests

# from manage_content_service.settings.base import get_environment_var
#
# url = get_environment_var(
# 'INSTANT_MESSAGE_URL', 'https://ims.sepid.org/')
#
url = 'https://ims.sepid.org'

class NotifServiceProxy():
def __init__(self ,website):
self.website= website
self.notif = None


def send_notification(self, reciver , message):
self.notif = message
res = requests.post(f'{url}/send-message', json={'sender':self.website , 'reciver':reciver , 'message':self.notif})
return res.status_code



Empty file.

0 comments on commit 98226a9

Please sign in to comment.