Merge pull request #3273 from matrix-org/rav/server_notices_avatar_url
Allow overriding the server_notices user's avatar
This commit is contained in:
commit
6abcb5d22d
|
@ -44,13 +44,16 @@ section, which should look like this:
|
||||||
server_notices:
|
server_notices:
|
||||||
system_mxid_localpart: server
|
system_mxid_localpart: server
|
||||||
system_mxid_display_name: "Server Notices"
|
system_mxid_display_name: "Server Notices"
|
||||||
|
system_mxid_avatar_url: "mxc://server.com/oumMVlgDnLYFaPVkExemNVVZ"
|
||||||
room_name: "Server Notices"
|
room_name: "Server Notices"
|
||||||
```
|
```
|
||||||
|
|
||||||
The only compulsory setting is `system_mxid_localpart`, which defines the user
|
The only compulsory setting is `system_mxid_localpart`, which defines the user
|
||||||
id of the server notices user, as above. `system_mxid_display_name` and
|
id of the Server Notices user, as above. `room_name` defines the name of the
|
||||||
`room_name` define the displayname of the system notices user, and of
|
room which will be created.
|
||||||
the notices room, respectively.
|
|
||||||
|
`system_mxid_display_name` and `system_mxid_avatar_url` can be used to set the
|
||||||
|
displayname and avatar of the Server Notices user.
|
||||||
|
|
||||||
Sending notices
|
Sending notices
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -26,12 +26,13 @@ DEFAULT_CONFIG = """\
|
||||||
# setting, which defines the id of the user which will be used to send the
|
# setting, which defines the id of the user which will be used to send the
|
||||||
# notices.
|
# notices.
|
||||||
#
|
#
|
||||||
# It's also possible to override the room name, or the display name of the
|
# It's also possible to override the room name, the display name of the
|
||||||
# "notices" user.
|
# "notices" user, and the avatar for the user.
|
||||||
#
|
#
|
||||||
# server_notices:
|
# server_notices:
|
||||||
# system_mxid_localpart: notices
|
# system_mxid_localpart: notices
|
||||||
# system_mxid_display_name: "Server Notices"
|
# system_mxid_display_name: "Server Notices"
|
||||||
|
# system_mxid_avatar_url: "mxc://server.com/oumMVlgDnLYFaPVkExemNVVZ"
|
||||||
# room_name: "Server Notices"
|
# room_name: "Server Notices"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -48,6 +49,10 @@ class ServerNoticesConfig(Config):
|
||||||
The display name to use for the server notices user.
|
The display name to use for the server notices user.
|
||||||
None if server notices are not enabled.
|
None if server notices are not enabled.
|
||||||
|
|
||||||
|
server_notices_mxid_avatar_url (str|None):
|
||||||
|
The display name to use for the server notices user.
|
||||||
|
None if server notices are not enabled.
|
||||||
|
|
||||||
server_notices_room_name (str|None):
|
server_notices_room_name (str|None):
|
||||||
The name to use for the server notices room.
|
The name to use for the server notices room.
|
||||||
None if server notices are not enabled.
|
None if server notices are not enabled.
|
||||||
|
@ -56,6 +61,7 @@ class ServerNoticesConfig(Config):
|
||||||
super(ServerNoticesConfig, self).__init__()
|
super(ServerNoticesConfig, self).__init__()
|
||||||
self.server_notices_mxid = None
|
self.server_notices_mxid = None
|
||||||
self.server_notices_mxid_display_name = None
|
self.server_notices_mxid_display_name = None
|
||||||
|
self.server_notices_mxid_avatar_url = None
|
||||||
self.server_notices_room_name = None
|
self.server_notices_room_name = None
|
||||||
|
|
||||||
def read_config(self, config):
|
def read_config(self, config):
|
||||||
|
@ -68,7 +74,10 @@ class ServerNoticesConfig(Config):
|
||||||
mxid_localpart, self.server_name,
|
mxid_localpart, self.server_name,
|
||||||
).to_string()
|
).to_string()
|
||||||
self.server_notices_mxid_display_name = c.get(
|
self.server_notices_mxid_display_name = c.get(
|
||||||
'system_mxid_display_name', 'Server Notices',
|
'system_mxid_display_name', None,
|
||||||
|
)
|
||||||
|
self.server_notices_mxid_avatar_url = c.get(
|
||||||
|
'system_mxid_avatar_url', None,
|
||||||
)
|
)
|
||||||
# todo: i18n
|
# todo: i18n
|
||||||
self.server_notices_room_name = c.get('room_name', "Server Notices")
|
self.server_notices_room_name = c.get('room_name', "Server Notices")
|
||||||
|
|
|
@ -113,6 +113,19 @@ class ServerNoticesManager(object):
|
||||||
# apparently no existing notice room: create a new one
|
# apparently no existing notice room: create a new one
|
||||||
logger.info("Creating server notices room for %s", user_id)
|
logger.info("Creating server notices room for %s", user_id)
|
||||||
|
|
||||||
|
# see if we want to override the profile info for the server user.
|
||||||
|
# note that if we want to override either the display name or the
|
||||||
|
# avatar, we have to use both.
|
||||||
|
join_profile = None
|
||||||
|
if (
|
||||||
|
self._config.server_notices_mxid_display_name is not None or
|
||||||
|
self._config.server_notices_mxid_avatar_url is not None
|
||||||
|
):
|
||||||
|
join_profile = {
|
||||||
|
"displayname": self._config.server_notices_mxid_display_name,
|
||||||
|
"avatar_url": self._config.server_notices_mxid_avatar_url,
|
||||||
|
}
|
||||||
|
|
||||||
requester = create_requester(system_mxid)
|
requester = create_requester(system_mxid)
|
||||||
info = yield self._room_creation_handler.create_room(
|
info = yield self._room_creation_handler.create_room(
|
||||||
requester,
|
requester,
|
||||||
|
@ -125,9 +138,7 @@ class ServerNoticesManager(object):
|
||||||
"invite": (user_id,)
|
"invite": (user_id,)
|
||||||
},
|
},
|
||||||
ratelimit=False,
|
ratelimit=False,
|
||||||
creator_join_profile={
|
creator_join_profile=join_profile,
|
||||||
"displayname": self._config.server_notices_mxid_display_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
room_id = info['room_id']
|
room_id = info['room_id']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue