FileMessage.fromParams constructor
FileMessage.fromParams({
- required FileMessageCreateParams params,
- required BaseChannel channel,
Implementation
factory FileMessage.fromParams({
required FileMessageCreateParams params,
required BaseChannel channel,
}) {
final message = FileMessage(
channelType: channel.channelType,
channelUrl: channel.channelUrl,
messageId: 0,
requestId: const Uuid().v1(),
// BaseMessageCreateParams
data: params.data,
customType: params.customType,
mentionType: params.mentionType,
metaArrays: params.metaArrays,
parentMessageId: params.parentMessageId,
replyToChannel: params.replyToChannel,
// FileMessageCreateParams
url: params.fileInfo.fileUrl ?? '',
file: params.fileInfo.file,
name: params.fileInfo.fileName,
type: params.fileInfo.mimeType,
size: params.fileInfo.fileSize ?? 0,
createdAt: DateTime.now().millisecondsSinceEpoch,
requireAuth: false,
);
// mentionedUserIds
if (params.mentionedUserIds != null &&
params.mentionedUserIds!.isNotEmpty) {
message.mentionedUserIds.addAll(params.mentionedUserIds!);
}
return message;
}