

@defer.inlineCallbacks
def add_tag_to_room(self, user_id, room_id, tag, content):
    'Add a tag to a room for a user.\n        Args:\n            user_id(str): The user to add a tag for.\n            room_id(str): The room to add a tag for.\n            tag(str): The tag name to add.\n            content(dict): A json object to associate with the tag.\n        Returns:\n            A deferred that completes once the tag has been added.\n        '
    content_json = json.dumps(content)

    def add_tag_txn(txn, next_id):
        self._simple_upsert_txn(txn, table='room_tags', keyvalues={
            'user_id': user_id,
            'room_id': room_id,
            'tag': tag,
        }, values={
            'content': content_json,
        })
        self._update_revision_txn(txn, user_id, room_id, next_id)
    with self._account_data_id_gen.get_next() as next_id:
        (yield self.runInteraction('add_tag', add_tag_txn, next_id))
    self.get_tags_for_user.invalidate((user_id,))
    result = self._account_data_id_gen.get_max_token()
    defer.returnValue(result)

dataset/ETHPy150Open matrix-org/synapse/synapse/storage/tags.py TagsStore.add_tag_to_room/original