Skip to content

Commit

Permalink
Add missing fields to Sendgrid webhook schema
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Nov 25, 2019
1 parent 89fc35a commit 800e1f9
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docker/integtest/3-receive-email-for-client.sh
Expand Up @@ -16,9 +16,13 @@ client_id="$(jq -r '.client_id' < "${out_dir}/register1.json")"
# this simulates sendgrid delivering an email to the service
http --check-status -f POST \
"http://nginx:8888/api/email/sendgrid/${client_id}" \
"dkim={@sendgrid.com : pass}" \
"SPF=pass" \
"email=@${email_to_receive}"

# simulate delivery of the same email to the second mailbox
http --check-status -f POST \
"http://nginx:8888/api/email/sendgrid/${client_id}" \
"dkim={@sendgrid.com : pass}" \
"SPF=pass" \
"email=@${email_to_receive}"
2 changes: 1 addition & 1 deletion opwen_email_server/actions.py
Expand Up @@ -198,7 +198,7 @@ def __init__(self, auth: AzureAuth, raw_email_storage: AzureTextStorage, next_ta
self._raw_email_storage = raw_email_storage
self._next_task = next_task

def _action(self, client_id, email): # type: ignore
def _action(self, client_id, email, **sendgrid_args): # type: ignore
domain = self._auth.domain_for(client_id)
if not domain:
self.log_event(events.UNREGISTERED_CLIENT, {'client_id': client_id}) # noqa: E501 # yapf: disable
Expand Down
102 changes: 99 additions & 3 deletions opwen_email_server/swagger/email-receive.yaml
Expand Up @@ -17,7 +17,19 @@ paths:
- multipart/form-data
parameters:
- $ref: '#/parameters/ClientId'
- $ref: '#/parameters/MimeEmail'
- $ref: '#/parameters/SendgridEmail'
- $ref: '#/parameters/SendgridDkim'
- $ref: '#/parameters/SendgridTo'
- $ref: '#/parameters/SendgridCc'
- $ref: '#/parameters/SendgridFrom'
- $ref: '#/parameters/SendgridText'
- $ref: '#/parameters/SendgridSenderIp'
- $ref: '#/parameters/SendgridSpamReport'
- $ref: '#/parameters/SendgridEnvelope'
- $ref: '#/parameters/SendgridSubject'
- $ref: '#/parameters/SendgridSpamScore'
- $ref: '#/parameters/SendgridCharsets'
- $ref: '#/parameters/SendgridSpf'
responses:
200:
description: The email was successfully received. No need to retry it.
Expand All @@ -33,9 +45,93 @@ parameters:
type: string
required: true

MimeEmail:
SendgridEmail:
name: email
description: Email represented as a MIME string.
description: A string containing the email headers, date, body, and attachments.
in: formData
type: string
required: true

SendgridDkim:
name: dkim
description: A string containing the verification results of any DKIM and domain keys signatures in the message.
in: formData
type: string
required: false

SendgridTo:
name: to
description: Email recipient field as taken from the message headers.
in: formData
type: string
required: false

SendgridCc:
name: cc
description: Email cc field, as taken from the message headers.
in: formData
type: string
required: false

SendgridFrom:
name: from
description: Email sender, as taken from the message headers.
in: formData
type: string
required: false

SendgridText:
name: text
description: Email body in plaintext formatting.
in: formData
type: string
required: false

SendgridSenderIp:
name: sender_ip
description: Email sender IP address.
in: formData
type: string
required: false

SendgridSpamReport:
name: spam_report
description: Spam Assassin's spam report.
in: formData
type: string
required: false

SendgridEnvelope:
name: envelope
description: A string containing the SMTP envelope. This will have 2 variables; to, which is an single-element array containing the addresses that received the email, and from, which is the return path for the message.
in: formData
type: string
required: false

SendgridSubject:
name: subject
description: Email subject.
in: formData
type: string
required: false

SendgridSpamScore:
name: spam_score
description: Spam Assassin's rating for whether or not this is spam.
in: formData
type: string
required: false

SendgridCharsets:
name: charsets
description: A string containing the character sets of the fields extracted from the message.
in: formData
type: string
required: false

SendgridSpf:
name: SPF
description: The results of the Sender Policy Framework verification of the message sender and receiving IP address.
in: formData
type: string
required: false

0 comments on commit 800e1f9

Please sign in to comment.