forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Api.scala
25 lines (18 loc) · 680 Bytes
/
Api.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package lila
package notification
import user.User
import socket.MetaHub
import collection.mutable
final class Api(metaHub: MetaHub) {
private val repo = mutable.Map[String, List[Notification]]()
def add(user: User, html: String, from: Option[User] = None) {
val notification = Notification(user, html, from)
repo.update(user.id, notification :: get(user))
metaHub.addNotification(user.id, views.html.notification.view(notification).toString)
}
def get(user: User): List[Notification] = ~(repo get user.id)
def remove(user: User, id: String) {
repo.update(user.id, get(user) filter (_.id != id))
metaHub.removeNotification(user.id, id)
}
}