aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2026-06-07 23:10:29 +0200
committerfiaxh <git@lightrise.org>2026-06-07 23:10:29 +0200
commitcf8e81e26862b463c6d42fc6359557db85eb8d90 (patch)
treee08d43c625ca7ba1353d2feabd3d98df5ac54297
parente76a727fdc4a28ec3b6a1a7aed57f6a283bf2eda (diff)
Handle invalid content item database entries better
-rw-r--r--libdino/src/service/content_item_store.vala11
1 files changed, 6 insertions, 5 deletions
diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala
index 99475492..37c82eb7 100644
--- a/libdino/src/service/content_item_store.vala
+++ b/libdino/src/service/content_item_store.vala
@@ -44,8 +44,8 @@ public class ContentItemStore : StreamInteractionModule, Object {
Gee.TreeSet<ContentItem> items = new Gee.TreeSet<ContentItem>(ContentItem.compare_func);
foreach (var row in select) {
- ContentItem content_item = get_item_from_row(row, conversation);
- items.add(content_item);
+ ContentItem? content_item = get_item_from_row(row, conversation);
+ if (content_item != null) items.add(content_item);
}
Gee.List<ContentItem> ret = new ArrayList<ContentItem>();
@@ -55,7 +55,7 @@ public class ContentItemStore : StreamInteractionModule, Object {
return ret;
}
- private ContentItem get_item_from_row(Row row, Conversation conversation) throws Error {
+ private ContentItem? get_item_from_row(Row row, Conversation conversation) {
int id = row[db.content_item.id];
int content_type = row[db.content_item.content_type];
int foreign_id = row[db.content_item.foreign_id];
@@ -63,7 +63,7 @@ public class ContentItemStore : StreamInteractionModule, Object {
return get_item(conversation, id, content_type, foreign_id, time);
}
- private ContentItem get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) throws Error {
+ private ContentItem? get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) {
switch (content_type) {
case 1:
Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation);
@@ -95,7 +95,8 @@ public class ContentItemStore : StreamInteractionModule, Object {
warning("Unknown content item type: %i", content_type);
break;
}
- throw new Error(-1, 0, "Bad content type %i or non existing content item %i", content_type, foreign_id);
+ warning("Bad content type %i or non existing content item %i", content_type, foreign_id);
+ return null;
}
public ContentItem? get_item_by_foreign(Conversation conversation, int type, int foreign_id) {