mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 12:16:47 +00:00
fix: null pointer
This commit is contained in:
parent
0f16ab68b7
commit
e6160990fe
3 changed files with 21 additions and 12 deletions
|
|
@ -71,12 +71,14 @@ Future<bool> handleContactRequest(
|
|||
final contact = await twonlyDB.contactsDao
|
||||
.getContactByUserId(fromUserId)
|
||||
.getSingleOrNull();
|
||||
if (contact != null) {
|
||||
await twonlyDB.groupsDao.createNewDirectChat(
|
||||
fromUserId,
|
||||
GroupsCompanion(
|
||||
groupName: Value(getContactDisplayName(contact!)),
|
||||
groupName: Value(getContactDisplayName(contact)),
|
||||
),
|
||||
);
|
||||
}
|
||||
case EncryptedContent_ContactRequest_Type.REJECT:
|
||||
Log.info('Got a contact reject from $fromUserId');
|
||||
await twonlyDB.contactsDao.updateContact(
|
||||
|
|
|
|||
|
|
@ -139,12 +139,21 @@ Future<void> handleMediaUpdate(
|
|||
.getMessageById(mediaUpdate.targetMessageId)
|
||||
.getSingleOrNull();
|
||||
if (message == null) {
|
||||
Log.error(
|
||||
// this can happen, in case the message was already deleted.
|
||||
Log.info(
|
||||
'Got media update to message ${mediaUpdate.targetMessageId} but message not found.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (message.mediaId == null) {
|
||||
// this can happen, in case the message was already deleted.
|
||||
Log.warn(
|
||||
'Got media update for message ${mediaUpdate.targetMessageId} which does not have a mediaId defined.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
final mediaFile =
|
||||
await twonlyDB.mediaFilesDao.getMediaFileById(message!.mediaId!);
|
||||
await twonlyDB.mediaFilesDao.getMediaFileById(message.mediaId!);
|
||||
if (mediaFile == null) {
|
||||
Log.info(
|
||||
'Got media file update, but media file was not found ${message.mediaId}',
|
||||
|
|
|
|||
|
|
@ -231,9 +231,7 @@ Future<void> downloadFileFast(
|
|||
await handleEncryptedFile(media.mediaId);
|
||||
return;
|
||||
} else {
|
||||
if (response.statusCode == 404 ||
|
||||
response.statusCode == 403 ||
|
||||
response.statusCode == 400) {
|
||||
if (response.statusCode == 404 || response.statusCode == 403) {
|
||||
Log.error(
|
||||
'Got ${response.statusCode} from server. Requesting upload again',
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue