diff --git a/.gitmodules b/.gitmodules index 0eb5a928..14144531 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "external/nextcloud-notifications"] path = external/nextcloud-notifications url = https://github.com/nextcloud/notifications +[submodule "external/nextcloud-uppush"] + path = external/nextcloud-uppush + url = git@github.com:UP-NextPush/server-app.git diff --git a/external/nextcloud-uppush b/external/nextcloud-uppush new file mode 160000 index 00000000..ea2264cc --- /dev/null +++ b/external/nextcloud-uppush @@ -0,0 +1 @@ +Subproject commit ea2264cc05443f295a662030ad13c4a40c744eb9 diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index 8a392ccf..7c0bde82 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -157,6 +157,7 @@ class NextcloudClient { NextcloudNotesClient get notes => NextcloudNotesClient(this); NextcloudNotificationsClient get notifications => NextcloudNotificationsClient(this); NextcloudProvisioningApiClient get provisioningApi => NextcloudProvisioningApiClient(this); + NextcloudUnifiedPushProviderClient get unifiedPushProvider => NextcloudUnifiedPushProviderClient(this); NextcloudUserStatusClient get userStatus => NextcloudUserStatusClient(this); } @@ -1177,6 +1178,240 @@ class NextcloudProvisioningApiClient { } } +class NextcloudUnifiedPushProviderClient { + NextcloudUnifiedPushProviderClient(this.rootClient); + + final NextcloudClient rootClient; + + /// Check if the UnifiedPush provider is present + Future check() async { + var path = '/index.php/apps/uppush'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + final response = await rootClient.doRequest( + 'get', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Set keepalive interval. + Future setKeepalive( + {required String keepalive}) async { + var path = '/index.php/apps/uppush/keepalive'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + queryParameters['keepalive'] = keepalive; + final response = await rootClient.doRequest( + 'put', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Request to create a new deviceId. + Future createDevice( + {required String deviceName}) async { + var path = '/index.php/apps/uppush/device'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + queryParameters['deviceName'] = deviceName; + final response = await rootClient.doRequest( + 'put', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Request to get push messages. + + /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app) + Future syncDevice( + {required String deviceId}) async { + var path = '/index.php/apps/uppush/device/{deviceId}'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); + final response = await rootClient.doRequest( + 'get', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 401) { + return NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Delete a device. + Future deleteDevice( + {required String deviceId}) async { + var path = '/index.php/apps/uppush/device/{deviceId}'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); + final response = await rootClient.doRequest( + 'delete', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Create an authorization token for a new 3rd party service. + Future createApp({ + required String deviceId, + required String appName, + }) async { + var path = '/index.php/apps/uppush/app'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + queryParameters['deviceId'] = deviceId; + queryParameters['appName'] = appName; + final response = await rootClient.doRequest( + 'put', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Delete an authorization token. + Future deleteApp({required String token}) async { + var path = '/index.php/apps/uppush/app/{token}'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); + final response = await rootClient.doRequest( + 'delete', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Unifiedpush discovery Following specifications + Future unifiedpushDiscovery( + {required String token}) async { + var path = '/index.php/apps/uppush/push/{token}'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); + final response = await rootClient.doRequest( + 'get', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Receive notifications from 3rd parties. + Future push({required String token}) async { + var path = '/index.php/apps/uppush/push/{token}'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); + final response = await rootClient.doRequest( + 'post', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 201) { + return NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Matrix Gateway discovery + Future gatewayMatrixDiscovery() async { + var path = '/index.php/apps/uppush/gateway/matrix'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + final response = await rootClient.doRequest( + 'get', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } + + /// Matrix Gateway + Future gatewayMatrix() async { + var path = '/index.php/apps/uppush/gateway/matrix'; + final queryParameters = {}; + final headers = {}; + Uint8List? body; + final response = await rootClient.doRequest( + 'post', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJson( + json.decode(utf8.decode(response.body) as String) as Map); + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } +} + class NextcloudUserStatusClient { NextcloudUserStatusClient(this.rootClient); @@ -4523,6 +4758,338 @@ class NextcloudProvisioningApiUser { static String? toJsonString(NextcloudProvisioningApiUser? data) => data == null ? null : json.encode(data.toJson()); } +@JsonSerializable() +class NextcloudUnifiedPushProviderCheckResponse200ApplicationJson { + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderCheckResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJson(json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderCheckResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderCheckResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson { + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson { + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson({ + required this.success, + required this.deviceId, + }); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + final String deviceId; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson { + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson { + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson { + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson({ + required this.success, + required this.token, + }); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + final String token; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson { + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush { + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush({required this.version}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + Map json) => + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_UnifiedpushFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJsonString( + String data) => + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final int version; + + // coverage:ignore-start + Map toJson() => + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_UnifiedpushToJson(this); + // coverage:ignore-end + static String? toJsonString( + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson { + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson({required this.unifiedpush}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJson( + Map json) => + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush unifiedpush; + + // coverage:ignore-start + Map toJson() => + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderPushResponse201ApplicationJson { + NextcloudUnifiedPushProviderPushResponse201ApplicationJson({required this.success}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderPushResponse201ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJson(json.decode(data) as Map); + // coverage:ignore-end + + final bool success; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderPushResponse201ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderPushResponse201ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush { + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush({required this.gateway}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + Map json) => + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_UnifiedpushFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJsonString( + String data) => + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final String gateway; + + // coverage:ignore-start + Map toJson() => + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_UnifiedpushToJson(this); + // coverage:ignore-end + static String? toJsonString( + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson { + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson({required this.unifiedpush}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJson( + Map json) => + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush unifiedpush; + + // coverage:ignore-start + Map toJson() => + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + +@JsonSerializable() +class NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson { + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson({required this.rejected}); + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJson(Map json) => + _$NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJsonFromJson(json); + // coverage:ignore-end + + // coverage:ignore-start + factory NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJsonString(String data) => + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJson( + json.decode(data) as Map); + // coverage:ignore-end + + final List rejected; + + // coverage:ignore-start + Map toJson() => _$NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJsonToJson(this); + // coverage:ignore-end + static String? toJsonString(NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson? data) => + data == null ? null : json.encode(data.toJson()); +} + enum NextcloudUserStatusClearAt_Type { period('period'), @JsonValue('end-of') @@ -5690,6 +6257,88 @@ final _deserializers = { List: (final data) => (data as List) .map((final e) => NextcloudProvisioningApiUserDetails_BackendCapabilities.fromJson(e as Map)) .toList(), + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => NextcloudUnifiedPushProviderCheckResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson: (final data) => + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson.fromJson( + e as Map)) + .toList(), + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush: (final data) => + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + data as Map), + List: (final data) => (data + as List) + .map((final e) => NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + e as Map)) + .toList(), + NextcloudUnifiedPushProviderPushResponse201ApplicationJson: (final data) => + NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => NextcloudUnifiedPushProviderPushResponse201ApplicationJson.fromJson(e as Map)) + .toList(), + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJson( + data as Map), + List: (final data) => (data as List) + .map((final e) => NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson.fromJson( + e as Map)) + .toList(), + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush: (final data) => + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + data as Map), + List: (final data) => + (data as List) + .map((final e) => + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + e as Map)) + .toList(), + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson: (final data) => + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJson(data as Map), + List: (final data) => (data as List) + .map((final e) => + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson.fromJson(e as Map)) + .toList(), NextcloudUserStatusGetPublicStatuses: (final data) => NextcloudUserStatusGetPublicStatuses.fromJson(data as Map), List: (final data) => (data as List) @@ -5974,6 +6623,46 @@ final _serializers = { NextcloudProvisioningApiUserDetails_BackendCapabilities: (final data) => data.toJson(), List: (final data) => data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderPushResponse201ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush: (final data) => + data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson: (final data) => data.toJson(), + List: (final data) => + data.map((final e) => e.toJson()).toList(), NextcloudUserStatusGetPublicStatuses: (final data) => data.toJson(), List: (final data) => data.map((final e) => e.toJson()).toList(), NextcloudUserStatusGetPublicStatuses_Ocs: (final data) => data.toJson(), diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart index 24ecae1e..990a1cf9 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart @@ -1949,6 +1949,235 @@ Map _$NextcloudProvisioningApiUserToJson(NextcloudProvisioningA 'ocs': instance.ocs.toJson(), }; +NextcloudUnifiedPushProviderCheckResponse200ApplicationJson + _$NextcloudUnifiedPushProviderCheckResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderCheckResponse200ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderCheckResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderCheckResponse200ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson + _$NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderSetKeepaliveResponse200ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson + _$NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success', 'deviceId'], + ); + return NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson( + success: json['success'] as bool, + deviceId: json['deviceId'] as String, + ); +} + +Map _$NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderCreateDeviceResponse200ApplicationJson instance) => + { + 'success': instance.success, + 'deviceId': instance.deviceId, + }; + +NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson + _$NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJsonToJson( + NextcloudUnifiedPushProviderSyncDeviceResponse401ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson + _$NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderDeleteDeviceResponse200ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson + _$NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success', 'token'], + ); + return NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson( + success: json['success'] as bool, + token: json['token'] as String, + ); +} + +Map _$NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderCreateAppResponse200ApplicationJson instance) => + { + 'success': instance.success, + 'token': instance.token, + }; + +NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson + _$NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderDeleteAppResponse200ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_UnifiedpushFromJson( + Map json) { + $checkKeys( + json, + allowedKeys: const ['version'], + ); + return NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush( + version: json['version'] as int, + ); +} + +Map _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_UnifiedpushToJson( + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush instance) => + { + 'version': instance.version, + }; + +NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson + _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['unifiedpush'], + ); + return NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson( + unifiedpush: NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + json['unifiedpush'] as Map), + ); +} + +Map _$NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderUnifiedpushDiscoveryResponse200ApplicationJson instance) => + { + 'unifiedpush': instance.unifiedpush.toJson(), + }; + +NextcloudUnifiedPushProviderPushResponse201ApplicationJson + _$NextcloudUnifiedPushProviderPushResponse201ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['success'], + ); + return NextcloudUnifiedPushProviderPushResponse201ApplicationJson( + success: json['success'] as bool, + ); +} + +Map _$NextcloudUnifiedPushProviderPushResponse201ApplicationJsonToJson( + NextcloudUnifiedPushProviderPushResponse201ApplicationJson instance) => + { + 'success': instance.success, + }; + +NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_UnifiedpushFromJson( + Map json) { + $checkKeys( + json, + allowedKeys: const ['gateway'], + ); + return NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush( + gateway: json['gateway'] as String, + ); +} + +Map _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_UnifiedpushToJson( + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush instance) => + { + 'gateway': instance.gateway, + }; + +NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson + _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['unifiedpush'], + ); + return NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson( + unifiedpush: NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson_Unifiedpush.fromJson( + json['unifiedpush'] as Map), + ); +} + +Map _$NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderGatewayMatrixDiscoveryResponse200ApplicationJson instance) => + { + 'unifiedpush': instance.unifiedpush.toJson(), + }; + +NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson + _$NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJsonFromJson(Map json) { + $checkKeys( + json, + allowedKeys: const ['rejected'], + ); + return NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson( + rejected: (json['rejected'] as List).map((e) => e as String).toList(), + ); +} + +Map _$NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJsonToJson( + NextcloudUnifiedPushProviderGatewayMatrixResponse200ApplicationJson instance) => + { + 'rejected': instance.rejected, + }; + NextcloudUserStatusClearAt _$NextcloudUserStatusClearAtFromJson(Map json) { $checkKeys( json, diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.json b/packages/nextcloud/lib/src/nextcloud.openapi.json index 6f360fdc..aacd2154 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.json +++ b/packages/nextcloud/lib/src/nextcloud.openapi.json @@ -3419,6 +3419,422 @@ } } }, + "/index.php/apps/uppush": { + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Check if the UnifiedPush provider is present", + "operationId": "unified_push_provider-check", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/keepalive": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Set keepalive interval.", + "operationId": "unified_push_provider-set-keepalive", + "parameters": [ + { + "name": "keepalive", + "in": "query", + "description": "Keep alive value in seconds", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/device": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Request to create a new deviceId.", + "operationId": "unified_push_provider-create-device", + "parameters": [ + { + "name": "deviceName", + "in": "query", + "description": "Name of the device", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success", + "deviceId" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "deviceId": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/device/{deviceId}": { + "parameters": [ + { + "name": "deviceId", + "in": "path", + "description": "ID of the device", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Request to get push messages.", + "description": "This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app)", + "operationId": "unified_push_provider-sync-device", + "responses": { + "401": { + "description": "Missing permissions to sync device", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "delete": { + "tags": [ + "unified_push_provider" + ], + "summary": "Delete a device.", + "operationId": "unified_push_provider-delete-device", + "responses": { + "200": { + "description": "Device deleted successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/app": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Create an authorization token for a new 3rd party service.", + "operationId": "unified_push_provider-create-app", + "parameters": [ + { + "name": "deviceId", + "in": "query", + "description": "ID of the device", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "appName", + "in": "query", + "description": "Name of the app", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "App created successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success", + "token" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "token": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/app/{token}": { + "parameters": [ + { + "name": "token", + "in": "path", + "description": "Token of the app", + "required": true, + "schema": { + "type": "string" + } + } + ], + "delete": { + "tags": [ + "unified_push_provider" + ], + "summary": "Delete an authorization token.", + "operationId": "unified_push_provider-delete-app", + "responses": { + "200": { + "description": "App deleted successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/push/{token}": { + "parameters": [ + { + "name": "token", + "in": "path", + "description": "Token of the app to push to", + "required": true, + "schema": { + "type": "string" + } + } + ], + "post": { + "tags": [ + "unified_push_provider" + ], + "summary": "Receive notifications from 3rd parties.", + "operationId": "unified_push_provider-push", + "responses": { + "201": { + "description": "Notification pushed successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Unifiedpush discovery Following specifications", + "operationId": "unified_push_provider-unifiedpush-discovery", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "unifiedpush" + ], + "type": "object", + "properties": { + "unifiedpush": { + "required": [ + "version" + ], + "type": "object", + "properties": { + "version": { + "type": "integer" + } + } + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/gateway/matrix": { + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Matrix Gateway discovery", + "operationId": "unified_push_provider-gateway-matrix-discovery", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "unifiedpush" + ], + "type": "object", + "properties": { + "unifiedpush": { + "required": [ + "gateway" + ], + "type": "object", + "properties": { + "gateway": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "post": { + "tags": [ + "unified_push_provider" + ], + "summary": "Matrix Gateway", + "operationId": "unified_push_provider-gateway-matrix", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "rejected" + ], + "type": "object", + "properties": { + "rejected": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, "/ocs/v2.php/apps/user_status/api/v1/statuses": { "get": { "operationId": "get-public-statuses", diff --git a/packages/nextcloud/test/uppush.dart b/packages/nextcloud/test/uppush.dart new file mode 100644 index 00000000..b00c444e --- /dev/null +++ b/packages/nextcloud/test/uppush.dart @@ -0,0 +1,66 @@ +import 'package:test/test.dart'; + +import 'helper.dart'; + +Future main() async { + await run(await getDockerImage()); +} + +Future run(final DockerImage image) async { + group('uppush', () { + late DockerContainer container; + late TestNextcloudClient client; + setUp(() async { + container = await getDockerContainer(image); + client = await getTestClient( + container, + username: 'admin', + password: 'admin', + ); + }); + tearDown(() => container.destroy()); + + test('Is installed', () async { + final response = await client.unifiedPushProvider.check(); + expect(response.success, isTrue); + }); + + test('Set keepalive', () async { + final response = await client.unifiedPushProvider.setKeepalive(keepalive: '10'); + expect(response.success, isTrue); + }); + + test('Create device', () async { + final response = await client.unifiedPushProvider.createDevice(deviceName: 'Test'); + expect(response.success, isTrue); + expect(response.deviceId, isNotEmpty); + }); + + test('Delete device', () async { + final deviceId = (await client.unifiedPushProvider.createDevice(deviceName: 'Test')).deviceId; + + final response = await client.unifiedPushProvider.deleteDevice(deviceId: deviceId); + expect(response.success, isTrue); + }); + + test('Create app', () async { + final deviceId = (await client.unifiedPushProvider.createDevice(deviceName: 'Test')).deviceId; + + final response = await client.unifiedPushProvider.createApp(deviceId: deviceId, appName: 'Test'); + expect(response.success, isTrue); + expect(response.token, isNotEmpty); + }); + + test('UnifiedPush discovery', () async { + final response = await client.unifiedPushProvider.unifiedpushDiscovery(token: 'example'); + expect(response.unifiedpush.version, 1); + }); + + test('Matrix gateway discovery', () async { + final response = await client.unifiedPushProvider.gatewayMatrixDiscovery(); + expect(response.unifiedpush.gateway, 'matrix'); + }); + + // Deleting an app, sending a notification (also via matrix gateway) or listening for notifications is not possible because redis is not set up + }); +} diff --git a/specs/uppush.json b/specs/uppush.json new file mode 100644 index 00000000..8712eacd --- /dev/null +++ b/specs/uppush.json @@ -0,0 +1,444 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "UnifiedPush Provider", + "description": "Use Nextcloud as a push provider for mobile phones' notifications", + "license": { + "name": "agpl" + }, + "version": "1.2.0" + }, + "paths": { + "/index.php/apps/uppush": { + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Check if the UnifiedPush provider is present", + "operationId": "unified_push_provider-check", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/keepalive": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Set keepalive interval.", + "operationId": "unified_push_provider-set-keepalive", + "parameters": [ + { + "name": "keepalive", + "in": "query", + "description": "Keep alive value in seconds", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/device": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Request to create a new deviceId.", + "operationId": "unified_push_provider-create-device", + "parameters": [ + { + "name": "deviceName", + "in": "query", + "description": "Name of the device", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "success", + "deviceId" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "deviceId": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/device/{deviceId}": { + "parameters": [ + { + "name": "deviceId", + "in": "path", + "description": "ID of the device", + "required": true, + "schema": { + "type": "string" + } + } + ], + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Request to get push messages.", + "description": "This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app)", + "operationId": "unified_push_provider-sync-device", + "responses": { + "401": { + "description": "Missing permissions to sync device", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "delete": { + "tags": [ + "unified_push_provider" + ], + "summary": "Delete a device.", + "operationId": "unified_push_provider-delete-device", + "responses": { + "200": { + "description": "Device deleted successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/app": { + "put": { + "tags": [ + "unified_push_provider" + ], + "summary": "Create an authorization token for a new 3rd party service.", + "operationId": "unified_push_provider-create-app", + "parameters": [ + { + "name": "deviceId", + "in": "query", + "description": "ID of the device", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "appName", + "in": "query", + "description": "Name of the app", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "App created successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success", + "token" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "token": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/app/{token}": { + "parameters": [ + { + "name": "token", + "in": "path", + "description": "Token of the app", + "required": true, + "schema": { + "type": "string" + } + } + ], + "delete": { + "tags": [ + "unified_push_provider" + ], + "summary": "Delete an authorization token.", + "operationId": "unified_push_provider-delete-app", + "responses": { + "200": { + "description": "App deleted successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/push/{token}": { + "parameters": [ + { + "name": "token", + "in": "path", + "description": "Token of the app to push to", + "required": true, + "schema": { + "type": "string" + } + } + ], + "post": { + "tags": [ + "unified_push_provider" + ], + "summary": "Receive notifications from 3rd parties.", + "operationId": "unified_push_provider-push", + "responses": { + "201": { + "description": "Notification pushed successfully", + "content": { + "application/json": { + "schema": { + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Unifiedpush discovery Following specifications", + "operationId": "unified_push_provider-unifiedpush-discovery", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "unifiedpush" + ], + "type": "object", + "properties": { + "unifiedpush": { + "required": [ + "version" + ], + "type": "object", + "properties": { + "version": { + "type": "integer" + } + } + } + } + } + } + } + } + } + } + }, + "/index.php/apps/uppush/gateway/matrix": { + "get": { + "tags": [ + "unified_push_provider" + ], + "summary": "Matrix Gateway discovery", + "operationId": "unified_push_provider-gateway-matrix-discovery", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "unifiedpush" + ], + "type": "object", + "properties": { + "unifiedpush": { + "required": [ + "gateway" + ], + "type": "object", + "properties": { + "gateway": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "post": { + "tags": [ + "unified_push_provider" + ], + "summary": "Matrix Gateway", + "operationId": "unified_push_provider-gateway-matrix", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "required": [ + "rejected" + ], + "type": "object", + "properties": { + "rejected": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": {}, + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + } + } + }, + "security": [ + { + "basic_auth": [] + } + ], + "tags": [] +} \ No newline at end of file diff --git a/tool/Dockerfile.dev b/tool/Dockerfile.dev index cbbf9faa..3c2cc700 100644 --- a/tool/Dockerfile.dev +++ b/tool/Dockerfile.dev @@ -13,6 +13,7 @@ RUN OC_PASS="user2" ./occ user:add --password-from-env --display-name "User Two" RUN ./occ app:install news # 21.0.0 RUN ./occ app:install notes # 4.6.0 +RUN ./occ app:install uppush # 1.2.0 RUN ./occ app:enable password_policy # TODO: This stopped working randomly with apache not being able to bind to the port during build. Must be some docker changes? diff --git a/tool/generate-nextcloud.sh b/tool/generate-nextcloud.sh index 71bec3f6..5611b526 100755 --- a/tool/generate-nextcloud.sh +++ b/tool/generate-nextcloud.sh @@ -5,8 +5,8 @@ cd "$(dirname "$0")/.." rm -rf /tmp/nextcloud-neon mkdir -p /tmp/nextcloud-neon -codenames=(core news notes notifications provisioning_api user_status) -prefixes=(Core News Notes Notifications ProvisioningApi UserStatus) +codenames=(core news notes notifications provisioning_api uppush user_status) +prefixes=(Core News Notes Notifications ProvisioningApi UnifiedPushProvider UserStatus) base_spec=/tmp/nextcloud-neon/base.json merged_spec=/tmp/nextcloud-neon/merged.json