Send messages conforming new facebook policy (#32516)

pull/32650/head
Paulus Schoutsen 2020-03-05 17:19:30 -08:00
parent 6062854666
commit c0dcd9c674
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"]}