mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:08:41 +00:00
multiple bug fixes
This commit is contained in:
parent
0485e306e1
commit
e7b48ecf63
3 changed files with 16 additions and 19 deletions
|
|
@ -184,7 +184,7 @@ Future<(String, RetransmitMessage)?> encryptMessage(
|
||||||
Future encryptAndSendMessageAsync(int? messageId, int userId, MessageJson msg,
|
Future encryptAndSendMessageAsync(int? messageId, int userId, MessageJson msg,
|
||||||
{PushKind? pushKind}) async {
|
{PushKind? pushKind}) async {
|
||||||
(String, RetransmitMessage)? stateData =
|
(String, RetransmitMessage)? stateData =
|
||||||
await encryptMessage(messageId, userId, msg);
|
await encryptMessage(messageId, userId, msg, pushKind: pushKind);
|
||||||
if (stateData != null) {
|
if (stateData != null) {
|
||||||
final (stateId, message) = stateData;
|
final (stateId, message) = stateData;
|
||||||
sendRetransmitMessage(stateId, message);
|
sendRetransmitMessage(stateId, message);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,10 @@ Future retryMediaUpload({int maxRetries = 3}) async {
|
||||||
if (mediaFile.uploadTokens != null) {
|
if (mediaFile.uploadTokens != null) {
|
||||||
/// the file was already uploaded.
|
/// the file was already uploaded.
|
||||||
/// notify the server to remove the upload
|
/// notify the server to remove the upload
|
||||||
|
apiProvider.getDownloadTokens(mediaFile.uploadTokens!.uploadToken, 0);
|
||||||
}
|
}
|
||||||
|
await twonlyDatabase.mediaUploadsDao
|
||||||
|
.deleteMediaUpload(mediaFile.mediaUploadId);
|
||||||
Logger("media_send.dart").shout(
|
Logger("media_send.dart").shout(
|
||||||
"upload can be removed, the finalized function was never called...");
|
"upload can be removed, the finalized function was never called...");
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -90,9 +93,9 @@ Future retryMediaUpload({int maxRetries = 3}) async {
|
||||||
});
|
});
|
||||||
if (maxRetries == 0) return;
|
if (maxRetries == 0) return;
|
||||||
// retry upload
|
// retry upload
|
||||||
Future.delayed(const Duration(milliseconds: 1000), () {
|
// Future.delayed(const Duration(milliseconds: 1000), () {
|
||||||
retryMediaUpload(maxRetries: maxRetries - 1);
|
// retryMediaUpload(maxRetries: maxRetries - 1);
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int?> initMediaUpload() async {
|
Future<int?> initMediaUpload() async {
|
||||||
|
|
@ -406,7 +409,6 @@ Future<bool> handleMediaUpload(int mediaUploadId) async {
|
||||||
final response = await http.Response.fromStream(streamedResponse);
|
final response = await http.Response.fromStream(streamedResponse);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Logger("media_send.dart").info("Uploaded: $response");
|
|
||||||
if (response.body.length != 64) {
|
if (response.body.length != 64) {
|
||||||
Logger("media_send.dart").info("Got invalid upload token.");
|
Logger("media_send.dart").info("Got invalid upload token.");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -187,17 +187,11 @@ class ApiProvider {
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getRetransmission() async {
|
Future<Map<String, dynamic>> getRetransmission() async {
|
||||||
final box = await getMediaStorage();
|
final box = await getMediaStorage();
|
||||||
Map<String, dynamic>? retransmit = box.get("rawbytes-to-retransmit");
|
try {
|
||||||
// Map<String, dynamic> retransmit = {};
|
return box.get("rawbytes-to-retransmit");
|
||||||
// if (retransmitJson != null) {
|
} catch (e) {
|
||||||
// try {
|
return {};
|
||||||
// retransmit = jsonDecode(retransmitJson);
|
}
|
||||||
// } catch (e) {
|
|
||||||
// Logger("api.dart").shout("Could not decode the rawbytes messages: $e");
|
|
||||||
// await box.delete("rawbytes-to-retransmit");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return retransmit ?? {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future retransmitRawBytes() async {
|
Future retransmitRawBytes() async {
|
||||||
|
|
@ -413,14 +407,15 @@ class ApiProvider {
|
||||||
return await sendRequestSync(req);
|
return await sendRequestSync(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Result> getDownloadTokens(
|
Future<Result> getDownloadTokens(List<int> uploadToken, int recipientsCount,
|
||||||
List<int> uploadToken, int recipientsCount) async {
|
{bool ensureRetransmission = false}) async {
|
||||||
var get = ApplicationData_UploadDone()
|
var get = ApplicationData_UploadDone()
|
||||||
..uploadToken = uploadToken
|
..uploadToken = uploadToken
|
||||||
..recipientsCount = recipientsCount;
|
..recipientsCount = recipientsCount;
|
||||||
var appData = ApplicationData()..uploaddone = get;
|
var appData = ApplicationData()..uploaddone = get;
|
||||||
var req = createClientToServerFromApplicationData(appData);
|
var req = createClientToServerFromApplicationData(appData);
|
||||||
return await sendRequestSync(req);
|
return await sendRequestSync(req,
|
||||||
|
ensureRetransmission: ensureRetransmission);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Result> downloadDone(List<int> token) async {
|
Future<Result> downloadDone(List<int> token) async {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue