Don’t accept cancel or update via broadcast API

We don’t support these methods at the moment. Instead we were just
ignoring the `msgType` field, so issuing one of these commands would
cause a new alert to be broadcast 🙃

We might want to support `Cancel` in the future, but for now let’s
reject anything that isn’t `Alert` (CAP terminology for the initial
broadcast).
This commit is contained in:
Chris Hill-Scott
2021-02-15 09:32:33 +00:00
parent a1e539e785
commit e8a79f5413
4 changed files with 212 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ def cap_xml_to_dict(cap_xml):
# This function assumes that its being passed valid CAP XML
cap = BeautifulSoup(cap_xml, "xml")
return {
"msgType": cap.alert.msgType.text,
"reference": cap.alert.identifier.text,
"category": cap.alert.info.category.text,
"expires": cap.alert.info.expires.text,

View File

@@ -2,6 +2,7 @@ post_broadcast_schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
"msgType",
"reference",
"category",
"content",
@@ -52,6 +53,18 @@ post_broadcast_schema = {
"$ref": "#/definitions/area",
},
},
"msgType": {
"type": "string",
"enum": [
"Alert",
# The following are valid CAP but not supported by our
# API at the moment
# "Update",
# "Cancel",
# "Ack",
# "Error",
],
}
},
"definitions": {
"area": {