mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Merge branch 'main' of https://github.com/GSA/notifications-api into message-send-flow-docs
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
from strenum import StrEnum # type: ignore [import-not-found]
|
||||
|
||||
# In 3.11 this is in the enum library. We will not need this external library any more.
|
||||
# The line will simply change from importing from strenum to importing from enum.
|
||||
# And the strenum library can then be removed from poetry.
|
||||
from enum import StrEnum
|
||||
|
||||
|
||||
class TemplateType(StrEnum):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from flask import Blueprint, current_app, jsonify, request
|
||||
from itsdangerous import BadData, SignatureExpired
|
||||
@@ -58,10 +59,7 @@ def invite_user_to_org(organization_id):
|
||||
else invited_org_user.invited_by.name
|
||||
),
|
||||
"organization_name": invited_org_user.organization.name,
|
||||
"url": invited_org_user_url(
|
||||
invited_org_user.id,
|
||||
data.get("invite_link_host"),
|
||||
),
|
||||
"url": os.environ["LOGIN_DOT_GOV_REGISTRATION_URL"],
|
||||
}
|
||||
saved_notification = persist_notification(
|
||||
template_id=template.id,
|
||||
@@ -74,12 +72,22 @@ def invite_user_to_org(organization_id):
|
||||
key_type=KeyType.NORMAL,
|
||||
reply_to_text=invited_org_user.invited_by.email_address,
|
||||
)
|
||||
|
||||
saved_notification.personalisation = personalisation
|
||||
redis_store.set(
|
||||
f"email-personalisation-{saved_notification.id}",
|
||||
json.dumps(personalisation),
|
||||
ex=1800,
|
||||
)
|
||||
saved_notification.personalisation = personalisation
|
||||
|
||||
# This is for the login.gov path, note 24 hour expiry to match
|
||||
# The expiration of invitations.
|
||||
redis_key = f"organization-invite-{invited_org_user.email_address}"
|
||||
redis_store.set(
|
||||
redis_key,
|
||||
organization_id,
|
||||
ex=3600 * 24,
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from flask import Blueprint, current_app, jsonify, request
|
||||
@@ -39,7 +40,7 @@ def _create_service_invite(invited_user, invite_link_host):
|
||||
personalisation = {
|
||||
"user_name": invited_user.from_user.name,
|
||||
"service_name": invited_user.service.name,
|
||||
"url": invited_user_url(invited_user.id, invite_link_host),
|
||||
"url": os.environ["LOGIN_DOT_GOV_REGISTRATION_URL"],
|
||||
}
|
||||
|
||||
saved_notification = persist_notification(
|
||||
@@ -47,11 +48,7 @@ def _create_service_invite(invited_user, invite_link_host):
|
||||
template_version=template.version,
|
||||
recipient=invited_user.email_address,
|
||||
service=service,
|
||||
personalisation={
|
||||
"user_name": invited_user.from_user.name,
|
||||
"service_name": invited_user.service.name,
|
||||
"url": invited_user_url(invited_user.id, invite_link_host),
|
||||
},
|
||||
personalisation={},
|
||||
notification_type=NotificationType.EMAIL,
|
||||
api_key_id=None,
|
||||
key_type=KeyType.NORMAL,
|
||||
@@ -63,6 +60,26 @@ def _create_service_invite(invited_user, invite_link_host):
|
||||
json.dumps(personalisation),
|
||||
ex=1800,
|
||||
)
|
||||
# The raw permissions are in the form "a,b,c,d"
|
||||
# but need to be in the form ["a", "b", "c", "d"]
|
||||
data = {}
|
||||
permissions = invited_user.permissions
|
||||
permissions = permissions.split(",")
|
||||
permission_list = []
|
||||
for permission in permissions:
|
||||
permission_list.append(f"{permission}")
|
||||
data["from_user_id"] = (str(invited_user.from_user.id),)
|
||||
data["service_id"] = str(invited_user.service.id)
|
||||
data["permissions"] = permission_list
|
||||
data["folder_permissions"] = invited_user.folder_permissions
|
||||
|
||||
# This is for the login.gov service invite on the
|
||||
# "Set Up Your Profile" path.
|
||||
redis_store.set(
|
||||
f"service-invite-{invited_user.email_address}",
|
||||
json.dumps(data),
|
||||
ex=3600 * 24,
|
||||
)
|
||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user