mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
fix invitations
This commit is contained in:
@@ -72,12 +72,22 @@ def invite_user_to_org(organization_id):
|
|||||||
key_type=KeyType.NORMAL,
|
key_type=KeyType.NORMAL,
|
||||||
reply_to_text=invited_org_user.invited_by.email_address,
|
reply_to_text=invited_org_user.invited_by.email_address,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
saved_notification.personalisation = personalisation
|
||||||
redis_store.set(
|
redis_store.set(
|
||||||
f"email-personalisation-{saved_notification.id}",
|
f"email-personalisation-{saved_notification.id}",
|
||||||
json.dumps(personalisation),
|
json.dumps(personalisation),
|
||||||
ex=1800,
|
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)
|
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||||
|
|
||||||
|
|||||||
@@ -48,11 +48,7 @@ def _create_service_invite(invited_user, invite_link_host):
|
|||||||
template_version=template.version,
|
template_version=template.version,
|
||||||
recipient=invited_user.email_address,
|
recipient=invited_user.email_address,
|
||||||
service=service,
|
service=service,
|
||||||
personalisation={
|
personalisation={},
|
||||||
"user_name": invited_user.from_user.name,
|
|
||||||
"service_name": invited_user.service.name,
|
|
||||||
"url": invited_user_url(invited_user.id, invite_link_host),
|
|
||||||
},
|
|
||||||
notification_type=NotificationType.EMAIL,
|
notification_type=NotificationType.EMAIL,
|
||||||
api_key_id=None,
|
api_key_id=None,
|
||||||
key_type=KeyType.NORMAL,
|
key_type=KeyType.NORMAL,
|
||||||
@@ -64,6 +60,26 @@ def _create_service_invite(invited_user, invite_link_host):
|
|||||||
json.dumps(personalisation),
|
json.dumps(personalisation),
|
||||||
ex=1800,
|
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)
|
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user