summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2020-06-01 16:34:33 +0200
committerGitHub <noreply@github.com>2020-06-01 15:34:33 +0100
commit901b1fa561e3cc661d78aa96d59802cf2078cb0d (patch)
tree83fda50c28ac01aafd2860e464feefe73c49a461 /synapse/rest
parentImprove performance of _get_state_groups_from_groups_txn (#7567) (diff)
downloadsynapse-901b1fa561e3cc661d78aa96d59802cf2078cb0d.tar.xz
Email notifications for new users when creating via the Admin API. (#7267)
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/admin/users.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/rest/admin/users.py b/synapse/rest/admin/users.py
index e7f6928c85..82251dbe5f 100644
--- a/synapse/rest/admin/users.py
+++ b/synapse/rest/admin/users.py
@@ -142,6 +142,7 @@ class UserRestServletV2(RestServlet):
         self.set_password_handler = hs.get_set_password_handler()
         self.deactivate_account_handler = hs.get_deactivate_account_handler()
         self.registration_handler = hs.get_registration_handler()
+        self.pusher_pool = hs.get_pusherpool()
 
     async def on_GET(self, request, user_id):
         await assert_requester_is_admin(self.auth, request)
@@ -281,6 +282,21 @@ class UserRestServletV2(RestServlet):
                     await self.auth_handler.add_threepid(
                         user_id, threepid["medium"], threepid["address"], current_time
                     )
+                    if (
+                        self.hs.config.email_enable_notifs
+                        and self.hs.config.email_notif_for_new_users
+                    ):
+                        await self.pusher_pool.add_pusher(
+                            user_id=user_id,
+                            access_token=None,
+                            kind="email",
+                            app_id="m.email",
+                            app_display_name="Email Notifications",
+                            device_display_name=threepid["address"],
+                            pushkey=threepid["address"],
+                            lang=None,  # We don't know a user's language here
+                            data={},
+                        )
 
             if "avatar_url" in body and type(body["avatar_url"]) == str:
                 await self.profile_handler.set_avatar_url(