2024-11-09 04:04:03 +00:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
|
|
|
|
part 'attachment.freezed.dart';
|
2024-12-26 14:19:01 +00:00
|
|
|
|
2024-11-09 04:04:03 +00:00
|
|
|
part 'attachment.g.dart';
|
|
|
|
|
2024-12-26 14:19:01 +00:00
|
|
|
enum SnMediaType {
|
|
|
|
image,
|
|
|
|
video,
|
|
|
|
audio,
|
|
|
|
file,
|
|
|
|
}
|
|
|
|
|
2024-11-09 04:04:03 +00:00
|
|
|
@freezed
|
|
|
|
class SnAttachment with _$SnAttachment {
|
2024-12-26 14:19:01 +00:00
|
|
|
const SnAttachment._();
|
|
|
|
|
2024-11-09 04:04:03 +00:00
|
|
|
const factory SnAttachment({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
2024-12-28 09:19:20 +00:00
|
|
|
required DateTime? deletedAt,
|
2024-11-09 04:04:03 +00:00
|
|
|
required String rid,
|
|
|
|
required String uuid,
|
|
|
|
required int size,
|
|
|
|
required String name,
|
|
|
|
required String alt,
|
|
|
|
required String mimetype,
|
|
|
|
required String hash,
|
|
|
|
required int destination,
|
|
|
|
required int refCount,
|
2024-12-26 14:19:01 +00:00
|
|
|
@Default(0) int contentRating,
|
|
|
|
@Default(0) int qualityRating,
|
2024-12-28 09:19:20 +00:00
|
|
|
required DateTime? cleanedAt,
|
2024-11-09 04:04:03 +00:00
|
|
|
required bool isAnalyzed,
|
|
|
|
required bool isSelfRef,
|
2024-12-28 10:16:59 +00:00
|
|
|
required bool isIndexable,
|
2024-12-28 09:19:20 +00:00
|
|
|
required SnAttachment? ref,
|
|
|
|
required int? refId,
|
2024-11-09 04:04:03 +00:00
|
|
|
required SnAttachmentPool? pool,
|
2024-12-28 18:13:31 +00:00
|
|
|
required int? poolId,
|
2024-11-09 04:04:03 +00:00
|
|
|
required int accountId,
|
2024-12-28 09:19:20 +00:00
|
|
|
int? thumbnailId,
|
|
|
|
SnAttachment? thumbnail,
|
|
|
|
int? compressedId,
|
|
|
|
SnAttachment? compressed,
|
2024-12-28 18:13:31 +00:00
|
|
|
@Default([]) List<SnAttachmentBoost> boosts,
|
2024-12-26 14:19:01 +00:00
|
|
|
@Default({}) Map<String, dynamic> usermeta,
|
2024-11-10 08:41:11 +00:00
|
|
|
@Default({}) Map<String, dynamic> metadata,
|
2024-11-09 04:04:03 +00:00
|
|
|
}) = _SnAttachment;
|
|
|
|
|
2024-12-26 14:19:01 +00:00
|
|
|
factory SnAttachment.fromJson(Map<String, Object?> json) => _$SnAttachmentFromJson(json);
|
|
|
|
|
|
|
|
Map<String, dynamic> get data => {
|
|
|
|
...metadata,
|
|
|
|
...usermeta,
|
|
|
|
};
|
|
|
|
|
|
|
|
SnMediaType get mediaType => switch (mimetype.split('/').firstOrNull) {
|
|
|
|
'image' => SnMediaType.image,
|
|
|
|
'video' => SnMediaType.video,
|
|
|
|
'audio' => SnMediaType.audio,
|
|
|
|
_ => SnMediaType.file,
|
|
|
|
};
|
2024-11-09 04:04:03 +00:00
|
|
|
}
|
|
|
|
|
2024-12-28 09:19:20 +00:00
|
|
|
@freezed
|
|
|
|
class SnAttachmentFragment with _$SnAttachmentFragment {
|
|
|
|
const SnAttachmentFragment._();
|
|
|
|
|
|
|
|
const factory SnAttachmentFragment({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required String rid,
|
|
|
|
required String uuid,
|
|
|
|
required int size,
|
|
|
|
required String name,
|
|
|
|
required String alt,
|
|
|
|
required String mimetype,
|
|
|
|
required String hash,
|
|
|
|
String? fingerprint,
|
|
|
|
@Default({}) Map<String, int> fileChunks,
|
|
|
|
@Default([]) List<String> fileChunksMissing,
|
|
|
|
}) = _SnAttachmentFragment;
|
|
|
|
|
|
|
|
factory SnAttachmentFragment.fromJson(Map<String, Object?> json) => _$SnAttachmentFragmentFromJson(json);
|
|
|
|
|
|
|
|
SnMediaType get mediaType => switch (mimetype.split('/').firstOrNull) {
|
|
|
|
'image' => SnMediaType.image,
|
|
|
|
'video' => SnMediaType.video,
|
|
|
|
'audio' => SnMediaType.audio,
|
|
|
|
_ => SnMediaType.file,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-11-09 04:04:03 +00:00
|
|
|
@freezed
|
|
|
|
class SnAttachmentPool with _$SnAttachmentPool {
|
|
|
|
const factory SnAttachmentPool({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required String alias,
|
|
|
|
required String name,
|
|
|
|
required String description,
|
|
|
|
required Map<String, dynamic> config,
|
|
|
|
required int? accountId,
|
|
|
|
}) = _SnAttachmentPool;
|
|
|
|
|
2024-12-26 14:19:01 +00:00
|
|
|
factory SnAttachmentPool.fromJson(Map<String, Object?> json) => _$SnAttachmentPoolFromJson(json);
|
2024-11-09 04:04:03 +00:00
|
|
|
}
|
2024-12-28 18:13:31 +00:00
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnAttachmentDestination with _$SnAttachmentDestination {
|
|
|
|
const factory SnAttachmentDestination({
|
|
|
|
@Default(0) int id,
|
|
|
|
required String type,
|
|
|
|
required String label,
|
|
|
|
required String region,
|
|
|
|
required bool isBoost,
|
|
|
|
}) = _SnAttachmentDestination;
|
|
|
|
|
|
|
|
factory SnAttachmentDestination.fromJson(Map<String, Object?> json) => _$SnAttachmentDestinationFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnAttachmentBoost with _$SnAttachmentBoost {
|
|
|
|
const factory SnAttachmentBoost({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required int status,
|
|
|
|
required int destination,
|
|
|
|
required int attachmentId,
|
|
|
|
required SnAttachment attachment,
|
|
|
|
required int account,
|
|
|
|
}) = _SnAttachmentBoost;
|
|
|
|
|
|
|
|
factory SnAttachmentBoost.fromJson(Map<String, Object?> json) => _$SnAttachmentBoostFromJson(json);
|
|
|
|
}
|