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
|
final contact = await twonlyDB.contactsDao
|
||||||
.getContactByUserId(fromUserId)
|
.getContactByUserId(fromUserId)
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
await twonlyDB.groupsDao.createNewDirectChat(
|
if (contact != null) {
|
||||||
fromUserId,
|
await twonlyDB.groupsDao.createNewDirectChat(
|
||||||
GroupsCompanion(
|
fromUserId,
|
||||||
groupName: Value(getContactDisplayName(contact!)),
|
GroupsCompanion(
|
||||||
),
|
groupName: Value(getContactDisplayName(contact)),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
case EncryptedContent_ContactRequest_Type.REJECT:
|
case EncryptedContent_ContactRequest_Type.REJECT:
|
||||||
Log.info('Got a contact reject from $fromUserId');
|
Log.info('Got a contact reject from $fromUserId');
|
||||||
await twonlyDB.contactsDao.updateContact(
|
await twonlyDB.contactsDao.updateContact(
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,21 @@ Future<void> handleMediaUpdate(
|
||||||
.getMessageById(mediaUpdate.targetMessageId)
|
.getMessageById(mediaUpdate.targetMessageId)
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
Log.error(
|
// this can happen, in case the message was already deleted.
|
||||||
'Got media update to message ${mediaUpdate.targetMessageId} but message not found.',
|
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 =
|
final mediaFile =
|
||||||
await twonlyDB.mediaFilesDao.getMediaFileById(message!.mediaId!);
|
await twonlyDB.mediaFilesDao.getMediaFileById(message.mediaId!);
|
||||||
if (mediaFile == null) {
|
if (mediaFile == null) {
|
||||||
Log.info(
|
Log.info(
|
||||||
'Got media file update, but media file was not found ${message.mediaId}',
|
'Got media file update, but media file was not found ${message.mediaId}',
|
||||||
|
|
|
||||||
|
|
@ -231,9 +231,7 @@ Future<void> downloadFileFast(
|
||||||
await handleEncryptedFile(media.mediaId);
|
await handleEncryptedFile(media.mediaId);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (response.statusCode == 404 ||
|
if (response.statusCode == 404 || response.statusCode == 403) {
|
||||||
response.statusCode == 403 ||
|
|
||||||
response.statusCode == 400) {
|
|
||||||
Log.error(
|
Log.error(
|
||||||
'Got ${response.statusCode} from server. Requesting upload again',
|
'Got ${response.statusCode} from server. Requesting upload again',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue