2024-11-16 08:55:31 +00:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-11-16 13:15:55 +00:00
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
2024-11-24 12:23:06 +00:00
|
|
|
import 'package:livekit_client/livekit_client.dart';
|
2024-11-16 17:16:54 +00:00
|
|
|
import 'package:surface/types/account.dart';
|
2024-11-17 16:55:39 +00:00
|
|
|
import 'package:surface/types/attachment.dart';
|
2024-11-16 08:55:31 +00:00
|
|
|
import 'package:surface/types/realm.dart';
|
|
|
|
|
|
|
|
part 'chat.freezed.dart';
|
|
|
|
part 'chat.g.dart';
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnChannel with _$SnChannel {
|
2024-11-16 13:15:55 +00:00
|
|
|
const SnChannel._();
|
|
|
|
|
|
|
|
@HiveType(typeId: 2)
|
2024-11-16 08:55:31 +00:00
|
|
|
const factory SnChannel({
|
2024-11-16 13:15:55 +00:00
|
|
|
@HiveField(0) required int id,
|
|
|
|
@HiveField(1) required DateTime createdAt,
|
|
|
|
@HiveField(2) required DateTime updatedAt,
|
|
|
|
@HiveField(3) required dynamic deletedAt,
|
|
|
|
@HiveField(4) required String alias,
|
|
|
|
@HiveField(5) required String name,
|
|
|
|
@HiveField(6) required String description,
|
2024-12-08 05:45:51 +00:00
|
|
|
@HiveField(7) required List<SnChannelMember>? members,
|
2024-11-16 17:16:54 +00:00
|
|
|
List<SnChatMessage>? messages,
|
2024-11-16 13:15:55 +00:00
|
|
|
@HiveField(8) required int type,
|
|
|
|
@HiveField(9) required int accountId,
|
|
|
|
@HiveField(10) required SnRealm? realm,
|
|
|
|
@HiveField(11) required int? realmId,
|
|
|
|
@HiveField(12) required bool isPublic,
|
|
|
|
@HiveField(13) required bool isCommunity,
|
2024-11-16 08:55:31 +00:00
|
|
|
}) = _SnChannel;
|
|
|
|
|
|
|
|
factory SnChannel.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SnChannelFromJson(json);
|
2024-11-16 13:15:55 +00:00
|
|
|
|
|
|
|
String get key => '${realm?.alias ?? 'global'}:$alias';
|
2024-11-16 17:16:54 +00:00
|
|
|
String get keyPath => '${realm?.alias ?? 'global'}/$alias';
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnChannelMember with _$SnChannelMember {
|
|
|
|
const SnChannelMember._();
|
|
|
|
|
|
|
|
@HiveType(typeId: 3)
|
|
|
|
const factory SnChannelMember({
|
|
|
|
@HiveField(0) required int id,
|
|
|
|
@HiveField(1) required DateTime createdAt,
|
|
|
|
@HiveField(2) required DateTime updatedAt,
|
|
|
|
@HiveField(3) required DateTime? deletedAt,
|
|
|
|
@HiveField(4) required int channelId,
|
|
|
|
@HiveField(5) required int accountId,
|
|
|
|
@HiveField(6) required String? nick,
|
|
|
|
@HiveField(7) required SnChannel? channel,
|
|
|
|
@HiveField(8) required SnAccount? account,
|
|
|
|
@Default(0) int notify,
|
|
|
|
@HiveField(9) required int powerLevel,
|
|
|
|
dynamic calls,
|
|
|
|
dynamic events,
|
|
|
|
}) = _SnChannelMember;
|
|
|
|
|
|
|
|
factory SnChannelMember.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SnChannelMemberFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnChatMessage with _$SnChatMessage {
|
|
|
|
const SnChatMessage._();
|
|
|
|
|
|
|
|
@HiveType(typeId: 4)
|
|
|
|
const factory SnChatMessage({
|
|
|
|
@HiveField(0) required int id,
|
|
|
|
@HiveField(1) required DateTime createdAt,
|
|
|
|
@HiveField(2) required DateTime updatedAt,
|
|
|
|
@HiveField(3) required DateTime? deletedAt,
|
|
|
|
@HiveField(4) required String uuid,
|
2024-11-18 15:59:08 +00:00
|
|
|
@HiveField(5) @Default({}) Map<String, dynamic> body,
|
2024-11-16 17:16:54 +00:00
|
|
|
@HiveField(6) required String type,
|
|
|
|
@HiveField(7) required SnChannel channel,
|
|
|
|
@HiveField(8) required SnChannelMember sender,
|
|
|
|
@HiveField(9) required int channelId,
|
|
|
|
@HiveField(10) required int senderId,
|
2024-11-18 15:04:36 +00:00
|
|
|
@HiveField(11) required int? quoteEventId,
|
2024-11-18 15:59:08 +00:00
|
|
|
@HiveField(12) required int? relatedEventId,
|
2024-11-17 16:55:39 +00:00
|
|
|
SnChatMessagePreload? preload,
|
2024-11-16 17:16:54 +00:00
|
|
|
}) = _SnChatMessage;
|
|
|
|
|
|
|
|
factory SnChatMessage.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SnChatMessageFromJson(json);
|
2024-11-16 08:55:31 +00:00
|
|
|
}
|
2024-11-17 16:55:39 +00:00
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnChatMessagePreload with _$SnChatMessagePreload {
|
|
|
|
const SnChatMessagePreload._();
|
|
|
|
|
|
|
|
const factory SnChatMessagePreload({
|
2024-11-18 14:33:03 +00:00
|
|
|
List<SnAttachment?>? attachments,
|
|
|
|
SnChatMessage? quoteEvent,
|
2024-11-17 16:55:39 +00:00
|
|
|
}) = _SnChatMessagePreload;
|
|
|
|
|
|
|
|
factory SnChatMessagePreload.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SnChatMessagePreloadFromJson(json);
|
|
|
|
}
|
2024-11-24 12:23:06 +00:00
|
|
|
|
|
|
|
@freezed
|
|
|
|
class SnChatCall with _$SnChatCall {
|
|
|
|
const factory SnChatCall({
|
|
|
|
required int id,
|
|
|
|
required DateTime createdAt,
|
|
|
|
required DateTime updatedAt,
|
|
|
|
required DateTime? deletedAt,
|
|
|
|
required DateTime? endedAt,
|
|
|
|
required String externalId,
|
|
|
|
required int founderId,
|
|
|
|
required int channelId,
|
|
|
|
required SnChannelMember founder,
|
|
|
|
@Default([]) List<dynamic> participants,
|
|
|
|
}) = _SnChatCall;
|
|
|
|
|
|
|
|
factory SnChatCall.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SnChatCallFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call stuff
|
|
|
|
|
|
|
|
enum ParticipantStatsType {
|
|
|
|
unknown,
|
|
|
|
localAudioSender,
|
|
|
|
localVideoSender,
|
|
|
|
remoteAudioReceiver,
|
|
|
|
remoteVideoReceiver,
|
|
|
|
}
|
|
|
|
|
|
|
|
class ParticipantTrack {
|
|
|
|
ParticipantTrack(
|
|
|
|
{required this.participant,
|
|
|
|
required this.videoTrack,
|
|
|
|
required this.isScreenShare});
|
|
|
|
|
|
|
|
VideoTrack? videoTrack;
|
|
|
|
Participant participant;
|
|
|
|
bool isScreenShare;
|
|
|
|
}
|