Skip to content

Commit

Permalink
checking notification apis.
Browse files Browse the repository at this point in the history
  • Loading branch information
uakihir0 committed Jan 3, 2024
1 parent c4b8d93 commit ecfefb5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import kotlinx.serialization.Serializable

@Serializable
class NotificationGetUnreadCountResponse {
var count: Int? = null
var count: Int = -1
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import work.socialhub.kbsky.model.bsky.notification.NotificationListNotification
@Serializable
class NotificationListNotificationsResponse {
var cursor: String? = null
var notifications: List<NotificationListNotificationsNotification>? = null
lateinit var notifications: List<NotificationListNotificationsNotification>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package work.socialhub.kbsky.api.entity.bsky.notification

import kotlinx.datetime.Clock
import work.socialhub.kbsky.api.entity.share.AuthRequest
import work.socialhub.kbsky.api.entity.share.MapRequest
import work.socialhub.kbsky.internal.share._InternalUtility

class NotificationUpdateSeenRequest internal constructor(
accessJwt: String
Expand All @@ -11,11 +13,11 @@ class NotificationUpdateSeenRequest internal constructor(

override fun toMap(): Map<String, Any> {
return mutableMapOf<String, Any>().also {
it.addParam("seenAt", seenAt)
it.addParam("seenAt", seenAt())
}
}

fun seenAt(): String {
return seenAt ?: TODO("seenAt is not set")
return seenAt ?: _InternalUtility.dateFormat.format(Clock.System.now())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import kotlinx.serialization.Serializable
import work.socialhub.kbsky.internal.share._InternalUtility.fromJson
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.properties.Delegates

open class AuthRequest(
val accessJwt: String
Expand All @@ -29,8 +28,8 @@ open class AuthRequest(
lateinit var scope: String
lateinit var sub: String
lateinit var aud: String
var iat by Delegates.notNull<Int>()
var exp by Delegates.notNull<Int>()
var iat: Int = -1
var exp: Int = -1
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package work.socialhub.kbsky.model.bsky.actor

import kotlinx.serialization.Serializable
import work.socialhub.kbsky.BlueskyTypes
import kotlin.properties.Delegates.notNull

@Serializable
class ActorDefsAdultContentPref : ActorDefsPreferencesUnion() {
Expand All @@ -13,5 +12,5 @@ class ActorDefsAdultContentPref : ActorDefsPreferencesUnion() {

override var type = TYPE

var enabled by notNull<Boolean>()
var enabled: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import work.socialhub.kbsky.model.share.RecordUnion

@Serializable
class NotificationListNotificationsNotification {
var uri: String? = null
var cid: String? = null
var author: ActorDefsProfileView? = null
lateinit var uri: String
lateinit var cid: String
lateinit var author: ActorDefsProfileView

/**
* Expected values are 'like', 'repost', 'follow
* (like, repost, follow, mention, reply, quote)
*/
var reason: String? = null
lateinit var reason: String
var reasonSubject: String? = null
var record: RecordUnion? = null
var isRead: Boolean? = null
var indexedAt: String? = null

lateinit var record: RecordUnion
var isRead: Boolean = false
lateinit var indexedAt: String

// TODO: labels
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ class ListNotificationsTest : AbstractTest() {
NotificationListNotificationsRequest(accessJwt)
)

checkNotNull(response.data.notifications)
.forEach { it ->
println("|NOTIFICATION|-----------------------------------------")
println("REASON> " + it.reason)
print(it.record)
}
response.data.notifications.forEach {
println("|NOTIFICATION|-----------------------------------------")
println("REASON> " + it.reason)
print(it.record)
}
}
}

0 comments on commit ecfefb5

Please sign in to comment.