Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Admin API: /_synapse/admin/v1/room/[room-id]/media always throws 500 error #5737

@zingi

Description

@zingi

Description

The ListMediaInRoom from the admin API does not get the auth token from the request. So every request to /_synapse/admin/v1/room/[room-id]/media fails with the error:

{
  "errcode": "M_UNKNOWN",
  "error": "Internal server error"
}
class ListMediaInRoom(RestServlet):
    """Lists all of the media in a given room.
    """

    PATTERNS = historical_admin_path_patterns("/room/(?P<room_id>[^/]+)/media")

    def __init__(self, hs):
        self.store = hs.get_datastore()

       # -------------------------
       # I guess here is missing:   
       # self.auth = hs.get_auth() 
       # ------------------------- 

    @defer.inlineCallbacks
    def on_GET(self, request, room_id):
        requester = yield self.auth.get_user_by_req(request)
        is_admin = yield self.auth.is_server_admin(requester.user)
        if not is_admin:
            raise AuthError(403, "You are not a server admin")

        local_mxcs, remote_mxcs = yield self.store.get_media_mxcs_in_room(room_id)

        defer.returnValue((200, {"local": local_mxcs, "remote": remote_mxcs}))

Steps to reproduce

  • Make a request to this endpoint.

It should return a list of the stored media in this room but always throws an error.

Version information

  • Homeserver: personal homeserver with ​restricted federation

If not matrix.org:

  • Version: v1.1.0 avhost docker

  • Install method: docker-compose up -d

  • Platform: VPS with Debian 9 64bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions