aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/kotlin/jp/rhe/snag/server/Event.kt
blob: bc42c559abe56f43afd0916e6123f9e90613bea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package jp.rhe.snag.server

data class Event(val type: EventType, val content: String) {
    val id = idBase++

    companion object {
        // The number of events must be less than 2^16 per seconds
        private var idBase = (System.currentTimeMillis() / 1000L) shl 16
    }
}

enum class EventType(private val jsonName: String) {
    HomeTimelineTweet("tweet"),
    MentionsTimelineTweet("tweet"),
    WebhookEvent("webhook_event"),
    System("system"),
    BackfillStart("backfill_start"),
    BackfillFinish("backfill_finish"),
    ;

    override fun toString() = jsonName
}