Skip to content

Commit

Permalink
Merge pull request #71 from akiomik/new-lexicons
Browse files Browse the repository at this point in the history
Add new lexicons support
  • Loading branch information
akiomik authored Mar 24, 2023
2 parents 3a3f97c + 5501950 commit dc05b4f
Show file tree
Hide file tree
Showing 78 changed files with 455 additions and 496 deletions.
105 changes: 51 additions & 54 deletions app/src/main/java/io/github/akiomik/seiun/api/AtpService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@ import com.squareup.moshi.Moshi
import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import io.github.akiomik.seiun.model.AtpError
import io.github.akiomik.seiun.model.app.bsky.actor.ProfileDetail
import io.github.akiomik.seiun.model.app.bsky.actor.UpdateProfileInput
import io.github.akiomik.seiun.model.app.bsky.actor.UpdateProfileOutput
import io.github.akiomik.seiun.model.app.bsky.blob.UploadBlobOutput
import io.github.akiomik.seiun.model.app.bsky.actor.ProfileView
import io.github.akiomik.seiun.model.app.bsky.feed.AuthorFeed
import io.github.akiomik.seiun.model.app.bsky.feed.Like
import io.github.akiomik.seiun.model.app.bsky.feed.Post
import io.github.akiomik.seiun.model.app.bsky.feed.Repost
import io.github.akiomik.seiun.model.app.bsky.feed.SetVoteInput
import io.github.akiomik.seiun.model.app.bsky.feed.SetVoteOutput
import io.github.akiomik.seiun.model.app.bsky.feed.Timeline
import io.github.akiomik.seiun.model.app.bsky.graph.Follow
import io.github.akiomik.seiun.model.app.bsky.graph.Followers
import io.github.akiomik.seiun.model.app.bsky.graph.Follows
import io.github.akiomik.seiun.model.app.bsky.graph.MuteInput
import io.github.akiomik.seiun.model.app.bsky.graph.UnmuteInput
import io.github.akiomik.seiun.model.app.bsky.graph.MuteActorInput
import io.github.akiomik.seiun.model.app.bsky.graph.UnmuteActorInput
import io.github.akiomik.seiun.model.app.bsky.notification.UpdateNotificationSeenInput
import io.github.akiomik.seiun.model.app.bsky.report.ReportCreateInput
import io.github.akiomik.seiun.model.app.bsky.report.ReportCreateOutput
import io.github.akiomik.seiun.model.com.atproto.account.AccountCreateInput
import io.github.akiomik.seiun.model.com.atproto.account.AccountCreateOutput
import io.github.akiomik.seiun.model.com.atproto.moderation.CreateReportInput
import io.github.akiomik.seiun.model.com.atproto.moderation.CreateReportOutput
import io.github.akiomik.seiun.model.com.atproto.repo.CreateRecordInput
import io.github.akiomik.seiun.model.com.atproto.repo.CreateRecordOutput
import io.github.akiomik.seiun.model.com.atproto.repo.DeleteRecordInput
import io.github.akiomik.seiun.model.com.atproto.session.SessionCreateInput
import io.github.akiomik.seiun.model.com.atproto.session.SessionCreateOutput
import io.github.akiomik.seiun.model.com.atproto.session.SessionRefreshOutput
import io.github.akiomik.seiun.model.com.atproto.repo.UploadBlobOutput
import io.github.akiomik.seiun.model.com.atproto.server.CreateAccountInput
import io.github.akiomik.seiun.model.com.atproto.server.CreateAccountOutput
import io.github.akiomik.seiun.model.com.atproto.server.CreateSessionInput
import io.github.akiomik.seiun.model.com.atproto.server.CreateSessionOutput
import io.github.akiomik.seiun.model.com.atproto.server.RefreshSessionOutput
import okhttp3.OkHttpClient
import okhttp3.RequestBody
import okhttp3.logging.HttpLoggingInterceptor
Expand Down Expand Up @@ -68,53 +65,53 @@ interface AtpService {
}

@DecodeErrorBody
@POST("com.atproto.account.create")
@POST("com.atproto.server.createAccount")
suspend fun createAccount(
@Body body: AccountCreateInput
): ApiResult<AccountCreateOutput, AtpError>
@Body body: CreateAccountInput
): ApiResult<CreateAccountOutput, AtpError>

@DecodeErrorBody
@POST("com.atproto.session.create")
@POST("com.atproto.server.createSession")
suspend fun createSession(
@Body body: SessionCreateInput
): ApiResult<SessionCreateOutput, AtpError>
@Body body: CreateSessionInput
): ApiResult<CreateSessionOutput, AtpError>

@DecodeErrorBody
@POST("com.atproto.session.refresh")
@POST("com.atproto.server.refreshSession")
suspend fun refreshSession(
@Header("Authorization") authorization: String
): ApiResult<SessionRefreshOutput, AtpError>
): ApiResult<RefreshSessionOutput, AtpError>

@DecodeErrorBody
@GET("app.bsky.actor.getProfile")
suspend fun getProfile(
@Header("Authorization") authorization: String,
@Query("actor") actor: String
): ApiResult<ProfileDetail, AtpError>
): ApiResult<ProfileView, AtpError>

@DecodeErrorBody
@POST("app.bsky.actor.updateProfile")
suspend fun updateProfile(
@Header("Authorization") authorization: String,
@Body body: UpdateProfileInput
): ApiResult<UpdateProfileOutput, AtpError>
// @DecodeErrorBody
// @POST("com.atproto.repo.putRecord")
// suspend fun updateProfile(
// @Header("Authorization") authorization: String,
// @Body body: UpdateProfileInput
// ): ApiResult<UpdateProfileOutput, AtpError>

@DecodeErrorBody
@GET("app.bsky.feed.getTimeline")
suspend fun getTimeline(
@Header("Authorization") authorization: String,
@Query("algorithm") algorithm: String? = null,
@Query("limit") limit: Int? = null,
@Query("before") before: String? = null
@Query("cursor") cursor: String? = null
): ApiResult<Timeline, AtpError>

@DecodeErrorBody
@GET("app.bsky.feed.getAuthorFeed")
suspend fun getAuthorFeed(
@Header("Authorization") authorization: String,
@Query("author") author: String,
@Query("actor") actor: String,
@Query("limit") limit: Int? = null,
@Query("before") before: String? = null
@Query("cursor") cursor: String? = null
): ApiResult<AuthorFeed, AtpError>

@DecodeErrorBody
Expand All @@ -139,19 +136,19 @@ interface AtpService {
): ApiResult<Unit, AtpError>

@DecodeErrorBody
@POST("app.bsky.feed.setVote")
suspend fun setVote(
@POST("com.atproto.repo.createRecord")
suspend fun like(
@Header("Authorization") authorization: String,
@Body body: SetVoteInput
): ApiResult<SetVoteOutput, AtpError>
@Body body: CreateRecordInput<Like>
): ApiResult<CreateRecordOutput, AtpError>

@DecodeErrorBody
@GET("app.bsky.notification.list")
@GET("app.bsky.notification.listNotifications")
suspend fun listNotifications(
@Header("Authorization") authorization: String,
@Query("limit") limit: Int? = null,
@Query("before") before: String? = null
): ApiResult<io.github.akiomik.seiun.model.app.bsky.notification.NotificationList, AtpError>
@Query("cursor") cursor: String? = null
): ApiResult<io.github.akiomik.seiun.model.app.bsky.notification.Notifications, AtpError>

@DecodeErrorBody
@POST("app.bsky.notification.updateSeen")
Expand All @@ -161,36 +158,36 @@ interface AtpService {
): ApiResult<Unit, AtpError>

@DecodeErrorBody
@POST("com.atproto.blob.upload")
@POST("com.atproto.repo.uploadBlob")
suspend fun uploadBlob(
@Header("Authorization") authorization: String,
@Header("Content-Type") contentType: String,
@Body body: RequestBody
): ApiResult<UploadBlobOutput, AtpError>

@DecodeErrorBody
@POST("com.atproto.report.create")
@POST("com.atproto.moderation.createReport")
suspend fun createReport(
@Header("Authorization") authorization: String,
@Body body: ReportCreateInput
): ApiResult<ReportCreateOutput, AtpError>
@Body body: CreateReportInput
): ApiResult<CreateReportOutput, AtpError>

@DecodeErrorBody
@GET("app.bsky.graph.getFollows")
suspend fun getFollows(
@Header("Authorization") authorization: String,
@Query("user") user: String,
@Query("actor") actor: String,
@Query("limit") limit: Int? = null,
@Query("before") before: String? = null
@Query("cursor") cursor: String? = null
): ApiResult<Follows, AtpError>

@DecodeErrorBody
@GET("app.bsky.graph.getFollowers")
suspend fun getFollowers(
@Header("Authorization") authorization: String,
@Query("user") user: String,
@Query("actor") actor: String,
@Query("limit") limit: Int? = null,
@Query("before") before: String? = null
@Query("cursor") cursor: String? = null
): ApiResult<Followers, AtpError>

@DecodeErrorBody
Expand All @@ -208,16 +205,16 @@ interface AtpService {
): ApiResult<Unit, AtpError>

@DecodeErrorBody
@POST("app.bsky.graph.mute")
suspend fun mute(
@POST("app.bsky.graph.muteActor")
suspend fun muteActor(
@Header("Authorization") authorization: String,
@Body body: MuteInput
@Body body: MuteActorInput
): ApiResult<Unit, AtpError>

@DecodeErrorBody
@POST("app.bsky.graph.unmute")
suspend fun unmute(
@POST("app.bsky.graph.unmuteActor")
suspend fun unmuteActor(
@Header("Authorization") authorization: String,
@Body body: UnmuteInput
@Body body: UnmuteActorInput
): ApiResult<Unit, AtpError>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.akiomik.seiun.model.app.bsky.actor

import com.squareup.moshi.JsonClass
import io.github.akiomik.seiun.model.type.Image
import io.github.akiomik.seiun.model.type.Blob

@JsonClass(generateAdapter = true)
data class Profile(
val displayName: String,
val displayName: String? = null,
val description: String? = null,
val avatar: Image? = null,
val banner: Image? = null
val avatar: Blob? = null,
val banner: Blob? = null
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package io.github.akiomik.seiun.model.app.bsky.actor

import com.squareup.moshi.JsonClass
import io.github.akiomik.seiun.model.app.bsky.system.DeclRef
import java.util.*

@JsonClass(generateAdapter = true)
data class ProfileDetail(
data class ProfileView(
val did: String,
val declaration: DeclRef,
val handle: String,
val creator: String,
val followersCount: Int,
val followsCount: Int,
val postsCount: Int,
val membersCount: Int? = null,
val displayName: String? = null,
val description: String? = null,
val avatar: String? = null,
val banner: String? = null,
val myState: MyState? = null
val followersCount: Int? = null,
val followsCount: Int? = null,
val postsCount: Int? = null,
val indexedAt: Date? = null,
val viewer: ViewerState? = null
)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.github.akiomik.seiun.model.app.bsky.actor

import com.squareup.moshi.JsonClass
import io.github.akiomik.seiun.model.app.bsky.system.DeclRef

@JsonClass(generateAdapter = true)
data class RefWithInfo(
data class WithInfo(
val did: String,
val declaration: DeclRef,
val handle: String,
val displayName: String? = null,
val avatar: String? = null,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class External(
val external: ExternalExternal?
val external: ExternalExternal
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.akiomik.seiun.model.app.bsky.embed

import com.squareup.moshi.JsonClass
import io.github.akiomik.seiun.model.type.Image as ImageType
import io.github.akiomik.seiun.model.type.Blob

@JsonClass(generateAdapter = true)
data class ExternalExternal(
val uri: String,
val title: String,
val description: String,
val thumb: ImageType
val thumb: Blob? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.github.akiomik.seiun.model.app.bsky.embed
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class PresentedExternal(
data class ExternalViewExternal(
val uri: String,
val title: String,
val description: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.github.akiomik.seiun.model.app.bsky.embed

import com.squareup.moshi.JsonClass
import io.github.akiomik.seiun.model.type.Image as ImageType
import io.github.akiomik.seiun.model.type.Blob

@JsonClass(generateAdapter = true)
data class Image(
val image: ImageType,
data class ImagesImage(
val image: Blob,
val alt: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.github.akiomik.seiun.model.app.bsky.embed
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class PresentedImage(
data class ImagesViewImage(
val thumb: String,
val fullsize: String,
val alt: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class FeedViewPost(
val post: PostView,
val reply: FeedViewPostReplyRef? = null,
val reason: ReasonTrendOrReasonRepost? = null
val reply: ReplyRef? = null,
val reason: ReasonRepost? = null // TODO: union type
) {
fun id(): String = reason?.id()?.let { "${post.cid}-$it" } ?: post.cid
}
Loading

0 comments on commit dc05b4f

Please sign in to comment.