Skip to content

Commit 4edb375

Browse files
committed
refactor(nextcloud)!: Remove AppType and simplify user-agent configuration
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent d2a73b4 commit 4edb375

File tree

5 files changed

+6
-27
lines changed

5 files changed

+6
-27
lines changed

packages/neon_framework/lib/src/blocs/#_check_account.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class _LoginCheckAccountBloc extends InteractiveBloc implements LoginCheckAccoun
5959
serverURL,
6060
loginName: loginName,
6161
password: password,
62-
userAgentOverride: neonUserAgent,
62+
userAgent: neonUserAgent,
6363
);
6464

6565
final response = await client.provisioningApi.users.getCurrentUser();

packages/neon_framework/lib/src/blocs/#_check_server_status.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class _LoginCheckServerStatusBloc extends InteractiveBloc implements LoginCheckS
5050
try {
5151
final client = NextcloudClient(
5252
serverURL,
53-
userAgentOverride: neonUserAgent,
53+
userAgent: neonUserAgent,
5454
);
5555

5656
final status = await client.core.getStatus();

packages/neon_framework/lib/src/blocs/#_flow.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class _LoginFlowBloc extends InteractiveBloc implements LoginFlowBloc {
3939
final Uri serverURL;
4040
late final client = NextcloudClient(
4141
serverURL,
42-
userAgentOverride: neonUserAgent,
42+
userAgent: neonUserAgent,
4343
);
4444
final resultController = StreamController<core.LoginFlowV2Credentials>();
4545

packages/neon_framework/lib/src/models/account.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Account implements Credentials, Findable {
4040
loginName: username,
4141
password: password,
4242
appPassword: password,
43-
userAgentOverride: userAgent,
43+
userAgent: userAgent,
4444
cookieJar: CookieJar(),
4545
httpClient: httpClient,
4646
);

packages/nextcloud/lib/src/client.dart

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
import 'package:dynamite_runtime/http_client.dart';
22
import 'package:universal_io/io.dart';
33

4-
/// Different app types to register for
5-
enum AppType {
6-
/// Will only receive Talk notifications
7-
talk('Mozilla/5.0 (Android) Nextcloud-Talk'),
8-
9-
/// Will receive all notifications except Talk notifications if another Talk
10-
/// app is already registered for the user
11-
nextcloud('Mozilla/5.0 (Android) Nextcloud-android'),
12-
13-
/// Default. Same problem with notifications as the [nextcloud] type
14-
unknown(null);
15-
16-
// ignore: public_member_api_docs
17-
const AppType(this.userAgent);
18-
19-
// ignore: public_member_api_docs
20-
final String? userAgent;
21-
}
22-
234
// ignore: public_member_api_docs
245
class NextcloudClient extends DynamiteClient {
256
// ignore: public_member_api_docs
@@ -29,15 +10,13 @@ class NextcloudClient extends DynamiteClient {
2910
String? password,
3011
String? appPassword,
3112
String? language,
32-
AppType appType = AppType.unknown,
33-
String? userAgentOverride,
13+
String? userAgent,
3414
super.httpClient,
3515
super.cookieJar,
3616
}) : super(
3717
baseHeaders: {
3818
if (language != null) HttpHeaders.acceptLanguageHeader: language,
39-
if ((userAgentOverride ?? appType.userAgent) != null)
40-
HttpHeaders.userAgentHeader: userAgentOverride ?? appType.userAgent!,
19+
if (userAgent != null) HttpHeaders.userAgentHeader: userAgent,
4120
},
4221
authentications: [
4322
if (appPassword != null)

0 commit comments

Comments
 (0)