Change summary
src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java | 22
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 4
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 5
3 files changed, 30 insertions(+), 1 deletion(-)
Detailed changes
@@ -1016,6 +1016,28 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return list;
}
+ public Message getMessage(Conversation conversation, String uuid) {
+ ArrayList<Message> list = new ArrayList<>();
+ SQLiteDatabase db = this.getReadableDatabase();
+ Cursor cursor;
+ cursor = db.rawQuery(
+ "SELECT * FROM " + Message.TABLENAME + " " +
+ "LEFT JOIN cheogram." + Message.TABLENAME +
+ " USING (" + Message.UUID + ")" +
+ "WHERE " + Message.UUID + "=?",
+ new String[]{uuid}
+ );
+ while (cursor.moveToNext()) {
+ try {
+ return Message.fromCursor(cursor, conversation);
+ } catch (Exception e) {
+ Log.e(Config.LOGTAG, "unable to restore message");
+ }
+ }
+ cursor.close();
+ return null;
+ }
+
public ArrayList<Message> getMessages(Conversation conversations, int limit) {
return getMessages(conversations, limit, -1);
}
@@ -635,6 +635,10 @@ public class XmppConnectionService extends Service {
this.databaseBackend.clearBlockedMedia();
}
+ public Message getMessage(Conversation conversation, String uuid) {
+ return this.databaseBackend.getMessage(conversation, uuid);
+ }
+
public void insertWebxdcUpdate(final WebxdcUpdate update) {
this.databaseBackend.insertWebxdcUpdate(update);
}
@@ -3268,9 +3268,12 @@ public class ConversationFragment extends XmppFragment
});
return;
}
- final Message message =
+ Message message =
downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid);
if ("webxdc".equals(postInitAction)) {
+ if (message == null) {
+ message = activity.xmppConnectionService.getMessage(conversation, downloadUuid);
+ }
if (message == null) return;
Cid webxdcCid = message.getFileParams().getCids().get(0);