Skip to content

Instantly share code, notes, and snippets.

@slorber
Last active June 14, 2016 09:37
Show Gist options
  • Save slorber/4cf8a84e5f761a86e31da38ef2a5f12a to your computer and use it in GitHub Desktop.
Save slorber/4cf8a84e5f761a86e31da38ef2a5f12a to your computer and use it in GitHub Desktop.
pushnotification.title=Stample
pushnotification.relationship.created={0} souhaite vous ajouter à ses contacts
pushnotification.relationship.accepted={0} a accepté votre demande de contact
pushnotification.addedToLibraryMembers={0} a partagé la bibliothèque {1} avec vous
pushnotification.addedToGroupMembers={0} vous a ajouté à l''équipe {1}
pushnotification.stample.liked={0} a aimé votre stample {1} dans {2}
pushnotification.stample.commented={0} a commenté {1}
pushnotification.stample.mentionned={0} vous a mentionné dans un commentaire sur le stample {1}
pushnotification.stample.created={0} a ajouté un stample dans votre bibliothèque {1}
pushnotification.library.followed={0} à suivi votre bibliothèque publique {1}
pushnotification.stample.reminder=Rappel: {0}
pushnotification.library.publish={0} a publié la bibliothèque {1}
pushnotification.title=Stample
pushnotification.relationship.created={0} wants to connect with you on stample
pushnotification.relationship.accepted={0} accepted your invitation to connect
pushnotification.addedToLibraryMembers={0} shared the library {1} with you
pushnotification.addedToGroupMembers={0} added you to {1}
pushnotification.stample.liked={0} liked your stample {1} in {2}
pushnotification.stample.commented={0} commented the stample {1}
pushnotification.stample.mentionned={0} mentionned you in a comment in stample {1}
pushnotification.stample.created={0} added a stample in the library {1}
pushnotification.library.followed={0} followed your public library {1}
pushnotification.stample.reminder=Reminder: {0}
pushnotification.library.publish={0} published the library {1}
override def sendTitleWithMessage(toUser: User, title: String, message: String,devices: Option[Set[MobileDevice]] = None): Unit = {
push(toUser, PushMessage(title, message, PayloadType.SIMPLE_MESSAGE),devices)
}
override def createdRelationshipPush(fromUser: User, toUser: User): Unit = {
push(toUser, PushMessage(
Messages("pushnotification.title")(lang(toUser)),
Messages("pushnotification.relationship.created", fromUser.fullname)(lang(toUser)),
PayloadType.CREATED_RELATIONSHIP,
Map("url" -> FrontendController.makeUrl(fromUser))
))
}
override def addedToLibraryMembersPush(fromUser: User, library: Library, toUsers: List[User]): Unit = {
toUsers.foreach((user: User) => {
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.addedToLibraryMembers", fromUser.fullname, library.name)(lang(user)),
PayloadType.SHARED_LIBRARY,
Map("url" -> FrontendController.makeUrl(library))
))
})
}
override def likedStamplePush(fromUser: User, stample: Stample): Unit = {
val library = libraryService.getLibrary(stample)
val toUser: User = stample.creatorId.toUser
push(toUser, PushMessage(
Messages("pushnotification.title")(lang(toUser)),
Messages("pushnotification.stample.liked", fromUser.fullname, stample.title.getOrDefault("untitled"), library.name)(lang(toUser)),
PayloadType.LIKED_STAMPLE,
Map("url" -> FrontendController.makeUrl(stample))
))
}
override def createdStamplePush(fromUser: User, stample: Stample): Unit = {
val library = libraryService.getLibrary(stample)
val toUsers = getLibraryMembersToNotify(fromUser,library)
toUsers.foreach((user: User) => {
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.stample.created", fromUser.fullname, library.name)(lang(user)),
PayloadType.CREATED_STAMPLE,
Map("url" -> FrontendController.makeUrl(stample))
))
})
}
override def addedToGroupMembersPush(fromUser: User, toUsers: List[User], community: Community): Unit = {
toUsers.foreach((user: User) => {
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.addedToGroupMembers", fromUser.fullname, community.name)(lang(user)),
PayloadType.ADDED_TO_TEAM,
Map("url" -> FrontendController.makeUrl(community))))
})
}
override def libraryFollowedPush(fromUser: User, library: Library): Unit = {
val toUser: User = library.userId.toUser
push(toUser, PushMessage(
Messages("pushnotification.title")(lang(toUser)),
Messages("pushnotification.library.followed", fromUser.fullname, library.name)(lang(toUser)),
PayloadType.FOLLOWED_LIBRARY,
Map("url" -> FrontendController.makeUrl(library))
))
}
override def commentOnStamplePush(fromUser: User, stample: Stample, commentContent: CommentContent): Unit = {
val mentionedUsers = commentContent.mentionedUserIds.toList.toUsers
.filterNot(is(fromUser))
mentionedUsers.foreach((user: User) => {
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.stample.mentionned", fromUser.fullname, stample.title.getOrDefault("untitled"))(lang(user)),
PayloadType.MENTION_ON_COMMENT,
Map("url" -> FrontendController.makeUrl(stample))
))
})
val notMentionnedStampleFollowers = stampleService.getStampleFollowers(stample)
.filterNot(is(fromUser))
.filterNot(u => mentionedUsers.contains(u))
notMentionnedStampleFollowers.foreach((user: User) => {
val userLang: Lang = lang(user)
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.stample.commented", fromUser.fullname, stample.title.getOrDefault("untitled"))(lang(user)),
PayloadType.COMMENT_ON_STAMPLE,
Map("url" -> FrontendController.makeUrl(stample))
))
})
}
override def movedStamplePush(fromUser: User, stample: Stample): Unit = {
val library = libraryService.getLibrary(stample)
val toUsers = getLibraryMembersToNotify(fromUser,library)
toUsers.foreach((user: User) => {
push(user, PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.stample.created", fromUser.fullname, library.name)(lang(user)),
PayloadType.MOVED_STAMPLE,
Map("url" -> FrontendController.makeUrl(stample))
))
})
}
override def acceptedRelationshipPush(fromUser: User, toUser: User): Unit = {
push(toUser, PushMessage(
Messages("pushnotification.title")(lang(toUser)),
Messages("pushnotification.relationship.accepted", fromUser.fullname)(lang(toUser)),
PayloadType.ACCEPTED_RELATIONSHIP,
Map("url" -> FrontendController.makeUrl(fromUser))
))
}
override def stampleRemindPush(toUser: User, stample: Stample): Unit = {
push(toUser,PushMessage(
Messages("pushnotification.title")(lang(toUser)),
Messages("pushnotification.stample.reminder",stample.title.getOrDefault("untitled")),
PayloadType.STAMPLE_REMINDER,
Map("url" -> FrontendController.makeUrl(stample))
))
}
override def publishLibraryPush(fromUser: User, library: Library): Unit = {
val toUsers = relationshipService.getActiveRelationUsers(fromUser)
toUsers.foreach((user: User) => {
push(user,PushMessage(
Messages("pushnotification.title")(lang(user)),
Messages("pushnotification.library.publish",fromUser.fullname,library.name),
PayloadType.PUBLISH_LIBRARY,
Map("url" -> FrontendController.makeUrl(library))
))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment