Skip to content

Commit

Permalink
adds logic for gcn.notices. notices, replace healpix_file if present
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota002 committed Jan 29, 2024
1 parent beaa77c commit 3f43a69
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcn_email/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from email.message import EmailMessage
import logging
import os
import json

import boto3
from boto3.dynamodb.conditions import Key
Expand Down Expand Up @@ -80,6 +81,11 @@ def kafka_message_to_email(message):
email_message.add_attachment(
message.value(), filename='notice.xml',
maintype='application', subtype='xml')
elif topic.startswith('gcn.notices.'):
value = json.loads(message.value().decode())
if 'healpix_file' in value:
value['healpix_file'] = 'This content is too large for email. To receive it, see https://gcn.nasa.gov/quickstart'
email_message.set_content(json.dumps(value, indent=4))
else:
email_message.add_attachment(
message.value(), filename='notice.bin',
Expand Down

0 comments on commit 3f43a69

Please sign in to comment.