Merge pull request #770 from GetStream/feat/hard-delete

feat(llc): added hard delete
This commit is contained in:
Salvatore Giordano
2021-11-26 15:28:40 +01:00
committed by GitHub
7 changed files with 70 additions and 30 deletions
@@ -80,10 +80,16 @@ class MessageApi {
/// Deletes the given [messageId]
Future<EmptyResponse> deleteMessage(
String messageId,
) async {
String messageId, {
bool? hard,
}) async {
final response = await _client.delete(
'/messages/$messageId',
queryParameters: hard != null
? {
'hard': hard,
}
: null,
);
return EmptyResponse.fromJson(response.data);
}
@@ -27,6 +27,7 @@ class Event {
this.channelId,
this.channelType,
this.parentId,
this.hardDelete,
this.extraData = const {},
this.isLocal = true,
}) : createdAt = createdAt?.toUtc() ?? DateTime.now().toUtc();
@@ -91,6 +92,10 @@ class Event {
@JsonKey(defaultValue: false)
final bool isLocal;
/// This is true if the message has been hard deleted
@JsonKey(includeIfNull: false)
final bool? hardDelete;
/// Map of custom channel extraData
final Map<String, Object?> extraData;
@@ -113,6 +118,7 @@ class Event {
'channel_id',
'channel_type',
'parent_id',
'hard_delete',
'is_local',
];
@@ -139,6 +145,7 @@ class Event {
int? unreadChannels,
bool? online,
String? parentId,
bool? hardDelete,
Map<String, Object?>? extraData,
}) =>
Event(
@@ -158,6 +165,7 @@ class Event {
channelId: channelId ?? this.channelId,
channelType: channelType ?? this.channelType,
parentId: parentId ?? this.parentId,
hardDelete: hardDelete ?? this.hardDelete,
extraData: extraData ?? this.extraData,
isLocal: isLocal,
);
@@ -37,30 +37,42 @@ Event _$EventFromJson(Map<String, dynamic> json) => Event(
channelId: json['channel_id'] as String?,
channelType: json['channel_type'] as String?,
parentId: json['parent_id'] as String?,
hardDelete: json['hard_delete'] as bool?,
extraData: json['extra_data'] as Map<String, dynamic>? ?? const {},
isLocal: json['is_local'] as bool? ?? false,
);
Map<String, dynamic> _$EventToJson(Event instance) => <String, dynamic>{
'type': instance.type,
'cid': instance.cid,
'channel_id': instance.channelId,
'channel_type': instance.channelType,
'connection_id': instance.connectionId,
'created_at': instance.createdAt.toIso8601String(),
'me': instance.me?.toJson(),
'user': instance.user?.toJson(),
'message': instance.message?.toJson(),
'channel': instance.channel?.toJson(),
'member': instance.member?.toJson(),
'reaction': instance.reaction?.toJson(),
'total_unread_count': instance.totalUnreadCount,
'unread_channels': instance.unreadChannels,
'online': instance.online,
'parent_id': instance.parentId,
'is_local': instance.isLocal,
'extra_data': instance.extraData,
};
Map<String, dynamic> _$EventToJson(Event instance) {
final val = <String, dynamic>{
'type': instance.type,
'cid': instance.cid,
'channel_id': instance.channelId,
'channel_type': instance.channelType,
'connection_id': instance.connectionId,
'created_at': instance.createdAt.toIso8601String(),
'me': instance.me?.toJson(),
'user': instance.user?.toJson(),
'message': instance.message?.toJson(),
'channel': instance.channel?.toJson(),
'member': instance.member?.toJson(),
'reaction': instance.reaction?.toJson(),
'total_unread_count': instance.totalUnreadCount,
'unread_channels': instance.unreadChannels,
'online': instance.online,
'parent_id': instance.parentId,
'is_local': instance.isLocal,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('hard_delete', instance.hardDelete);
val['extra_data'] = instance.extraData;
return val;
}
EventChannel _$EventChannelFromJson(Map<String, dynamic> json) => EventChannel(
members: (json['members'] as List<dynamic>?)
@@ -8,7 +8,7 @@ part 'read.g.dart';
@JsonSerializable()
class Read extends Equatable {
/// Constructor used for json serialization
Read({
const Read({
required this.lastRead,
required this.user,
this.unreadMessages = 0,