Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update and change it #7

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.