Send messages conforming new facebook policy (#32516)

This commit is contained in:
Paulus Schoutsen 2020-03-05 17:19:30 -08:00 committed by GitHub
parent 19254eee30
commit e02042b33e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -97,7 +97,12 @@ class FacebookNotificationService(BaseNotificationService):
else:
recipient = {"id": target}
body = {"recipient": recipient, "message": body_message}
body = {
"recipient": recipient,
"message": body_message,
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
resp = requests.post(
BASE_URL,
data=json.dumps(body),

View file

@ -30,6 +30,8 @@ class TestFacebook(unittest.TestCase):
expected_body = {
"recipient": {"phone_number": target[0]},
"message": {"text": message},
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
assert mock.last_request.json() == expected_body
@ -53,6 +55,8 @@ class TestFacebook(unittest.TestCase):
expected_body = {
"recipient": {"phone_number": target},
"message": {"text": message},
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
assert request.json() == expected_body
@ -77,7 +81,12 @@ class TestFacebook(unittest.TestCase):
assert mock.called
assert mock.call_count == 1
expected_body = {"recipient": {"phone_number": target[0]}, "message": data}
expected_body = {
"recipient": {"phone_number": target[0]},
"message": data,
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
assert mock.last_request.json() == expected_body
expected_params = {"access_token": ["page-access-token"]}