synapse/storage/room.py
def _get_media_mxcs_in_room_txn(self, txn, room_id):
        """Retrieves all the local and remote media MXC URIs in a given room

        Args:
            txn (cursor)
            room_id (str)

        Returns:
            The local and remote media as a lists of tuples where the key is
            the hostname and the value is the media ID.
        """
        mxc_re = re.compile("^mxc://([^/]+)/([^/#?]+)")

        next_token = self.get_current_events_token() + 1
        local_media_mxcs = []
        remote_media_mxcs = []

        while next_token:
            sql = """
                SELECT stream_ordering, json FROM events
                JOIN event_json USING (room_id, event_id)
                WHERE room_id = ?
                    AND stream_ordering < ?
                    AND contains_url = ? AND outlier = ?
                ORDER BY stream_ordering DESC
                LIMIT ?
            """
            txn.execute(sql, (room_id, next_token, True, False, 100))

            next_token = None
            for stream_ordering, content_json in txn:
                next_token = stream_ordering
                event_json = json.loads(content_json)
                content = event_json["content"]
                content_url = content.get("url")
                thumbnail_url = content.get("info", {}).get("thumbnail_url")

                for url in (content_url, thumbnail_url):
                    if not url:
                        continue
                    matches = mxc_re.match(url)
                    if matches:
                        hostname = matches.group(1)
                        media_id = matches.group(2)
                        if hostname == self.hs.hostname:
                            local_media_mxcs.append(media_id)
                        else:
                            remote_media_mxcs.append((hostname, media_id))

        return local_media_mxcs, remote_media_mxcs
Retrieves all the local and remote media MXC URIs in a given room

        Args:
            txn (cursor)
            room_id (str)

        Returns:
            The local and remote media as a lists of tuples where the key is
            the hostname and the value is the media ID.
        
Retrieves all the local and remote media MXC URIs in a given room
Args:
txn (cursor)
room_id (str)

The local and remote media as a lists of tuples where the key is
the hostname and the value is the media ID.
Retrieves all the local and remote media MXC URIs in a given room Args : txn ( cursor ) room_id ( str ) The local and remote media as a lists of tuples where the key is the hostname and the value is the media ID .
def _get_media_mxcs_in_room_txn(self, txn, room_id):
        mxc_re = re.compile("^mxc://([^/]+)/([^/#?]+)")
        next_token = self.get_current_events_token() + 1
        local_media_mxcs = []
        remote_media_mxcs = []
        while next_token:
            sql = """
                SELECT stream_ordering, json FROM events
                JOIN event_json USING (room_id, event_id)
                WHERE room_id = ?
                    AND stream_ordering < ?
                    AND contains_url = ? AND outlier = ?
                ORDER BY stream_ordering DESC
                LIMIT ?
            """
            txn.execute(sql, (room_id, next_token, True, False, 100))
            next_token = None
            for stream_ordering, content_json in txn:
                next_token = stream_ordering
                event_json = json.loads(content_json)
                content = event_json["content"]
                content_url = content.get("url")
                thumbnail_url = content.get("info", {}).get("thumbnail_url")
                for url in (content_url, thumbnail_url):
                    if not url:
                        continue
                    matches = mxc_re.match(url)
                    if matches:
                        hostname = matches.group(1)
                        media_id = matches.group(2)
                        if hostname == self.hs.hostname:
                            local_media_mxcs.append(media_id)
                        else:
                            remote_media_mxcs.append((hostname, media_id))
        return local_media_mxcs, remote_media_mxcs
def _get_media_mxcs_in_room_txn ( self , txn , room_id ) : mxc_re = re . compile ( "^mxc://([^/]+)/([^/#?]+)" ) next_token = self . get_current_events_token ( ) + 1 local_media_mxcs = [ ] remote_media_mxcs = [ ] while next_token : sql = """
                SELECT stream_ordering, json FROM events
                JOIN event_json USING (room_id, event_id)
                WHERE room_id = ?
                    AND stream_ordering < ?
                    AND contains_url = ? AND outlier = ?
                ORDER BY stream_ordering DESC
                LIMIT ?
            """ txn . execute ( sql , ( room_id , next_token , True , False , 100 ) ) next_token = None for stream_ordering , content_json in txn : next_token = stream_ordering event_json = json . loads ( content_json ) content = event_json [ "content" ] content_url = content . get ( "url" ) thumbnail_url = content . get ( "info" , { } ) . get ( "thumbnail_url" ) for url in ( content_url , thumbnail_url ) : if not url : continue matches = mxc_re . match ( url ) if matches : hostname = matches . group ( 1 ) media_id = matches . group ( 2 ) if hostname == self . hs . hostname : local_media_mxcs . append ( media_id ) else : remote_media_mxcs . append ( ( hostname , media_id ) ) return local_media_mxcs , remote_media_mxcs
Retrieves all the local and remote media MXC URIs in a given room
Args:
txn (cursor)
room_id (str)
Retrieves all the local and remote media MXC URIs in a given room Args : txn ( cursor ) room_id ( str )
"""Retrieves all the local and remote media MXC URIs in a given room

        Args:
            txn (cursor)
            room_id (str)

        Returns:
            The local and remote media as a lists of tuples where the key is
            the hostname and the value is the media ID.
        """
self
txn
room_id