Skip to content

Commit

Permalink
Add in lines to carry over data flowing from pay-api -> events -> acc…
Browse files Browse the repository at this point in the history
…ount-mailer (#2744)
  • Loading branch information
seeker25 authored Feb 28, 2024
1 parent a11555b commit 65c1cb2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions queue_services/events-listener/src/events_listener/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ async def process_event(event_message, flask_app):
if message_type == LOCK_ACCOUNT_MESSAGE_TYPE:
org.status_code = OrgStatus.NSF_SUSPENDED.value
org.suspended_on = datetime.now()
await publish_mailer_events(LOCK_ACCOUNT_MESSAGE_TYPE, org_id)
data = {
'accountId': org_id,
}
await publish_mailer_events(LOCK_ACCOUNT_MESSAGE_TYPE, org_id, data)
elif message_type == UNLOCK_ACCOUNT_MESSAGE_TYPE:
org.status_code = OrgStatus.ACTIVE.value
await publish_mailer_events(UNLOCK_ACCOUNT_MESSAGE_TYPE, org_id)
await publish_mailer_events(UNLOCK_ACCOUNT_MESSAGE_TYPE, org_id, data)
else:
logger.error('Unknown Message Type : %s', message_type)
return
Expand All @@ -97,21 +100,17 @@ async def cb_subscription_handler(msg: nats.aio.client.Msg):
logger.error('Queue Error: %s', json.dumps(event_message), exc_info=True)


async def publish_mailer_events(message_type: str, org_id: str):
async def publish_mailer_events(message_type: str, org_id, data):
"""Publish payment message to the mailer queue."""
# Publish message to the Queue, saying account has been created. Using the event spec.

queue_data = {
'accountId': org_id,
}
payload = {
'specversion': '1.x-wip',
'type': message_type,
'source': f'https://api.pay.bcregistry.gov.bc.ca/v1/accounts/{org_id}',
'id': org_id,
'time': f'{datetime.now()}',
'datacontenttype': 'application/json',
'data': queue_data
'data': data
}
try:
await publish(payload=payload,
Expand Down

0 comments on commit 65c1cb2

Please sign in to comment.