getRoomByShareTokenRaw method
- @experimental
Returns the token of the room associated to the file of the given share token.
This is the counterpart of self::getRoomByFileId() for share tokens instead of file ids, 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 file id of the given share token a new room is created; the new room is a public room associated with a "file" object with the file id of the given share token. 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 publicly shared (like a link share, for example); an error is returned otherwise. Besides the token of the room this also returns the current user ID and display name, if any; this is needed by the Talk sidebar to know the actual current user, as the public share page uses the incognito mode and thus logged-in users as seen as guests.
This method and the response it returns is experimental. The API might change without a major version bump.
Returns a Future containing a DynamiteRawResponse with the raw HttpClientResponse and serialization helpers. Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
apiVersion
Defaults tov1
.shareToken
Token of the file share.oCSAPIRequest
Required to be true for the API request to pass. Defaults totrue
.
Status codes:
- 200: Room token and user info returned
- 400: Rooms not allowed for shares
- 404: Share not found
See:
- getRoomByShareToken for an operation that returns a DynamiteResponse with a stable API.
Implementation
@experimental
DynamiteRawResponse<FilesIntegrationGetRoomByShareTokenResponseApplicationJson, void> getRoomByShareTokenRaw({
required String shareToken,
FilesIntegrationGetRoomByShareTokenApiVersion? apiVersion,
bool? oCSAPIRequest,
}) {
final _parameters = <String, dynamic>{};
final _headers = <String, String>{
'Accept': 'application/json',
};
// coverage:ignore-start
final authentication = _rootClient.authentications.firstWhereOrNull(
(auth) => switch (auth) {
DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true,
_ => false,
},
);
if (authentication != null) {
_headers.addAll(
authentication.headers,
);
}
// coverage:ignore-end
final $shareToken = jsonSerializers.serialize(shareToken, specifiedType: const FullType(String));
dynamite_utils.checkPattern($shareToken as String?, RegExp(r'^.+$'), 'shareToken');
_parameters['shareToken'] = $shareToken;
var $apiVersion = jsonSerializers.serialize(
apiVersion,
specifiedType: const FullType(FilesIntegrationGetRoomByShareTokenApiVersion),
);
$apiVersion ??= 'v1';
_parameters['apiVersion'] = $apiVersion;
var $oCSAPIRequest = jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
$oCSAPIRequest ??= true;
_headers['OCS-APIRequest'] = const dynamite_utils.HeaderEncoder().convert($oCSAPIRequest);
final _path = UriTemplate('/ocs/v2.php/apps/spreed/api/{apiVersion}/publicshare/{shareToken}').expand(_parameters);
return DynamiteRawResponse<FilesIntegrationGetRoomByShareTokenResponseApplicationJson, void>(
response: _rootClient.executeRequest(
'get',
_path,
_headers,
null,
const {200},
),
bodyType: const FullType(FilesIntegrationGetRoomByShareTokenResponseApplicationJson),
headersType: null,
serializers: jsonSerializers,
);
}