mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 19:47:05 +03:00
Default device_display_name to null
It turns out that it's more useful to return a null device display name (and let clients decide how to handle it: eg, falling back to device_id) than using a constant string like "unknown device".
This commit is contained in:
parent
9a2f296fa2
commit
4fec5e57be
4 changed files with 23 additions and 5 deletions
|
@ -29,7 +29,7 @@ class DeviceHandler(BaseHandler):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def check_device_registered(self, user_id, device_id,
|
||||
initial_device_display_name):
|
||||
initial_device_display_name = None):
|
||||
"""
|
||||
If the given device has not been registered, register it with the
|
||||
supplied display name.
|
||||
|
|
|
@ -130,9 +130,7 @@ class KeyUploadServlet(RestServlet):
|
|||
# old access_token without an associated device_id. Either way, we
|
||||
# need to double-check the device is registered to avoid ending up with
|
||||
# keys without a corresponding device.
|
||||
self.device_handler.check_device_registered(
|
||||
user_id, device_id, "unknown device"
|
||||
)
|
||||
self.device_handler.check_device_registered(user_id, device_id)
|
||||
|
||||
result = yield self.store.count_e2e_one_time_keys(user_id, device_id)
|
||||
defer.returnValue((200, {"one_time_key_counts": result}))
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
-- make sure that we have a device record for each set of E2E keys, so that the
|
||||
-- user can delete them if they like.
|
||||
INSERT INTO devices
|
||||
SELECT user_id, device_id, 'unknown device' FROM e2e_device_keys_json;
|
||||
SELECT user_id, device_id, NULL FROM e2e_device_keys_json;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* Copyright 2016 OpenMarket Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
-- a previous version of the "devices_for_e2e_keys" delta set all the device
|
||||
-- names to "unknown device". This wasn't terribly helpful
|
||||
UPDATE devices
|
||||
SET display_name = NULL
|
||||
WHERE display_name = 'unknown device';
|
Loading…
Reference in a new issue