synapse/handlers/device.py
def check_device_registered(self, user_id, device_id,
                                initial_device_display_name=None):
        """
        If the given device has not been registered, register it with the
        supplied display name.

        If no device_id is supplied, we make one up.

        Args:
            user_id (str):  @user:id
            device_id (str | None): device id supplied by client
            initial_device_display_name (str | None): device display name from
                 client
        Returns:
            str: device id (generated if none was supplied)
        """
        if device_id is not None:
            new_device = yield self.store.store_device(
                user_id=user_id,
                device_id=device_id,
                initial_device_display_name=initial_device_display_name,
            )
            if new_device:
                yield self.notify_device_update(user_id, [device_id])
            defer.returnValue(device_id)

        # if the device id is not specified, we'll autogen one, but loop a few
        # times in case of a clash.
        attempts = 0
        while attempts < 5:
            device_id = stringutils.random_string(10).upper()
            new_device = yield self.store.store_device(
                user_id=user_id,
                device_id=device_id,
                initial_device_display_name=initial_device_display_name,
            )
            if new_device:
                yield self.notify_device_update(user_id, [device_id])
                defer.returnValue(device_id)
            attempts += 1

        raise errors.StoreError(500, "Couldn't generate a device ID.")

        If the given device has not been registered, register it with the
        supplied display name.

        If no device_id is supplied, we make one up.

        Args:
            user_id (str):  @user:id
            device_id (str | None): device id supplied by client
            initial_device_display_name (str | None): device display name from
                 client
        Returns:
            str: device id (generated if none was supplied)
        
If the given device has not been registered, register it with the
supplied display name.

If no device_id is supplied, we make one up.
If the given device has not been registered register it with the supplied display name . If no device_id is supplied we make one up .
def check_device_registered(self, user_id, device_id,
                                initial_device_display_name=None):
        if device_id is not None:
            new_device = yield self.store.store_device(
                user_id=user_id,
                device_id=device_id,
                initial_device_display_name=initial_device_display_name,
            )
            if new_device:
                yield self.notify_device_update(user_id, [device_id])
            defer.returnValue(device_id)
        attempts = 0
        while attempts < 5:
            device_id = stringutils.random_string(10).upper()
            new_device = yield self.store.store_device(
                user_id=user_id,
                device_id=device_id,
                initial_device_display_name=initial_device_display_name,
            )
            if new_device:
                yield self.notify_device_update(user_id, [device_id])
                defer.returnValue(device_id)
            attempts += 1
        raise errors.StoreError(500, "Couldn't generate a device ID.")
def check_device_registered ( self , user_id , device_id , initial_device_display_name = None ) : if device_id is not None : new_device = yield self . store . store_device ( user_id = user_id , device_id = device_id , initial_device_display_name = initial_device_display_name , ) if new_device : yield self . notify_device_update ( user_id , [ device_id ] ) defer . returnValue ( device_id ) attempts = 0 while attempts < 5 : device_id = stringutils . random_string ( 10 ) . upper ( ) new_device = yield self . store . store_device ( user_id = user_id , device_id = device_id , initial_device_display_name = initial_device_display_name , ) if new_device : yield self . notify_device_update ( user_id , [ device_id ] ) defer . returnValue ( device_id ) attempts += 1 raise errors . StoreError ( 500 , "Couldn't generate a device ID." )
If the given device has not been registered, register it with the
supplied display name.
If the given device has not been registered register it with the supplied display name .
"""
        If the given device has not been registered, register it with the
        supplied display name.

        If no device_id is supplied, we make one up.

        Args:
            user_id (str):  @user:id
            device_id (str | None): device id supplied by client
            initial_device_display_name (str | None): device display name from
                 client
        Returns:
            str: device id (generated if none was supplied)
        """ # if the device id is not specified, we'll autogen one, but loop a few # times in case of a clash.
device id (generated if none was supplied)
device id ( generated if none was supplied )
str
self
user_id
None
device_id
device id supplied by client
device id supplied by client
initial_device_display_name
device display name from
client
device display name from client