synapse/storage/account_data.py
def add_account_data_to_room(self, user_id, room_id, account_data_type, content):
        """Add some account_data to a room for a user.
        Args:
            user_id(str): The user to add a tag for.
            room_id(str): The room to add a tag for.
            account_data_type(str): The type of account_data to add.
            content(dict): A json object to associate with the tag.
        Returns:
            A deferred that completes once the account_data has been added.
        """
        content_json = json.dumps(content)

        with self._account_data_id_gen.get_next() as next_id:
            # no need to lock here as room_account_data has a unique constraint
            # on (user_id, room_id, account_data_type) so _simple_upsert will
            # retry if there is a conflict.
            yield self._simple_upsert(
                desc="add_room_account_data",
                table="room_account_data",
                keyvalues={
                    "user_id": user_id,
                    "room_id": room_id,
                    "account_data_type": account_data_type,
                },
                values={
                    "stream_id": next_id,
                    "content": content_json,
                },
                lock=False,
            )

            # it's theoretically possible for the above to succeed and the
            # below to fail - in which case we might reuse a stream id on
            # restart, and the above update might not get propagated. That
            # doesn't sound any worse than the whole update getting lost,
            # which is what would happen if we combined the two into one
            # transaction.
            yield self._update_max_stream_id(next_id)

            self._account_data_stream_cache.entity_has_changed(user_id, next_id)
            self.get_account_data_for_user.invalidate((user_id,))
            self.get_account_data_for_room.invalidate((user_id, room_id,))
            self.get_account_data_for_room_and_type.prefill(
                (user_id, room_id, account_data_type,), content,
            )

        result = self._account_data_id_gen.get_current_token()
        defer.returnValue(result)
Add some account_data to a room for a user.
        Args:
            user_id(str): The user to add a tag for.
            room_id(str): The room to add a tag for.
            account_data_type(str): The type of account_data to add.
            content(dict): A json object to associate with the tag.
        Returns:
            A deferred that completes once the account_data has been added.
        
Add some account_data to a room for a user.
Add some account_data to a room for a user .
def add_account_data_to_room(self, user_id, room_id, account_data_type, content):
        content_json = json.dumps(content)
        with self._account_data_id_gen.get_next() as next_id:
            yield self._simple_upsert(
                desc="add_room_account_data",
                table="room_account_data",
                keyvalues={
                    "user_id": user_id,
                    "room_id": room_id,
                    "account_data_type": account_data_type,
                },
                values={
                    "stream_id": next_id,
                    "content": content_json,
                },
                lock=False,
            )
            yield self._update_max_stream_id(next_id)
            self._account_data_stream_cache.entity_has_changed(user_id, next_id)
            self.get_account_data_for_user.invalidate((user_id,))
            self.get_account_data_for_room.invalidate((user_id, room_id,))
            self.get_account_data_for_room_and_type.prefill(
                (user_id, room_id, account_data_type,), content,
            )
        result = self._account_data_id_gen.get_current_token()
        defer.returnValue(result)
def add_account_data_to_room ( self , user_id , room_id , account_data_type , content ) : content_json = json . dumps ( content ) with self . _account_data_id_gen . get_next ( ) as next_id : yield self . _simple_upsert ( desc = "add_room_account_data" , table = "room_account_data" , keyvalues = { "user_id" : user_id , "room_id" : room_id , "account_data_type" : account_data_type , } , values = { "stream_id" : next_id , "content" : content_json , } , lock = False , ) yield self . _update_max_stream_id ( next_id ) self . _account_data_stream_cache . entity_has_changed ( user_id , next_id ) self . get_account_data_for_user . invalidate ( ( user_id , ) ) self . get_account_data_for_room . invalidate ( ( user_id , room_id , ) ) self . get_account_data_for_room_and_type . prefill ( ( user_id , room_id , account_data_type , ) , content , ) result = self . _account_data_id_gen . get_current_token ( ) defer . returnValue ( result )
Add some account_data to a room for a user.
Add some account_data to a room for a user .
"""Add some account_data to a room for a user.
        Args:
            user_id(str): The user to add a tag for.
            room_id(str): The room to add a tag for.
            account_data_type(str): The type of account_data to add.
            content(dict): A json object to associate with the tag.
        Returns:
            A deferred that completes once the account_data has been added.
        """ # no need to lock here as room_account_data has a unique constraint # on (user_id, room_id, account_data_type) so _simple_upsert will # retry if there is a conflict. # it's theoretically possible for the above to succeed and the # below to fail - in which case we might reuse a stream id on # restart, and the above update might not get propagated. That # doesn't sound any worse than the whole update getting lost, # which is what would happen if we combined the two into one # transaction.
A deferred that completes once the account_data has been added.
A deferred that completes once the account_data has been added .
self
user_id
The user to add a tag for.
The user to add a tag for .
room_id
The room to add a tag for.
The room to add a tag for .
account_data_type
The type of account_data to add.
The type of account_data to add .
content
A json object to associate with the tag.
A json object to associate with the tag .