Last active
May 4, 2016 20:39
-
-
Save ryanpbrewster/8cd1998152ca881c93c82d1769e88621 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generateNotifications(activity: Seq[Event]): Seq[BatchFetchable[String]] = { | |
| activity.map { | |
| case NewPost(userId, groupId, postId) => BatchFetchable[String]( | |
| keys = Keys(Set(userId), Set(groupId), Set(postId), Set()), | |
| entities => | |
| val user = entities.users(userId) | |
| val group = entities.groups(groupId) | |
| val post = entities.posts(postId) | |
| s"${user.fullName} shared ${post.title} with ${group.name}" | |
| ) | |
| case DirectMessage(fromId, toId, msgId) => BatchFetchable[String]( | |
| keys = Keys(Set(fromId, toId), Set(), Set(), Set(msgId)), | |
| entities => | |
| val (from, to) = (entities.users(fromId), entities.users(toId)) | |
| val msg = entities.msgs(msgId) | |
| s"${from.fullName} said ${msg.text} to ${to.fullName}" | |
| ) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment