fix(llc): fix not able to update message with type: reply.
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -168,8 +168,16 @@ class Message extends Equatable {
|
|||||||
late final MessageState state;
|
late final MessageState state;
|
||||||
|
|
||||||
/// The message type.
|
/// The message type.
|
||||||
|
@JsonKey(includeIfNull: false, toJson: _typeToJson)
|
||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
|
// We need to skip passing type if it's not regular or system as the API
|
||||||
|
// does not expect it.
|
||||||
|
static String? _typeToJson(String type) {
|
||||||
|
if (['regular', 'system'].contains(type)) return type;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// The list of attachments, either provided by the user or generated from a
|
/// The list of attachments, either provided by the user or generated from a
|
||||||
/// command or as a result of URL scraping.
|
/// command or as a result of URL scraping.
|
||||||
@JsonKey(includeIfNull: false)
|
@JsonKey(includeIfNull: false)
|
||||||
|
|||||||
@@ -71,17 +71,27 @@ Message _$MessageFromJson(Map<String, dynamic> json) => Message(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$MessageToJson(Message instance) => <String, dynamic>{
|
Map<String, dynamic> _$MessageToJson(Message instance) {
|
||||||
'id': instance.id,
|
final val = <String, dynamic>{
|
||||||
'text': instance.text,
|
'id': instance.id,
|
||||||
'type': instance.type,
|
'text': instance.text,
|
||||||
'attachments': instance.attachments.map((e) => e.toJson()).toList(),
|
};
|
||||||
'mentioned_users': User.toIds(instance.mentionedUsers),
|
|
||||||
'parent_id': instance.parentId,
|
void writeNotNull(String key, dynamic value) {
|
||||||
'quoted_message_id': instance.quotedMessageId,
|
if (value != null) {
|
||||||
'show_in_channel': instance.showInChannel,
|
val[key] = value;
|
||||||
'silent': instance.silent,
|
}
|
||||||
'pinned': instance.pinned,
|
}
|
||||||
'pin_expires': instance.pinExpires?.toIso8601String(),
|
|
||||||
'extra_data': instance.extraData,
|
writeNotNull('type', Message._typeToJson(instance.type));
|
||||||
};
|
val['attachments'] = instance.attachments.map((e) => e.toJson()).toList();
|
||||||
|
val['mentioned_users'] = User.toIds(instance.mentionedUsers);
|
||||||
|
val['parent_id'] = instance.parentId;
|
||||||
|
val['quoted_message_id'] = instance.quotedMessageId;
|
||||||
|
val['show_in_channel'] = instance.showInChannel;
|
||||||
|
val['silent'] = instance.silent;
|
||||||
|
val['pinned'] = instance.pinned;
|
||||||
|
val['pin_expires'] = instance.pinExpires?.toIso8601String();
|
||||||
|
val['extra_data'] = instance.extraData;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user