$getRoomByFileId_Request method

  1. @experimental
Request $getRoomByFileId_Request({
  1. required String fileId,
  2. FilesIntegrationGetRoomByFileIdApiVersion? apiVersion,
  3. bool? oCSAPIRequest,
})

Get the token of the room associated to the given file id.

This is the counterpart of self::getRoomByShareToken() for file ids instead of share tokens, although both return the same room token if the given file id and share token refer to the same file. If there is no room associated to the given file id a new room is created; the new room is a public room associated with a "file" object with the given file id. Unlike normal rooms in which the owner is the user that created the room these are special rooms without owner (although self joined users with direct access to the file become persistent participants automatically when they join until they explicitly leave or no longer have access to the file). In any case, to create or even get the token of the room, the file must be shared and the user must be the owner of a public share of the file (like a link share, for example) or have direct access to that file; an error is returned otherwise. A user has direct access to a file if she has access to it (or to an ancestor) through a user, group, circle or room share (but not through a link share, for example), or if she is the owner of such a file.

Returns a DynamiteRequest backing the getRoomByFileId operation. Throws a DynamiteApiException if the API call does not return an expected status code.

Parameters:

  • apiVersion Defaults to "v1".
  • fileId ID of the file.
  • oCSAPIRequest Required to be true for the API request to pass. Defaults to true.

Status codes:

  • 200: Room token returned
  • 400: Rooms not allowed for shares
  • 404: Share not found

See:

Implementation

@_i2.experimental
_i3.Request $getRoomByFileId_Request({
  required String fileId,
  FilesIntegrationGetRoomByFileIdApiVersion? apiVersion,
  bool? oCSAPIRequest,
}) {
  final _parameters = <String, Object?>{};
  final $fileId = _$jsonSerializers.serialize(fileId, specifiedType: const FullType(String));
  _i4.checkString(
    $fileId,
    'fileId',
    pattern: RegExp(r'^.+$'),
  );
  _parameters['fileId'] = $fileId;

  var $apiVersion = _$jsonSerializers.serialize(
    apiVersion,
    specifiedType: const FullType(FilesIntegrationGetRoomByFileIdApiVersion),
  );
  $apiVersion ??= 'v1';
  _parameters['apiVersion'] = $apiVersion;

  final _path = _i5.UriTemplate('/ocs/v2.php/apps/spreed/api/{apiVersion}/file/{fileId}').expand(_parameters);
  final _uri = Uri.parse('${_rootClient.baseURL}$_path');
  final _request = _i3.Request('get', _uri);
  _request.headers['Accept'] = 'application/json';
// coverage:ignore-start
  final authentication = _rootClient.authentications?.firstWhereOrNull(
    (auth) => switch (auth) {
      _i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
      _ => false,
    },
  );

  if (authentication != null) {
    _request.headers.addAll(
      authentication.headers,
    );
  } else {
    throw Exception('Missing authentication for bearer_auth or basic_auth');
  }

// coverage:ignore-end
  var $oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
  $oCSAPIRequest ??= true;
  _request.headers['OCS-APIRequest'] = const _i4.HeaderEncoder().convert($oCSAPIRequest);

  return _request;
}