mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 11:07:42 +00:00
Merge pull request #524 from hjubb/file_server_v2
New File Server V2 URL handling and open group v2 fixes / features
This commit is contained in:
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import okhttp3.HttpUrl
|
||||
import org.session.libsession.messaging.StorageProtocol
|
||||
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
||||
import org.session.libsession.messaging.jobs.Job
|
||||
@@ -378,9 +379,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
SessionMetaProtocol.addTimestamp(timestamp)
|
||||
}
|
||||
|
||||
// override fun removeReceivedMessageTimestamps(timestamps: Set<Long>) {
|
||||
// TODO("Not yet implemented")
|
||||
// }
|
||||
override fun removeReceivedMessageTimestamps(timestamps: Set<Long>) {
|
||||
SessionMetaProtocol.removeTimestamps(timestamps)
|
||||
}
|
||||
|
||||
override fun getMessageIdInDatabase(timestamp: Long, author: String): Long? {
|
||||
val database = DatabaseFactory.getMmsSmsDatabase(context)
|
||||
@@ -543,8 +544,23 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
return DatabaseFactory.getLokiThreadDatabase(context).getAllV2OpenGroups()
|
||||
}
|
||||
|
||||
override fun addOpenGroup(server: String, channel: Long) {
|
||||
OpenGroupUtilities.addGroup(context, server, channel)
|
||||
override fun addOpenGroup(serverUrl: String, channel: Long) {
|
||||
val httpUrl = HttpUrl.parse(serverUrl) ?: return
|
||||
if (httpUrl.queryParameterNames().contains("public_key")) {
|
||||
// open group v2
|
||||
val server = HttpUrl.Builder().scheme(httpUrl.scheme()).host(httpUrl.host()).apply {
|
||||
if (httpUrl.port() != 80 || httpUrl.port() != 443) {
|
||||
// non-standard port, add to server
|
||||
this.port(httpUrl.port())
|
||||
}
|
||||
}.build()
|
||||
val room = httpUrl.pathSegments().firstOrNull() ?: return
|
||||
val publicKey = httpUrl.queryParameter("public_key") ?: return
|
||||
|
||||
OpenGroupUtilities.addGroup(context, server.toString().removeSuffix("/"), room, publicKey)
|
||||
} else {
|
||||
OpenGroupUtilities.addGroup(context, serverUrl, channel)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllGroups(): List<GroupRecord> {
|
||||
|
@@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
|
||||
@@ -410,6 +411,7 @@ public class ThreadDatabase extends Database {
|
||||
deleteThread(threadId);
|
||||
notifyConversationListeners(threadId);
|
||||
notifyConversationListListeners();
|
||||
SessionMetaProtocol.clearReceivedMessages();
|
||||
}
|
||||
|
||||
public boolean hasThread(long threadId) {
|
||||
|
@@ -24,6 +24,15 @@ object SessionMetaProtocol {
|
||||
timestamps.add(timestamp)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun clearReceivedMessages() {
|
||||
timestamps.clear()
|
||||
}
|
||||
|
||||
fun removeTimestamps(timestamps: Set<Long>) {
|
||||
this.timestamps.removeAll(timestamps)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shouldIgnoreMessage(timestamp: Long): Boolean {
|
||||
val shouldIgnoreMessage = timestamps.contains(timestamp)
|
||||
|
Reference in New Issue
Block a user