mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Do some renaming, Sygnal is an implementation of a PushGateway.
This commit is contained in:
parent
d1fb1614a3
commit
48ca1384f8
14 changed files with 55 additions and 54 deletions
|
@ -17,6 +17,7 @@ Improvements 🙌:
|
|||
- Filter room member (and banned users) by name (#2184)
|
||||
- Implement "Jump to read receipt" and "Mention" actions on the room member profile screen
|
||||
- Add Sygnal API implementation to test is Push are correctly received
|
||||
- Add PushGateway API implementation to test if Push are correctly received
|
||||
|
||||
Bugfix 🐛:
|
||||
- Improve support for image/audio/video/file selection with intent changes (#1376)
|
||||
|
|
|
@ -18,6 +18,6 @@ package org.matrix.android.sdk.api.session.pushers
|
|||
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
|
||||
sealed class SygnalFailure : Failure.FeatureFailure() {
|
||||
object PusherRejected : SygnalFailure()
|
||||
sealed class PushGatewayFailure : Failure.FeatureFailure() {
|
||||
object PusherRejected : PushGatewayFailure()
|
||||
}
|
|
@ -67,12 +67,12 @@ interface PushersService {
|
|||
withEventIdOnly: Boolean): UUID
|
||||
|
||||
/**
|
||||
* Directly ask Sygnal to send a push to this device
|
||||
* @param url the Sygnal url (full path)
|
||||
* Directly ask the push gateway to send a push to this device
|
||||
* @param url the push gateway url (full path)
|
||||
* @param appId the application id
|
||||
* @param pushkey the FCM token
|
||||
* @param eventId the eventId which will be sent in the Push message. Use a fake eventId.
|
||||
* @param callback callback to know if Sygnal has accepted the request. In this case, the app should receive a Push with the provided eventId.
|
||||
* @param callback callback to know if the push gateway has accepted the request. In this case, the app should receive a Push with the provided eventId.
|
||||
* In case of error, PusherRejected failure can happen. In this case it means that the pushkey is not valid.
|
||||
*/
|
||||
fun testPush(url: String,
|
||||
|
|
|
@ -31,8 +31,8 @@ internal object NetworkConstants {
|
|||
const val URI_IDENTITY_PREFIX_PATH = "_matrix/identity/v2"
|
||||
const val URI_IDENTITY_PATH_V2 = "$URI_IDENTITY_PREFIX_PATH/"
|
||||
|
||||
// Sygnal
|
||||
const val URI_SYGNAL_PREFIX_PATH = "_matrix/push/v1/"
|
||||
// Push Gateway
|
||||
const val URI_PUSH_GATEWAY_PREFIX_PATH = "_matrix/push/v1/"
|
||||
|
||||
// Integration
|
||||
const val URI_INTEGRATION_MANAGER_PATH = "_matrix/integrations/v1/"
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.matrix.android.sdk.internal.database.query.where
|
|||
import org.matrix.android.sdk.internal.di.SessionDatabase
|
||||
import org.matrix.android.sdk.internal.di.SessionId
|
||||
import org.matrix.android.sdk.internal.di.WorkManagerProvider
|
||||
import org.matrix.android.sdk.internal.session.pushers.sygnal.SygnalNotifyTask
|
||||
import org.matrix.android.sdk.internal.session.pushers.gateway.PushGatewayNotifyTask
|
||||
import org.matrix.android.sdk.internal.task.TaskExecutor
|
||||
import org.matrix.android.sdk.internal.task.configureWith
|
||||
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
||||
|
@ -42,7 +42,7 @@ internal class DefaultPushersService @Inject constructor(
|
|||
@SessionDatabase private val monarchy: Monarchy,
|
||||
@SessionId private val sessionId: String,
|
||||
private val getPusherTask: GetPushersTask,
|
||||
private val sygnalNotifyTask: SygnalNotifyTask,
|
||||
private val pushGatewayNotifyTask: PushGatewayNotifyTask,
|
||||
private val removePusherTask: RemovePusherTask,
|
||||
private val taskExecutor: TaskExecutor
|
||||
) : PushersService {
|
||||
|
@ -52,8 +52,8 @@ internal class DefaultPushersService @Inject constructor(
|
|||
pushkey: String,
|
||||
eventId: String,
|
||||
callback: MatrixCallback<Unit>) {
|
||||
sygnalNotifyTask
|
||||
.configureWith(SygnalNotifyTask.Params(url, appId, pushkey, eventId)) {
|
||||
pushGatewayNotifyTask
|
||||
.configureWith(PushGatewayNotifyTask.Params(url, appId, pushkey, eventId)) {
|
||||
this.callback = callback
|
||||
}
|
||||
.executeBy(taskExecutor)
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.matrix.android.sdk.api.session.pushers.PushersService
|
|||
import org.matrix.android.sdk.internal.session.notification.DefaultProcessEventForPushTask
|
||||
import org.matrix.android.sdk.internal.session.notification.DefaultPushRuleService
|
||||
import org.matrix.android.sdk.internal.session.notification.ProcessEventForPushTask
|
||||
import org.matrix.android.sdk.internal.session.pushers.sygnal.DefaultSygnalNotifyTask
|
||||
import org.matrix.android.sdk.internal.session.pushers.sygnal.SygnalNotifyTask
|
||||
import org.matrix.android.sdk.internal.session.pushers.gateway.DefaultPushGatewayNotifyTask
|
||||
import org.matrix.android.sdk.internal.session.pushers.gateway.PushGatewayNotifyTask
|
||||
import org.matrix.android.sdk.internal.session.room.notification.DefaultSetRoomNotificationStateTask
|
||||
import org.matrix.android.sdk.internal.session.room.notification.SetRoomNotificationStateTask
|
||||
import retrofit2.Retrofit
|
||||
|
@ -90,5 +90,5 @@ internal abstract class PushersModule {
|
|||
abstract fun bindProcessEventForPushTask(task: DefaultProcessEventForPushTask): ProcessEventForPushTask
|
||||
|
||||
@Binds
|
||||
abstract fun bindSygnalNotifyTask(task: DefaultSygnalNotifyTask): SygnalNotifyTask
|
||||
abstract fun bindPushGatewayNotifyTask(task: DefaultPushGatewayNotifyTask): PushGatewayNotifyTask
|
||||
}
|
||||
|
|
|
@ -13,20 +13,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.POST
|
||||
|
||||
internal interface SygnalAPI {
|
||||
internal interface PushGatewayAPI {
|
||||
/**
|
||||
* Ask Sygnal to send a push to the current device.
|
||||
* Ask the Push Gateway to send a push to the current device.
|
||||
*
|
||||
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
|
||||
*/
|
||||
@POST(NetworkConstants.URI_SYGNAL_PREFIX_PATH + "notify")
|
||||
fun notify(@Body body: SygnalNotifyBody): Call<SygnalNotifyResponse>
|
||||
@POST(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH + "notify")
|
||||
fun notify(@Body body: PushGatewayNotifyBody): Call<PushGatewayNotifyResponse>
|
||||
}
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class SygnalDevice(
|
||||
internal data class PushGatewayDevice(
|
||||
/**
|
||||
* Required. The app_id given when the pusher was created.
|
||||
*/
|
|
@ -14,13 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class SygnalNotification(
|
||||
internal data class PushGatewayNotification(
|
||||
@Json(name = "event_id")
|
||||
val eventId: String,
|
||||
|
||||
|
@ -28,5 +28,5 @@ internal data class SygnalNotification(
|
|||
* Required. This is an array of devices that the notification should be sent to.
|
||||
*/
|
||||
@Json(name = "devices")
|
||||
val devices: List<SygnalDevice>
|
||||
val devices: List<PushGatewayDevice>
|
||||
)
|
|
@ -14,16 +14,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class SygnalNotifyBody(
|
||||
internal data class PushGatewayNotifyBody(
|
||||
/**
|
||||
* Required. Information about the push notification
|
||||
*/
|
||||
@Json(name = "notification")
|
||||
val notification: SygnalNotification
|
||||
val notification: PushGatewayNotification
|
||||
)
|
|
@ -14,13 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class SygnalNotifyResponse(
|
||||
internal data class PushGatewayNotifyResponse(
|
||||
@Json(name = "rejected")
|
||||
val rejectedPushKey: List<String>
|
||||
val rejectedPushKeys: List<String>
|
||||
)
|
|
@ -13,10 +13,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.matrix.android.sdk.internal.session.pushers.sygnal
|
||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import org.matrix.android.sdk.api.session.pushers.SygnalFailure
|
||||
import org.matrix.android.sdk.api.session.pushers.PushGatewayFailure
|
||||
import org.matrix.android.sdk.internal.di.Unauthenticated
|
||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||
import org.matrix.android.sdk.internal.network.RetrofitFactory
|
||||
|
@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.network.executeRequest
|
|||
import org.matrix.android.sdk.internal.task.Task
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface SygnalNotifyTask : Task<SygnalNotifyTask.Params, Unit> {
|
||||
internal interface PushGatewayNotifyTask : Task<PushGatewayNotifyTask.Params, Unit> {
|
||||
data class Params(
|
||||
val url: String,
|
||||
val appId: String,
|
||||
|
@ -33,25 +33,25 @@ internal interface SygnalNotifyTask : Task<SygnalNotifyTask.Params, Unit> {
|
|||
)
|
||||
}
|
||||
|
||||
internal class DefaultSygnalNotifyTask @Inject constructor(
|
||||
internal class DefaultPushGatewayNotifyTask @Inject constructor(
|
||||
private val retrofitFactory: RetrofitFactory,
|
||||
@Unauthenticated private val unauthenticatedOkHttpClient: OkHttpClient
|
||||
) : SygnalNotifyTask {
|
||||
) : PushGatewayNotifyTask {
|
||||
|
||||
override suspend fun execute(params: SygnalNotifyTask.Params) {
|
||||
override suspend fun execute(params: PushGatewayNotifyTask.Params) {
|
||||
val sygnalApi = retrofitFactory.create(
|
||||
unauthenticatedOkHttpClient,
|
||||
params.url.substringBefore(NetworkConstants.URI_SYGNAL_PREFIX_PATH)
|
||||
params.url.substringBefore(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH)
|
||||
)
|
||||
.create(SygnalAPI::class.java)
|
||||
.create(PushGatewayAPI::class.java)
|
||||
|
||||
val response = executeRequest<SygnalNotifyResponse>(null) {
|
||||
val response = executeRequest<PushGatewayNotifyResponse>(null) {
|
||||
apiCall = sygnalApi.notify(
|
||||
SygnalNotifyBody(
|
||||
SygnalNotification(
|
||||
PushGatewayNotifyBody(
|
||||
PushGatewayNotification(
|
||||
eventId = params.eventId,
|
||||
devices = listOf(
|
||||
SygnalDevice(
|
||||
PushGatewayDevice(
|
||||
params.appId,
|
||||
params.pushKey
|
||||
)
|
||||
|
@ -61,8 +61,8 @@ internal class DefaultSygnalNotifyTask @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
if (response.rejectedPushKey.contains(params.pushKey)) {
|
||||
throw SygnalFailure.PusherRejected
|
||||
if (response.rejectedPushKeys.contains(params.pushKey)) {
|
||||
throw PushGatewayFailure.PusherRejected
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,13 +23,13 @@ import im.vector.app.core.resources.StringProvider
|
|||
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
||||
import im.vector.app.push.fcm.FcmHelper
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.session.pushers.SygnalFailure
|
||||
import org.matrix.android.sdk.api.session.pushers.PushGatewayFailure
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Test Push by asking Sygnal to send a Push back
|
||||
* Test Push by asking the Push Gateway to send a Push back
|
||||
*/
|
||||
class TestPushFromSygnal @Inject constructor(private val context: AppCompatActivity,
|
||||
class TestPushFromPushGateway @Inject constructor(private val context: AppCompatActivity,
|
||||
private val stringProvider: StringProvider,
|
||||
private val errorFormatter: ErrorFormatter,
|
||||
private val pushersManager: PushersManager)
|
||||
|
@ -42,7 +42,7 @@ class TestPushFromSygnal @Inject constructor(private val context: AppCompatActiv
|
|||
}
|
||||
pushersManager.testPush(fcmToken, object : MatrixCallback<Unit> {
|
||||
override fun onFailure(failure: Throwable) {
|
||||
description = if (failure is SygnalFailure.PusherRejected) {
|
||||
description = if (failure is PushGatewayFailure.PusherRejected) {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_failed)
|
||||
} else {
|
||||
errorFormatter.toHumanReadable(failure)
|
|
@ -23,7 +23,7 @@ import im.vector.app.features.settings.troubleshoot.TestPushRulesSettings
|
|||
import im.vector.app.features.settings.troubleshoot.TestSystemSettings
|
||||
import im.vector.app.gplay.features.settings.troubleshoot.TestFirebaseToken
|
||||
import im.vector.app.gplay.features.settings.troubleshoot.TestPlayServices
|
||||
import im.vector.app.gplay.features.settings.troubleshoot.TestPushFromSygnal
|
||||
import im.vector.app.gplay.features.settings.troubleshoot.TestPushFromPushGateway
|
||||
import im.vector.app.gplay.features.settings.troubleshoot.TestTokenRegistration
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -35,7 +35,7 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
|
|||
private val testPlayServices: TestPlayServices,
|
||||
private val testFirebaseToken: TestFirebaseToken,
|
||||
private val testTokenRegistration: TestTokenRegistration,
|
||||
private val testPushFromSygnal: TestPushFromSygnal
|
||||
private val testPushFromPushGateway: TestPushFromPushGateway
|
||||
) {
|
||||
|
||||
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
|
||||
|
@ -47,7 +47,7 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
|
|||
mgr.addTest(testPlayServices)
|
||||
mgr.addTest(testFirebaseToken)
|
||||
mgr.addTest(testTokenRegistration)
|
||||
mgr.addTest(testPushFromSygnal)
|
||||
mgr.addTest(testPushFromPushGateway)
|
||||
return mgr
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue