From f99238fe12d9641fc3efdafe6c3f1e2174869e85 Mon Sep 17 00:00:00 2001 From: Lukas Nagel Date: Mon, 10 Jul 2023 07:25:04 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=A7=20Made=20object=20prop=20final?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Models/CoreTypes/object.dart | 6 +++++- lib/Models/ObjectTypes/document.dart | 5 +++-- lib/Models/post.dart | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Models/CoreTypes/object.dart b/lib/Models/CoreTypes/object.dart index 3d3db3a..ed4a390 100644 --- a/lib/Models/CoreTypes/object.dart +++ b/lib/Models/CoreTypes/object.dart @@ -1,3 +1,7 @@ class ActivityPubObject { - List? attachments; + final List? attachments; + + ActivityPubObject( + this.attachments, + ); } diff --git a/lib/Models/ObjectTypes/document.dart b/lib/Models/ObjectTypes/document.dart index 1ea2cdb..fb16697 100644 --- a/lib/Models/ObjectTypes/document.dart +++ b/lib/Models/ObjectTypes/document.dart @@ -13,12 +13,13 @@ class Document extends ActivityPubObject { this.mediaType, this.context, this.url, - ); + ) : super(null); Document.fromJson(Map json) : type = json["type"], mediaType = json["mediaType"], url = Uri.tryParse(json["url"]), name = json["name"], - context = json["@context"]; + context = json["@context"], + super(null); } diff --git a/lib/Models/post.dart b/lib/Models/post.dart index 80c533d..2612992 100644 --- a/lib/Models/post.dart +++ b/lib/Models/post.dart @@ -30,7 +30,7 @@ class Post extends ActivityPubObject { this.attributedTo, this.replies, this.attachment, - ); + ) : super(attachment); Post.fromJson(Map json) : to = convertToStringList(json["to"]), @@ -46,7 +46,8 @@ class Post extends ActivityPubObject { attachment = toListOfDocuments(json["attachment"]), replies = json["replies"] == null ? null - : Collection.fromJson(json["replies"]); + : Collection.fromJson(json["replies"]), + super(json["attachment"]); static List convertToStringList(json) { List jsonList = []; From 69c06f8a741b8d9bbecbfccc2efe2923a8142b44 Mon Sep 17 00:00:00 2001 From: Lukas Nagel Date: Tue, 11 Jul 2023 06:46:58 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Added=20props=20to=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Models/CoreTypes/object.dart | 8 ++++++-- lib/Models/ObjectTypes/document.dart | 12 ++++++++++-- lib/Models/post.dart | 24 +++++++++++++----------- pubspec.yaml | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/lib/Models/CoreTypes/object.dart b/lib/Models/CoreTypes/object.dart index ed4a390..0766033 100644 --- a/lib/Models/CoreTypes/object.dart +++ b/lib/Models/CoreTypes/object.dart @@ -1,7 +1,11 @@ class ActivityPubObject { - final List? attachments; + final List? attachment; + final String? content; + final String? attributedTo; ActivityPubObject( - this.attachments, + this.attachment, + this.content, + this.attributedTo, ); } diff --git a/lib/Models/ObjectTypes/document.dart b/lib/Models/ObjectTypes/document.dart index fb16697..599502e 100644 --- a/lib/Models/ObjectTypes/document.dart +++ b/lib/Models/ObjectTypes/document.dart @@ -13,7 +13,11 @@ class Document extends ActivityPubObject { this.mediaType, this.context, this.url, - ) : super(null); + ) : super( + null, + null, + null, + ); Document.fromJson(Map json) : type = json["type"], @@ -21,5 +25,9 @@ class Document extends ActivityPubObject { url = Uri.tryParse(json["url"]), name = json["name"], context = json["@context"], - super(null); + super( + null, + null, + null, + ); } diff --git a/lib/Models/post.dart b/lib/Models/post.dart index 2612992..8d24ae8 100644 --- a/lib/Models/post.dart +++ b/lib/Models/post.dart @@ -9,13 +9,10 @@ class Post extends ActivityPubObject { final String? summary; final bool? sensitive; final String? inReplyTo; - final String content; final String id; final String type; final DateTime published; - final String attributedTo; final Collection? replies; - final List? attachment; Post( this.to, @@ -23,14 +20,18 @@ class Post extends ActivityPubObject { this.summary, this.sensitive, this.inReplyTo, - this.content, + content, this.id, this.type, this.published, - this.attributedTo, + attributedTo, this.replies, - this.attachment, - ) : super(attachment); + attachment, + ) : super( + attachment, + content, + attributedTo, + ); Post.fromJson(Map json) : to = convertToStringList(json["to"]), @@ -38,16 +39,17 @@ class Post extends ActivityPubObject { summary = json["summary"], sensitive = json["sensitive"], inReplyTo = json["inReplyTo"], - content = json["content"], id = json["id"], type = json["type"], published = DateTime.parse(json["published"]), - attributedTo = json["attributedTo"], - attachment = toListOfDocuments(json["attachment"]), replies = json["replies"] == null ? null : Collection.fromJson(json["replies"]), - super(json["attachment"]); + super( + json["attachment"], + json["content"], + json["attributedTo"], + ); static List convertToStringList(json) { List jsonList = []; diff --git a/pubspec.yaml b/pubspec.yaml index 737fa57..4276907 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: activitypub description: A library for the ActivityPub standard. Created an also used by Fedodo. -version: 1.2.4 +version: 1.2.5 repository: https://github.com/Fedodo/Fedodo.Pub.ActivityPub environment: