Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish Sprint 26 Merge #93

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ env:
FLUTTER_VERSION: 3.22.2

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
on: [push, pull_request, workflow_dispatch]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:jmap_dart_client/http/converter/identities/identity_id_converter.dart';
import 'package:jmap_dart_client/jmap/identities/identity.dart';
import 'package:json_annotation/json_annotation.dart';

class PublicAssetIdentitiesConverter extends JsonConverter<Map<IdentityId, bool>, Map<String, dynamic>> {
const PublicAssetIdentitiesConverter();

@override
Map<IdentityId, bool> fromJson(Map<String, dynamic> json) {
return Map.fromEntries(
json.entries.map(
(entry) => MapEntry(
const IdentityIdConverter().fromJson(entry.key),
entry.value)));
}

@override
Map<String, bool> toJson(Map<IdentityId, bool> object) {
return Map.fromEntries(
object.entries.map(
(entry) => MapEntry(
const IdentityIdConverter().toJson(entry.key),
entry.value)));
}
}
1 change: 1 addition & 0 deletions lib/jmap/core/capability/capability_identifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class CapabilityIdentifier with EquatableMixin {
static final jmapTeamMailboxes = CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares'));
static final jamesSortOrder = CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:identity:sortorder'));
static final jamesCalendarEvent = CapabilityIdentifier(Uri.parse('com:linagora:params:calendar:event'));
static final jmapPublicAsset = CapabilityIdentifier(Uri.parse('com:linagora:params:jmap:public:assets'));

final Uri value;

Expand Down
1 change: 1 addition & 0 deletions lib/jmap/core/error/method/error_method_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class ErrorMethodResponse extends MethodResponse {
static final accountNotSupportedByMethod = ErrorType("accountNotSupportedByMethod");
static final accountReadOnly = ErrorType("accountReadOnly");
static final cannotCalculateChanges = ErrorType("cannotCalculateChanges");
static final overQuota = ErrorType("overQuota");

final ErrorType type;
final String? description;
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/core/error/set_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SetError with EquatableMixin {
static final invalidPatch = ErrorType("invalidPatch");
static final willDestroy = ErrorType("willDestroy");
static final invalidProperties = ErrorType("invalidProperties");
static final invalidArguments = ErrorType("invalidArguments");
static final singleton = ErrorType("singleton");

final ErrorType type;
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/core/patch_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class PatchObject with EquatableMixin {

static final mailboxIdsProperty = 'mailboxIds';
static final keywordsProperty = 'keywords';
static const identityIdsProperty = 'identityIds';

PatchObject(this.patches);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:jmap_dart_client/jmap/core/method/method.dart';
import 'package:jmap_dart_client/jmap/core/method/request/get_method.dart';
import 'package:jmap_dart_client/jmap/core/request/request_invocation.dart';
import 'package:json_annotation/json_annotation.dart';

part 'get_public_asset_method.g.dart';

@JsonSerializable(converters: [AccountIdConverter(), IdConverter()])
class GetPublicAssetMethod extends MethodRequiringAccountId with OptionalIds {
GetPublicAssetMethod(super.accountId);

@override
MethodName get methodName => MethodName('PublicAsset/get');

@override
List<Object?> get props => [accountId, ids];

@override
Set<CapabilityIdentifier> get requiredCapabilities => {
CapabilityIdentifier.jmapCore,
CapabilityIdentifier.jmapPublicAsset
};

@override
Map<String, dynamic> toJson() => _$GetPublicAssetMethodToJson(this);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/http/converter/state_converter.dart';
import 'package:jmap_dart_client/jmap/core/method/response/get_response.dart';
import 'package:jmap_dart_client/jmap/mail/extensions/public_asset/public_asset.dart';
import 'package:json_annotation/json_annotation.dart';

part 'get_public_asset_response.g.dart';

@StateConverter()
@AccountIdConverter()
@IdConverter()
@JsonSerializable()
class GetPublicAssetResponse extends GetResponse<PublicAsset> {
GetPublicAssetResponse(super.accountId, super.state, super.list, super.notFound);

@override
List<Object?> get props => [accountId, state, list, notFound];

static GetPublicAssetResponse deserialize(Map<String, dynamic> json)
=> _$GetPublicAssetResponseFromJson(json);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions lib/jmap/mail/extensions/public_asset/public_asset.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/http/converter/id_nullable_converter.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/identities/identity.dart';
import 'package:jmap_dart_client/http/converter/identities/public_asset_identities_converter.dart';
import 'package:json_annotation/json_annotation.dart';

part 'public_asset.g.dart';

typedef PublicAssetIdentities = Map<IdentityId, bool>;

@JsonSerializable(
converters: [
IdNullableConverter(),
PublicAssetIdentitiesConverter(),
],
includeIfNull: false,
)
class PublicAsset with EquatableMixin {
final Id? id;
final String? publicURI;
final int? size;
final String? contentType;
final Id? blobId;
final PublicAssetIdentities? identityIds;

PublicAsset({
this.id,
this.publicURI,
this.size,
this.contentType,
this.blobId,
this.identityIds,
});

@override
List<Object?> get props => [
id,
publicURI,
size,
contentType,
blobId,
identityIds,
];

factory PublicAsset.fromJson(Map<String, dynamic> json) => _$PublicAssetFromJson(json);
Map<String, dynamic> toJson() => _$PublicAssetToJson(this);
}
52 changes: 52 additions & 0 deletions lib/jmap/mail/extensions/public_asset/public_asset.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/http/converter/set/set_method_properties_converter.dart';
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:jmap_dart_client/jmap/core/method/request/set_method.dart';
import 'package:jmap_dart_client/jmap/core/request/request_invocation.dart';
import 'package:jmap_dart_client/jmap/mail/extensions/public_asset/public_asset.dart';

class SetPublicAssetMethod extends SetMethod<PublicAsset> {

SetPublicAssetMethod(super.accountId);

@override
MethodName get methodName => MethodName('PublicAsset/set');

@override
List<Object?> get props => [accountId, ifInState, create, update, destroy];

@override
Set<CapabilityIdentifier> get requiredCapabilities => {
CapabilityIdentifier.jmapCore,
CapabilityIdentifier.jmapPublicAsset
};

@override
Map<String, dynamic> toJson() {
final val = <String, dynamic>{
'accountId': const AccountIdConverter().toJson(accountId),
};

void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}

writeNotNull('create', create
?.map((id, create) => SetMethodPropertiesConverter().fromMapIdToJson(id, create.toJson())));
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());

return val;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/http/converter/state_nullable_converter.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/method/response/set_response.dart';
import 'package:jmap_dart_client/jmap/mail/extensions/public_asset/public_asset.dart';

class SetPublicAssetResponse extends SetResponse<PublicAsset> {
SetPublicAssetResponse(
super.accountId, {
super.newState,
super.created,
super.updated,
super.destroyed,
super.notCreated,
super.notUpdated,
super.notDestroyed,
});

@override
List<Object?> get props => [accountId, newState, created, updated, destroyed];

static SetPublicAssetResponse deserialize(Map<String, dynamic> json) {
return SetPublicAssetResponse(
const AccountIdConverter().fromJson(json['accountId'] as String),
newState: const StateNullableConverter().fromJson(json['newState'] as String?),
created: (json['created'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
const IdConverter().fromJson(key),
PublicAsset.fromJson(value as Map<String, dynamic>))),
updated: (json['updated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
const IdConverter().fromJson(key),
value != null ? PublicAsset.fromJson(value as Map<String, dynamic>) : null)),
destroyed: (json['destroyed'] as List<dynamic>?)
?.map((id) => const IdConverter().fromJson(id)).toSet(),
notCreated: (json['notCreated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
const IdConverter().fromJson(key),
SetError.fromJson(value))),
notUpdated: (json['notUpdated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
const IdConverter().fromJson(key),
SetError.fromJson(value))),
notDestroyed: (json['notDestroyed'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
const IdConverter().fromJson(key),
SetError.fromJson(value))),
);
}
}
Loading
Loading