2024-11-08 16:09:46 +00:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-11-09 04:04:03 +00:00
|
|
|
import 'package:surface/types/attachment.dart';
|
2024-11-08 16:09:46 +00:00
|
|
|
|
|
|
|
part 'post.freezed.dart';
|
|
|
|
part 'post.g.dart';
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnPost with _$SnPost {
|
2024-11-10 10:37:34 +00:00
|
|
|
const SnPost._();
|
|
|
|
|
2024-11-08 16:09:46 +00:00
|
|
|
const factory SnPost({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required String type,
|
2024-11-09 04:04:03 +00:00
|
|
|
required Map<String, dynamic> body,
|
2024-11-08 16:09:46 +00:00
|
|
|
required String language,
|
|
|
|
required String? alias,
|
2024-11-08 16:46:32 +00:00
|
|
|
required String? aliasPrefix,
|
2024-11-08 16:09:46 +00:00
|
|
|
required List<dynamic> tags,
|
|
|
|
required List<dynamic> categories,
|
2024-11-13 14:05:40 +00:00
|
|
|
required List<SnPost>? replies,
|
|
|
|
required int? replyId,
|
|
|
|
required int? repostId,
|
|
|
|
required SnPost? replyTo,
|
|
|
|
required SnPost? repostTo,
|
|
|
|
required List<int>? visibleUsersList,
|
|
|
|
required List<int>? invisibleUsersList,
|
2024-11-08 16:09:46 +00:00
|
|
|
required int visibility,
|
|
|
|
required DateTime? editedAt,
|
|
|
|
required DateTime? pinnedAt,
|
|
|
|
required DateTime? lockedAt,
|
|
|
|
required bool isDraft,
|
2024-11-10 12:07:26 +00:00
|
|
|
required DateTime? publishedAt,
|
2024-11-11 13:30:05 +00:00
|
|
|
required DateTime? publishedUntil,
|
2024-11-08 16:09:46 +00:00
|
|
|
required int totalUpvote,
|
|
|
|
required int totalDownvote,
|
|
|
|
required int publisherId,
|
|
|
|
required SnPublisher publisher,
|
|
|
|
required SnMetric metric,
|
2024-11-09 04:04:03 +00:00
|
|
|
SnPostPreload? preload,
|
2024-11-08 16:09:46 +00:00
|
|
|
}) = _SnPost;
|
|
|
|
|
|
|
|
factory SnPost.fromJson(Map<String, Object?> json) => _$SnPostFromJson(json);
|
2024-11-10 10:37:34 +00:00
|
|
|
|
|
|
|
String get typePlural => switch (type) {
|
|
|
|
'story' => 'stories',
|
|
|
|
_ => '${type}s',
|
|
|
|
};
|
2024-11-08 16:09:46 +00:00
|
|
|
}
|
|
|
|
|
2024-11-09 04:04:03 +00:00
|
|
|
@freezed
|
|
|
|
class SnPostPreload with _$SnPostPreload {
|
|
|
|
const factory SnPostPreload({
|
|
|
|
required List<SnAttachment>? attachments,
|
|
|
|
}) = _SnPostPreload;
|
|
|
|
|
|
|
|
factory SnPostPreload.fromJson(Map<String, Object?> json) =>
|
|
|
|
_$SnPostPreloadFromJson(json);
|
|
|
|
}
|
|
|
|
|
2024-11-08 16:09:46 +00:00
|
|
|
@freezed
|
|
|
|
class SnBody with _$SnBody {
|
|
|
|
const factory SnBody({
|
|
|
|
required List<String> attachments,
|
|
|
|
required String content,
|
|
|
|
required dynamic location,
|
|
|
|
required dynamic thumbnail,
|
|
|
|
required dynamic title,
|
|
|
|
}) = _SnBody;
|
|
|
|
|
|
|
|
factory SnBody.fromJson(Map<String, Object?> json) => _$SnBodyFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnMetric with _$SnMetric {
|
|
|
|
const factory SnMetric({
|
|
|
|
required int replyCount,
|
|
|
|
required int reactionCount,
|
2024-11-12 12:47:40 +00:00
|
|
|
@Default({}) Map<String, int> reactionList,
|
2024-11-08 16:09:46 +00:00
|
|
|
}) = _SnMetric;
|
|
|
|
|
|
|
|
factory SnMetric.fromJson(Map<String, Object?> json) =>
|
|
|
|
_$SnMetricFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnPublisher with _$SnPublisher {
|
|
|
|
const factory SnPublisher({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required int type,
|
|
|
|
required String name,
|
|
|
|
required String nick,
|
|
|
|
required String description,
|
|
|
|
required String avatar,
|
|
|
|
required String banner,
|
|
|
|
required int totalUpvote,
|
|
|
|
required int totalDownvote,
|
|
|
|
required int? realmId,
|
|
|
|
required int accountId,
|
|
|
|
}) = _SnPublisher;
|
|
|
|
|
|
|
|
factory SnPublisher.fromJson(Map<String, Object?> json) =>
|
|
|
|
_$SnPublisherFromJson(json);
|
|
|
|
}
|