Solian/lib/models/post.dart

101 lines
2.2 KiB
Dart
Raw Normal View History

2024-09-16 18:14:23 +00:00
import 'package:json_annotation/json_annotation.dart';
2024-05-18 10:17:16 +00:00
import 'package:solian/models/account.dart';
2024-10-10 14:52:05 +00:00
import 'package:solian/models/attachment.dart';
import 'package:solian/models/post_categories.dart';
2024-05-18 10:17:16 +00:00
import 'package:solian/models/realm.dart';
part 'post.g.dart';
2024-10-10 14:52:05 +00:00
class PostPreload {
List<Attachment> attachments;
PostPreload({
required this.attachments,
});
}
@JsonSerializable()
2024-05-18 10:17:16 +00:00
class Post {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? editedAt;
2024-05-18 10:17:16 +00:00
DateTime? deletedAt;
2024-08-17 10:44:20 +00:00
String? alias;
String? areaAlias;
dynamic body;
2024-10-13 12:45:00 +00:00
int visibility;
2024-07-07 04:33:54 +00:00
List<Tag>? tags;
List<Category>? categories;
2024-05-18 10:17:16 +00:00
List<Post>? replies;
String type;
2024-05-18 10:17:16 +00:00
int? replyId;
int? repostId;
int? realmId;
Post? replyTo;
Post? repostTo;
Realm? realm;
DateTime? publishedAt;
DateTime? publishedUntil;
DateTime? pinnedAt;
2024-07-09 13:23:38 +00:00
bool? isDraft;
2024-05-18 10:17:16 +00:00
int authorId;
Account author;
PostMetric? metric;
2024-05-18 10:17:16 +00:00
2024-10-10 14:52:05 +00:00
@JsonKey(includeFromJson: false, includeToJson: false)
PostPreload? preload;
2024-05-18 10:17:16 +00:00
Post({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.editedAt,
2024-05-18 10:17:16 +00:00
required this.deletedAt,
2024-08-17 10:44:20 +00:00
required this.alias,
required this.areaAlias,
required this.type,
required this.body,
2024-10-13 12:45:00 +00:00
required this.visibility,
2024-05-18 10:17:16 +00:00
required this.tags,
required this.categories,
required this.replies,
required this.replyId,
required this.repostId,
required this.realmId,
required this.replyTo,
required this.repostTo,
required this.realm,
required this.publishedAt,
required this.publishedUntil,
required this.pinnedAt,
2024-07-09 13:23:38 +00:00
required this.isDraft,
2024-05-18 10:17:16 +00:00
required this.authorId,
required this.author,
required this.metric,
2024-05-18 10:17:16 +00:00
});
factory Post.fromJson(Map<String, dynamic> json) => _$PostFromJson(json);
2024-05-18 10:17:16 +00:00
Map<String, dynamic> toJson() => _$PostToJson(this);
}
@JsonSerializable()
class PostMetric {
int reactionCount;
@JsonKey(defaultValue: {})
Map<String, int> reactionList;
int replyCount;
PostMetric({
required this.reactionCount,
required this.reactionList,
required this.replyCount,
});
factory PostMetric.fromJson(Map<String, dynamic> json) =>
_$PostMetricFromJson(json);
Map<String, dynamic> toJson() => _$PostMetricToJson(this);
2024-05-19 12:30:50 +00:00
}