From bf824249bc48158f1d3e8d167987e1d379e39e5a Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sun, 19 Jan 2025 11:40:09 -0500 Subject: [PATCH] Office 365 posts include title and subject now --- apprise/plugins/office365.py | 16 +++++++--------- test/test_plugin_office365.py | 14 +++++++++++++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/apprise/plugins/office365.py b/apprise/plugins/office365.py index c0069f919..406200574 100644 --- a/apprise/plugins/office365.py +++ b/apprise/plugins/office365.py @@ -366,15 +366,13 @@ def send(self, body, title='', notify_type=NotifyType.INFO, attach=None, if self.from_email: # Apply from email if it is known - payload.update({ - 'message': { - 'from': { - "emailAddress": { - "address": self.from_email, - "name": self.from_name or self.app_id, - } - }, - } + payload['message'].update({ + 'from': { + "emailAddress": { + "address": self.from_email, + "name": self.from_name or self.app_id, + } + }, }) # Create a copy of the email list diff --git a/test/test_plugin_office365.py b/test/test_plugin_office365.py index a1541e319..91b354528 100644 --- a/test/test_plugin_office365.py +++ b/test/test_plugin_office365.py @@ -32,7 +32,7 @@ import pytest import requests from datetime import datetime -from json import dumps +from json import dumps, loads from apprise import Apprise from apprise import NotifyType from apprise import AppriseAttachment @@ -541,6 +541,18 @@ def test_plugin_office365_queries(mock_post, mock_get, mock_put): 'https://login.microsoftonline.com/{}/oauth2/v2.0/token'.format(tenant) assert mock_post.call_args_list[1][0][0] == \ 'https://graph.microsoft.com/v1.0/users/abc-1234-object-id/sendMail' + payload = loads(mock_post.call_args_list[1][1]['data']) + assert payload == { + 'message': { + 'subject': 'title', + 'body': { + 'contentType': 'HTML', + 'content': 'body', + }, + 'toRecipients': [ + {'emailAddress': {'address': 'target@example.ca'}}]}, + 'saveToSentItems': 'true', + } mock_post.reset_mock() # Now test a case where we just couldn't get any email details from the