Skip to content

Commit

Permalink
Send messages conforming new facebook policy (home-assistant#32516)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Mar 6, 2020
1 parent 19254ee commit e02042b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion homeassistant/components/facebook/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ def send_message(self, message="", **kwargs):
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),
Expand Down
11 changes: 10 additions & 1 deletion tests/components/facebook/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def test_send_simple_message(self, mock):
expected_body = {
"recipient": {"phone_number": target[0]},
"message": {"text": message},
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
assert mock.last_request.json() == expected_body

Expand All @@ -53,6 +55,8 @@ def test_sending_multiple_messages(self, mock):
expected_body = {
"recipient": {"phone_number": target},
"message": {"text": message},
"messaging_type": "MESSAGE_TAG",
"tag": "ACCOUNT_UPDATE",
}
assert request.json() == expected_body

Expand All @@ -77,7 +81,12 @@ def test_send_message_attachment(self, mock):
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"]}
Expand Down

0 comments on commit e02042b

Please sign in to comment.