Solian/lib/models/event.dart

67 lines
1.5 KiB
Dart
Raw Permalink 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/channel.dart';
part 'event.g.dart';
@JsonSerializable()
class Event {
2024-05-18 10:17:16 +00:00
int id;
2024-05-26 05:39:21 +00:00
String uuid;
2024-05-18 10:17:16 +00:00
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Map<String, dynamic> body;
2024-05-18 10:17:16 +00:00
String type;
Channel? channel;
ChannelMember sender;
2024-05-18 10:17:16 +00:00
int channelId;
int senderId;
@JsonKey(includeFromJson: false, includeToJson: true)
2024-06-27 16:59:11 +00:00
bool isPending = false;
2024-05-18 10:17:16 +00:00
Event({
2024-05-18 10:17:16 +00:00
required this.id,
2024-05-26 05:39:21 +00:00
required this.uuid,
2024-05-18 10:17:16 +00:00
required this.createdAt,
required this.updatedAt,
this.deletedAt,
required this.body,
2024-05-18 10:17:16 +00:00
required this.type,
this.channel,
required this.sender,
required this.channelId,
required this.senderId,
});
factory Event.fromJson(Map<String, dynamic> json) => _$EventFromJson(json);
2024-05-18 10:17:16 +00:00
Map<String, dynamic> toJson() => _$EventToJson(this);
2024-05-18 10:17:16 +00:00
}
@JsonSerializable()
class EventMessageBody {
@JsonKey(defaultValue: '')
String text;
@JsonKey(defaultValue: 'plain')
String algorithm;
List<String>? attachments;
int? quoteEvent;
int? relatedEvent;
List<int>? relatedUsers;
EventMessageBody({
required this.text,
required this.algorithm,
required this.attachments,
required this.quoteEvent,
required this.relatedEvent,
required this.relatedUsers,
});
factory EventMessageBody.fromJson(Map<String, dynamic> json) =>
_$EventMessageBodyFromJson(json);
2024-05-18 10:17:16 +00:00
Map<String, dynamic> toJson() => _$EventMessageBodyToJson(this);
2024-05-18 10:17:16 +00:00
}