remove onesignal push
parent
f61de99a64
commit
edcf1e0aa3
|
@ -101,7 +101,7 @@ Lichess as deployed on https://lichess.org/ also uses these external services:
|
|||
- [check.torproject.org](https://check.torproject.org/exit-addresses) for a list or Tor exit nodes
|
||||
- [detectlanguage.com](https://detectlanguage.com/)
|
||||
- Fallback to [Google Fonts](https://fonts.google.com/)
|
||||
- [Google Cloud Messaging](https://developers.google.com/cloud-messaging/) and [OneSignal](https://onesignal.com/) for mobile notifications
|
||||
- [Google Cloud Messaging](https://developers.google.com/cloud-messaging/) for mobile notifications
|
||||
- [reCAPTCHA](https://www.google.com/recaptcha/)
|
||||
- [PeerJS](https://peerjs.com/) for voice chat
|
||||
- [crowdin](https://crowdin.com/project/lichess) for localization
|
||||
|
|
|
@ -256,11 +256,6 @@ push {
|
|||
vapid_public_key = "BGr5CL0QlEYa7qW7HLqe7DFkCeTsYMLsi1Db+5Vwt1QBIs6+WxN8066AjtP8S9u+w+CbleE8xWY+qQaNEMs7sAs="
|
||||
url = "http://push.lichess.ovh:9054"
|
||||
}
|
||||
onesignal {
|
||||
url = "https://onesignal.com/api/v1/notifications"
|
||||
app_id = ""
|
||||
key = ""
|
||||
}
|
||||
firebase {
|
||||
url = "https://fcm.googleapis.com/v1/projects/lichess-1366/messages:send"
|
||||
json = ""
|
||||
|
|
|
@ -3,7 +3,7 @@ package lila.push
|
|||
import org.joda.time.DateTime
|
||||
|
||||
final private case class Device(
|
||||
_id: String, // Firebase token or OneSignal playerId
|
||||
_id: String, // Firebase token
|
||||
platform: String, // cordova platform (android, ios, firebase)
|
||||
userId: String,
|
||||
seenAt: DateTime
|
||||
|
|
|
@ -16,7 +16,6 @@ final private class PushConfig(
|
|||
@ConfigName("collection.device") val deviceColl: CollName,
|
||||
@ConfigName("collection.subscription") val subscriptionColl: CollName,
|
||||
val web: WebPush.Config,
|
||||
val onesignal: OneSignalPush.Config,
|
||||
val firebase: FirebasePush.Config
|
||||
)
|
||||
|
||||
|
@ -42,8 +41,6 @@ final class Env(
|
|||
def registerDevice = deviceApi.register _
|
||||
def unregisterDevices = deviceApi.unregister _
|
||||
|
||||
private lazy val oneSignalPush = wire[OneSignalPush]
|
||||
|
||||
private lazy val googleCredentials: Option[GoogleCredentials] =
|
||||
try {
|
||||
config.firebase.json.value.some.filter(_.nonEmpty).map { json =>
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
package lila.push
|
||||
|
||||
import io.methvin.play.autoconfig._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.ws._
|
||||
import play.api.libs.ws.JsonBodyReadables._
|
||||
import play.api.libs.ws.JsonBodyWritables._
|
||||
|
||||
final private class OneSignalPush(
|
||||
deviceApi: DeviceApi,
|
||||
ws: StandaloneWSClient,
|
||||
config: OneSignalPush.Config
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
import config._
|
||||
|
||||
def apply(userId: String, data: => PushApi.Data): Funit =
|
||||
deviceApi.findLastManyByUserId("onesignal", 3)(userId) flatMap {
|
||||
case Nil => funit
|
||||
case devices =>
|
||||
ws.url(config.url)
|
||||
.withHttpHeaders(
|
||||
"Authorization" -> s"key=${key.value}",
|
||||
"Accept" -> "application/json",
|
||||
"Content-type" -> "application/json"
|
||||
)
|
||||
.post(
|
||||
Json.obj(
|
||||
"app_id" -> appId,
|
||||
"include_player_ids" -> devices.map(_.deviceId),
|
||||
"headings" -> Map("en" -> data.title),
|
||||
"contents" -> Map("en" -> data.body),
|
||||
"data" -> data.payload,
|
||||
"android_group" -> data.stacking.key,
|
||||
"android_group_message" -> Map("en" -> data.stacking.message),
|
||||
"collapse_id" -> data.stacking.key,
|
||||
"ios_badgeType" -> "Increase",
|
||||
"ios_badgeCount" -> 1
|
||||
)
|
||||
)
|
||||
.flatMap {
|
||||
case res if res.status == 200 || res.status == 400 =>
|
||||
readErrors(res)
|
||||
.filterNot(_ contains "must have English language")
|
||||
.filterNot(_ contains "All included players are not subscribed") match {
|
||||
case Nil => funit
|
||||
case errors =>
|
||||
fufail(s"[push] ${devices.map(_.deviceId)} $data ${res.status} ${errors mkString ","}")
|
||||
}
|
||||
case res =>
|
||||
fufail(s"[push] ${devices.map(_.deviceId)} $data ${lila.log.http(res.status, res.body)}")
|
||||
}
|
||||
}
|
||||
|
||||
private def readErrors(res: StandaloneWSResponse): List[String] =
|
||||
~(res.body[JsValue] \ "errors").asOpt[List[String]]
|
||||
}
|
||||
|
||||
private object OneSignalPush {
|
||||
|
||||
final class Config(
|
||||
val url: String,
|
||||
@ConfigName("app_id") val appId: String,
|
||||
val key: lila.common.config.Secret
|
||||
)
|
||||
implicit val configLoader = AutoConfig.loader[Config]
|
||||
}
|
|
@ -13,7 +13,6 @@ import lila.user.User
|
|||
|
||||
final private class PushApi(
|
||||
firebasePush: FirebasePush,
|
||||
oneSignalPush: OneSignalPush,
|
||||
webPush: WebPush,
|
||||
userRepo: lila.user.UserRepo,
|
||||
implicit val lightUser: LightUser.Getter,
|
||||
|
@ -257,9 +256,6 @@ final private class PushApi(
|
|||
webPush(userId, data).addEffects { res =>
|
||||
monitor(lila.mon.push.send)("web", res.isSuccess)
|
||||
} zip
|
||||
oneSignalPush(userId, data).addEffects { res =>
|
||||
monitor(lila.mon.push.send)("onesignal", res.isSuccess)
|
||||
} zip
|
||||
firebasePush(userId, data).addEffects { res =>
|
||||
monitor(lila.mon.push.send)("firebase", res.isSuccess)
|
||||
} void
|
||||
|
|
Loading…
Reference in New Issue