feat: работа с шифрованным текстом/фото
This commit is contained in:
@@ -26,12 +26,18 @@ class UploadDone extends UploadEvent {
|
||||
final String? url;
|
||||
final String filename;
|
||||
final int size;
|
||||
|
||||
/// Server-assigned message id. Without it the optimistic message keeps its
|
||||
/// local temp id and download URLs cannot be resolved until a restart.
|
||||
final String? messageId;
|
||||
|
||||
const UploadDone({
|
||||
required this.fileId,
|
||||
required this.filename,
|
||||
required this.size,
|
||||
this.token,
|
||||
this.url,
|
||||
this.messageId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,14 +145,14 @@ class FileUploader {
|
||||
return;
|
||||
}
|
||||
|
||||
final ok = await messages.sendFileMessage(
|
||||
final messageId = await messages.sendFileMessage(
|
||||
chatId,
|
||||
info.fileId,
|
||||
token: info.token,
|
||||
scheduledTime: scheduledTime,
|
||||
);
|
||||
if (cancelled) return;
|
||||
if (!ok) {
|
||||
if (messageId == null) {
|
||||
ctrl.add(const UploadError('send_failed'));
|
||||
return;
|
||||
}
|
||||
@@ -158,6 +164,7 @@ class FileUploader {
|
||||
url: info.url,
|
||||
filename: filename,
|
||||
size: totalSize,
|
||||
messageId: messageId,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
@@ -1314,7 +1314,10 @@ class MessagesModule {
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> sendFileMessage(
|
||||
/// Returns the server-assigned message id, or null on failure. The id is
|
||||
/// required to later resolve a download URL — a message still carrying its
|
||||
/// local temp id resolves to messageId 0 and the server rejects it.
|
||||
Future<String?> sendFileMessage(
|
||||
int chatId,
|
||||
int fileId, {
|
||||
String? token,
|
||||
@@ -1343,12 +1346,12 @@ class MessagesModule {
|
||||
}
|
||||
final payload = {'chatId': chatId, 'message': message, 'notify': notify};
|
||||
|
||||
return _sendWithNotReadyRetry<bool>(
|
||||
return _sendWithNotReadyRetry<String?>(
|
||||
payload: payload,
|
||||
maxAttempts: maxAttempts,
|
||||
retryDelay: retryDelay,
|
||||
onResult: (response) => response.isOk,
|
||||
onExhausted: false,
|
||||
onResult: (response) => _sentMessageMap(response)?['id']?.toString(),
|
||||
onExhausted: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user