stage3: add inbox/search/comment methods
This commit is contained in:
8 files changed
+469
-203
No files matched your search
@@ -2,7 +2,7 @@ import type { ClientType } from './lemmy.svelte'
|
|||||||
import * as types from './types'
|
import * as types from './types'
|
||||||
|
|
||||||
export abstract class BaseClient {
|
export abstract class BaseClient {
|
||||||
static type: ClientType
|
abstract type: ClientType
|
||||||
|
|
||||||
abstract getSite(): Promise<types.GetSiteResponse>
|
abstract getSite(): Promise<types.GetSiteResponse>
|
||||||
abstract generateTotpSecret(): Promise<types.GenerateTotpSecretResponse>
|
abstract generateTotpSecret(): Promise<types.GenerateTotpSecretResponse>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { LemmyHttp } from 'lemmy-js-client'
|
import { LemmyHttp } from 'lemmy-js-client'
|
||||||
import type { BaseClient } from '../base'
|
import type { BaseClient } from '../base'
|
||||||
import { fromGetPosts, toListingType } from './rewrite'
|
import { fromGetPosts, toListingType } from './rewrite'
|
||||||
|
import type { ClientType } from '../lemmy.svelte'
|
||||||
|
|
||||||
export class LemmyClient implements BaseClient {
|
export class LemmyClient implements BaseClient {
|
||||||
static type = { name: 'lemmy', baseUrl: '/api/v3' }
|
type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' }
|
||||||
|
|
||||||
#client: LemmyHttp
|
#client: LemmyHttp
|
||||||
|
|
||||||
|
|||||||
+346
-193
@@ -1,22 +1,32 @@
|
|||||||
import createClient from 'openapi-fetch'
|
import createClient from 'openapi-fetch'
|
||||||
import type { BaseClient } from '../base'
|
import type { BaseClient } from '../base'
|
||||||
import {
|
import {
|
||||||
|
fromCreateComment,
|
||||||
|
fromCreatePost,
|
||||||
fromGetComments,
|
fromGetComments,
|
||||||
fromGetPost,
|
fromGetPost,
|
||||||
fromGetPosts,
|
fromGetPosts,
|
||||||
|
fromGetReplies,
|
||||||
|
fromListCommunities,
|
||||||
|
fromSearch,
|
||||||
|
toCommentReplyView,
|
||||||
|
toCommentSortType,
|
||||||
toCommentView,
|
toCommentView,
|
||||||
toCommunity,
|
toCommunity,
|
||||||
toCommunityView,
|
toCommunityView,
|
||||||
toLocalSite,
|
toLocalSite,
|
||||||
toMyUser,
|
toMyUser,
|
||||||
toPerson,
|
toPerson,
|
||||||
|
toPersonMentionView,
|
||||||
toPersonView,
|
toPersonView,
|
||||||
toPostView,
|
toPostView,
|
||||||
|
toPrivateMessageView,
|
||||||
} from './rewrite'
|
} from './rewrite'
|
||||||
import type { paths } from './schema'
|
import type { paths } from './schema'
|
||||||
|
import type { ClientType } from '../lemmy.svelte'
|
||||||
|
|
||||||
export class PiefedClient implements BaseClient {
|
export class PiefedClient implements BaseClient {
|
||||||
static type = { name: 'piefed', baseUrl: '/api/alpha' }
|
type: ClientType = { name: 'piefed', baseUrl: '/api/alpha' }
|
||||||
|
|
||||||
#client: ReturnType<typeof createClient<paths>>
|
#client: ReturnType<typeof createClient<paths>>
|
||||||
|
|
||||||
@@ -36,7 +46,7 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSite(): ReturnType<BaseClient['getSite']> {
|
async getSite(): ReturnType<BaseClient['getSite']> {
|
||||||
// throw new Error('Unimplemented')
|
// throw new Error('unimplemented')
|
||||||
|
|
||||||
const response = (await this.#client.GET('/site')).data!
|
const response = (await this.#client.GET('/site')).data!
|
||||||
|
|
||||||
@@ -73,9 +83,17 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createPost(
|
async createPost(
|
||||||
...params: Parameters<BaseClient['createPost']>
|
params: Parameters<BaseClient['createPost']>[0],
|
||||||
): ReturnType<BaseClient['createPost']> {
|
): ReturnType<BaseClient['createPost']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/post', {
|
||||||
|
body: fromCreatePost(params),
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async getPost(
|
async getPost(
|
||||||
params: Parameters<BaseClient['getPost']>[0],
|
params: Parameters<BaseClient['getPost']>[0],
|
||||||
@@ -97,20 +115,36 @@ export class PiefedClient implements BaseClient {
|
|||||||
post_view: toPostView(response.post_view),
|
post_view: toPostView(response.post_view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async editPost(
|
async editPost(
|
||||||
...params: Parameters<BaseClient['editPost']>
|
params: Parameters<BaseClient['editPost']>[0],
|
||||||
): ReturnType<BaseClient['editPost']> {
|
): ReturnType<BaseClient['editPost']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.PUT('/post', { body: params })).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async deletePost(
|
async deletePost(
|
||||||
...params: Parameters<BaseClient['deletePost']>
|
params: Parameters<BaseClient['deletePost']>[0],
|
||||||
): ReturnType<BaseClient['deletePost']> {
|
): ReturnType<BaseClient['deletePost']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.POST('/post/delete', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async removePost(
|
async removePost(
|
||||||
...params: Parameters<BaseClient['removePost']>
|
params: Parameters<BaseClient['removePost']>[0],
|
||||||
): ReturnType<BaseClient['removePost']> {
|
): ReturnType<BaseClient['removePost']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.POST('/post/remove', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPosts(
|
async getPosts(
|
||||||
@@ -137,95 +171,155 @@ export class PiefedClient implements BaseClient {
|
|||||||
})) as any
|
})) as any
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateTotpSecret(
|
async generateTotpSecret(): ReturnType<BaseClient['generateTotpSecret']> {
|
||||||
...params: Parameters<BaseClient['generateTotpSecret']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['generateTotpSecret']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async listLogins(
|
async listLogins(): ReturnType<BaseClient['listLogins']> {
|
||||||
...params: Parameters<BaseClient['listLogins']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['listLogins']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async listAllMedia(
|
async listAllMedia(): ReturnType<BaseClient['listAllMedia']> {
|
||||||
...params: Parameters<BaseClient['listAllMedia']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['listAllMedia']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async updateTotp(
|
async updateTotp(): ReturnType<BaseClient['updateTotp']> {
|
||||||
...params: Parameters<BaseClient['updateTotp']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['updateTotp']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getModlog(
|
async getModlog(): ReturnType<BaseClient['getModlog']> {
|
||||||
...params: Parameters<BaseClient['getModlog']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['getModlog']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async search(
|
async search(
|
||||||
...params: Parameters<BaseClient['search']>
|
params: Parameters<BaseClient['search']>[0],
|
||||||
): ReturnType<BaseClient['search']> {
|
): ReturnType<BaseClient['search']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/search', {
|
||||||
|
params: {
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
query: fromSearch(params),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comments: [],
|
||||||
|
communities: response.communities.map(toCommunityView),
|
||||||
|
posts: response.posts.map(toPostView),
|
||||||
|
users: response.users.map(toPersonView),
|
||||||
|
type_: response.type_,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async resolveObject(
|
async resolveObject(
|
||||||
...params: Parameters<BaseClient['resolveObject']>
|
params: Parameters<BaseClient['resolveObject']>[0],
|
||||||
): ReturnType<BaseClient['resolveObject']> {
|
): ReturnType<BaseClient['resolveObject']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/resolve_object', {
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
params: { query: params },
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comment: response.comment ? toCommentView(response.comment) : undefined,
|
||||||
|
community: response.community
|
||||||
|
? toCommunityView(response.community)
|
||||||
|
: undefined,
|
||||||
|
post: response.post ? toPostView(response.post) : undefined,
|
||||||
|
person: response.person ? toPersonView(response.person) : undefined,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async createCommunity(
|
async createCommunity(
|
||||||
...params: Parameters<BaseClient['createCommunity']>
|
...params: Parameters<BaseClient['createCommunity']>
|
||||||
): ReturnType<BaseClient['createCommunity']> {
|
): ReturnType<BaseClient['createCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getCommunity(
|
async getCommunity(
|
||||||
...params: Parameters<BaseClient['getCommunity']>
|
params: Parameters<BaseClient['getCommunity']>[0],
|
||||||
): ReturnType<BaseClient['getCommunity']> {
|
): ReturnType<BaseClient['getCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/community', {
|
||||||
|
params: {
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
query: params,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
community_view: toCommunityView(response.community_view),
|
||||||
|
moderators: response.moderators.map(i => ({
|
||||||
|
community: toCommunity(i.community),
|
||||||
|
moderator: toPerson(i.moderator),
|
||||||
|
})),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async editCommunity(
|
async editCommunity(
|
||||||
...params: Parameters<BaseClient['editCommunity']>
|
...params: Parameters<BaseClient['editCommunity']>
|
||||||
): ReturnType<BaseClient['editCommunity']> {
|
): ReturnType<BaseClient['editCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async listCommunities(
|
async listCommunities(
|
||||||
...params: Parameters<BaseClient['listCommunities']>
|
params: Parameters<BaseClient['listCommunities']>[0],
|
||||||
): ReturnType<BaseClient['listCommunities']> {
|
): ReturnType<BaseClient['listCommunities']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/community/list', {
|
||||||
|
params: {
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
query: fromListCommunities(params),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
communities: response.communities.map(toCommunityView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async followCommunity(
|
async followCommunity(
|
||||||
...params: Parameters<BaseClient['followCommunity']>
|
params: Parameters<BaseClient['followCommunity']>[0],
|
||||||
): ReturnType<BaseClient['followCommunity']> {
|
): ReturnType<BaseClient['followCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/community/follow', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
community_view: toCommunityView(response.community_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async blockCommunity(
|
async blockCommunity(
|
||||||
...params: Parameters<BaseClient['blockCommunity']>
|
params: Parameters<BaseClient['blockCommunity']>[0],
|
||||||
): ReturnType<BaseClient['blockCommunity']> {
|
): ReturnType<BaseClient['blockCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/community/block', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
community_view: toCommunityView(response.community_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async deleteCommunity(
|
async deleteCommunity(
|
||||||
...params: Parameters<BaseClient['deleteCommunity']>
|
...params: Parameters<BaseClient['deleteCommunity']>
|
||||||
): ReturnType<BaseClient['deleteCommunity']> {
|
): ReturnType<BaseClient['deleteCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async hideCommunity(
|
async hideCommunity(
|
||||||
...params: Parameters<BaseClient['hideCommunity']>
|
...params: Parameters<BaseClient['hideCommunity']>
|
||||||
): ReturnType<BaseClient['hideCommunity']> {
|
): ReturnType<BaseClient['hideCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async removeCommunity(
|
async removeCommunity(
|
||||||
...params: Parameters<BaseClient['removeCommunity']>
|
...params: Parameters<BaseClient['removeCommunity']>
|
||||||
): ReturnType<BaseClient['removeCommunity']> {
|
): ReturnType<BaseClient['removeCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async banFromCommunity(
|
async banFromCommunity(
|
||||||
...params: Parameters<BaseClient['banFromCommunity']>
|
...params: Parameters<BaseClient['banFromCommunity']>
|
||||||
): ReturnType<BaseClient['banFromCommunity']> {
|
): ReturnType<BaseClient['banFromCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async addModToCommunity(
|
async addModToCommunity(
|
||||||
...params: Parameters<BaseClient['addModToCommunity']>
|
...params: Parameters<BaseClient['addModToCommunity']>
|
||||||
): ReturnType<BaseClient['addModToCommunity']> {
|
): ReturnType<BaseClient['addModToCommunity']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async markPostAsRead(
|
async markPostAsRead(
|
||||||
params: Parameters<BaseClient['markPostAsRead']>[0],
|
params: Parameters<BaseClient['markPostAsRead']>[0],
|
||||||
@@ -240,95 +334,128 @@ export class PiefedClient implements BaseClient {
|
|||||||
async hidePost(
|
async hidePost(
|
||||||
...params: Parameters<BaseClient['hidePost']>
|
...params: Parameters<BaseClient['hidePost']>
|
||||||
): ReturnType<BaseClient['hidePost']> {
|
): ReturnType<BaseClient['hidePost']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async lockPost(
|
async lockPost(
|
||||||
...params: Parameters<BaseClient['lockPost']>
|
...params: Parameters<BaseClient['lockPost']>
|
||||||
): ReturnType<BaseClient['lockPost']> {
|
): ReturnType<BaseClient['lockPost']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async featurePost(
|
async featurePost(
|
||||||
...params: Parameters<BaseClient['featurePost']>
|
...params: Parameters<BaseClient['featurePost']>
|
||||||
): ReturnType<BaseClient['featurePost']> {
|
): ReturnType<BaseClient['featurePost']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async listPostLikes(
|
async listPostLikes(): ReturnType<BaseClient['listPostLikes']> {
|
||||||
...params: Parameters<BaseClient['listPostLikes']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['listPostLikes']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async savePost(
|
async savePost(
|
||||||
...params: Parameters<BaseClient['savePost']>
|
params: Parameters<BaseClient['savePost']>[0],
|
||||||
): ReturnType<BaseClient['savePost']> {
|
): ReturnType<BaseClient['savePost']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.PUT('/post/save', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async createPostReport(
|
async createPostReport(
|
||||||
...params: Parameters<BaseClient['createPostReport']>
|
...params: Parameters<BaseClient['createPostReport']>
|
||||||
): ReturnType<BaseClient['createPostReport']> {
|
): ReturnType<BaseClient['createPostReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async resolvePostReport(
|
async resolvePostReport(
|
||||||
...params: Parameters<BaseClient['resolvePostReport']>
|
...params: Parameters<BaseClient['resolvePostReport']>
|
||||||
): ReturnType<BaseClient['resolvePostReport']> {
|
): ReturnType<BaseClient['resolvePostReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async listPostReports(
|
async listPostReports(
|
||||||
...params: Parameters<BaseClient['listPostReports']>
|
...params: Parameters<BaseClient['listPostReports']>
|
||||||
): ReturnType<BaseClient['listPostReports']> {
|
): ReturnType<BaseClient['listPostReports']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getSiteMetadata(
|
async getSiteMetadata(
|
||||||
...params: Parameters<BaseClient['getSiteMetadata']>
|
...params: Parameters<BaseClient['getSiteMetadata']>
|
||||||
): ReturnType<BaseClient['getSiteMetadata']> {
|
): ReturnType<BaseClient['getSiteMetadata']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
|
|
||||||
async createComment(
|
async createComment(
|
||||||
...params: Parameters<BaseClient['createComment']>
|
params: Parameters<BaseClient['createComment']>[0],
|
||||||
): ReturnType<BaseClient['createComment']> {
|
): ReturnType<BaseClient['createComment']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/comment', {
|
||||||
|
body: fromCreateComment(params),
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async editComment(
|
async editComment(
|
||||||
...params: Parameters<BaseClient['editComment']>
|
params: Parameters<BaseClient['editComment']>[0],
|
||||||
): ReturnType<BaseClient['editComment']> {
|
): ReturnType<BaseClient['editComment']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.PUT('/comment', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async deleteComment(
|
async deleteComment(
|
||||||
...params: Parameters<BaseClient['deleteComment']>
|
params: Parameters<BaseClient['deleteComment']>[0],
|
||||||
): ReturnType<BaseClient['deleteComment']> {
|
): ReturnType<BaseClient['deleteComment']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/comment/delete', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async removeComment(
|
async removeComment(
|
||||||
...params: Parameters<BaseClient['removeComment']>
|
params: Parameters<BaseClient['removeComment']>[0],
|
||||||
): ReturnType<BaseClient['removeComment']> {
|
): ReturnType<BaseClient['removeComment']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/comment/remove', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async markCommentReplyAsRead(
|
async markCommentReplyAsRead(
|
||||||
...params: Parameters<BaseClient['markCommentReplyAsRead']>
|
...params: Parameters<BaseClient['markCommentReplyAsRead']>
|
||||||
): ReturnType<BaseClient['markCommentReplyAsRead']> {
|
): ReturnType<BaseClient['markCommentReplyAsRead']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async likeComment(
|
async likeComment(
|
||||||
params: Parameters<BaseClient['likeComment']>[0],
|
params: Parameters<BaseClient['likeComment']>[0],
|
||||||
): ReturnType<BaseClient['likeComment']> {
|
): ReturnType<BaseClient['likeComment']> {
|
||||||
// TODO remove any
|
// TODO remove any
|
||||||
return (await this.#client.POST('/comment/like', {
|
return (await this.#client.POST('/comment/like', {
|
||||||
body: { ...params },
|
body: params,
|
||||||
})) as any
|
})) as any
|
||||||
}
|
}
|
||||||
async listCommentLikes(
|
|
||||||
...params: Parameters<BaseClient['listCommentLikes']>
|
async listCommentLikes(): ReturnType<BaseClient['listCommentLikes']> {
|
||||||
): ReturnType<BaseClient['listCommentLikes']> {
|
throw new Error('unsupported')
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async saveComment(
|
async saveComment(
|
||||||
...params: Parameters<BaseClient['saveComment']>
|
...params: Parameters<BaseClient['saveComment']>
|
||||||
): ReturnType<BaseClient['saveComment']> {
|
): ReturnType<BaseClient['saveComment']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async distinguishComment(
|
async distinguishComment(
|
||||||
...params: Parameters<BaseClient['distinguishComment']>
|
...params: Parameters<BaseClient['distinguishComment']>
|
||||||
): ReturnType<BaseClient['distinguishComment']> {
|
): ReturnType<BaseClient['distinguishComment']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
|
|
||||||
async getComments(
|
async getComments(
|
||||||
@@ -347,218 +474,244 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getComment(
|
async getComment(
|
||||||
...params: Parameters<BaseClient['getComment']>
|
params: Parameters<BaseClient['getComment']>[0],
|
||||||
): ReturnType<BaseClient['getComment']> {
|
): ReturnType<BaseClient['getComment']> {
|
||||||
throw new Error('Unimplemented')
|
const response =
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
(await this.#client.GET('/comment', { params: { query: params } })).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async createCommentReport(
|
async createCommentReport(
|
||||||
...params: Parameters<BaseClient['createCommentReport']>
|
...params: Parameters<BaseClient['createCommentReport']>
|
||||||
): ReturnType<BaseClient['createCommentReport']> {
|
): ReturnType<BaseClient['createCommentReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async resolveCommentReport(
|
async resolveCommentReport(
|
||||||
...params: Parameters<BaseClient['resolveCommentReport']>
|
...params: Parameters<BaseClient['resolveCommentReport']>
|
||||||
): ReturnType<BaseClient['resolveCommentReport']> {
|
): ReturnType<BaseClient['resolveCommentReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async listCommentReports(
|
async listCommentReports(
|
||||||
...params: Parameters<BaseClient['listCommentReports']>
|
...params: Parameters<BaseClient['listCommentReports']>
|
||||||
): ReturnType<BaseClient['listCommentReports']> {
|
): ReturnType<BaseClient['listCommentReports']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getPrivateMessages(
|
async getPrivateMessages(
|
||||||
...params: Parameters<BaseClient['getPrivateMessages']>
|
params: Parameters<BaseClient['getPrivateMessages']>[0],
|
||||||
): ReturnType<BaseClient['getPrivateMessages']> {
|
): ReturnType<BaseClient['getPrivateMessages']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/private_message/list', {
|
||||||
|
// @ts-expect-error query params are screwed up
|
||||||
|
params: { query: params },
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
private_messages: response.private_messages.map(toPrivateMessageView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async createPrivateMessage(
|
async createPrivateMessage(
|
||||||
...params: Parameters<BaseClient['createPrivateMessage']>
|
...params: Parameters<BaseClient['createPrivateMessage']>
|
||||||
): ReturnType<BaseClient['createPrivateMessage']> {
|
): ReturnType<BaseClient['createPrivateMessage']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async editPrivateMessage(
|
async editPrivateMessage(
|
||||||
...params: Parameters<BaseClient['editPrivateMessage']>
|
...params: Parameters<BaseClient['editPrivateMessage']>
|
||||||
): ReturnType<BaseClient['editPrivateMessage']> {
|
): ReturnType<BaseClient['editPrivateMessage']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async deletePrivateMessage(
|
async deletePrivateMessage(
|
||||||
...params: Parameters<BaseClient['deletePrivateMessage']>
|
...params: Parameters<BaseClient['deletePrivateMessage']>
|
||||||
): ReturnType<BaseClient['deletePrivateMessage']> {
|
): ReturnType<BaseClient['deletePrivateMessage']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async markPrivateMessageAsRead(
|
async markPrivateMessageAsRead(
|
||||||
...params: Parameters<BaseClient['markPrivateMessageAsRead']>
|
...params: Parameters<BaseClient['markPrivateMessageAsRead']>
|
||||||
): ReturnType<BaseClient['markPrivateMessageAsRead']> {
|
): ReturnType<BaseClient['markPrivateMessageAsRead']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async createPrivateMessageReport(
|
async createPrivateMessageReport(
|
||||||
...params: Parameters<BaseClient['createPrivateMessageReport']>
|
...params: Parameters<BaseClient['createPrivateMessageReport']>
|
||||||
): ReturnType<BaseClient['createPrivateMessageReport']> {
|
): ReturnType<BaseClient['createPrivateMessageReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async resolvePrivateMessageReport(
|
async resolvePrivateMessageReport(
|
||||||
...params: Parameters<BaseClient['resolvePrivateMessageReport']>
|
...params: Parameters<BaseClient['resolvePrivateMessageReport']>
|
||||||
): ReturnType<BaseClient['resolvePrivateMessageReport']> {
|
): ReturnType<BaseClient['resolvePrivateMessageReport']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async listPrivateMessageReports(
|
async listPrivateMessageReports(
|
||||||
...params: Parameters<BaseClient['listPrivateMessageReports']>
|
...params: Parameters<BaseClient['listPrivateMessageReports']>
|
||||||
): ReturnType<BaseClient['listPrivateMessageReports']> {
|
): ReturnType<BaseClient['listPrivateMessageReports']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async register(
|
async register(): ReturnType<BaseClient['register']> {
|
||||||
...params: Parameters<BaseClient['register']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['register']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async login(
|
async login(
|
||||||
...params: Parameters<BaseClient['login']>
|
params: Parameters<BaseClient['login']>[0],
|
||||||
): ReturnType<BaseClient['login']> {
|
): ReturnType<BaseClient['login']> {
|
||||||
throw new Error('Unimplemented')
|
const response = await this.#client.POST('/user/login', {
|
||||||
|
body: { username: params.username_or_email, password: params.password },
|
||||||
|
})!
|
||||||
|
|
||||||
|
return {
|
||||||
|
verify_email_sent: false,
|
||||||
|
registration_created: false,
|
||||||
|
jwt: response.data?.jwt,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async logout(
|
async logout(
|
||||||
...params: Parameters<BaseClient['logout']>
|
...params: Parameters<BaseClient['logout']>
|
||||||
): ReturnType<BaseClient['logout']> {
|
): ReturnType<BaseClient['logout']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getPersonDetails(
|
async getPersonDetails(
|
||||||
...params: Parameters<BaseClient['getPersonDetails']>
|
...params: Parameters<BaseClient['getPersonDetails']>
|
||||||
): ReturnType<BaseClient['getPersonDetails']> {
|
): ReturnType<BaseClient['getPersonDetails']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getPersonMentions(
|
async getPersonMentions(
|
||||||
...params: Parameters<BaseClient['getPersonMentions']>
|
params: Parameters<BaseClient['getPersonMentions']>[0],
|
||||||
): ReturnType<BaseClient['getPersonMentions']> {
|
): ReturnType<BaseClient['getPersonMentions']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/user/mentions', {
|
||||||
|
// @ts-expect-error yet another query param bug
|
||||||
|
params: { query: { ...params, sort: toCommentSortType(params.sort) } },
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
mentions: response.replies.map(toPersonMentionView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async markPersonMentionAsRead(
|
async markPersonMentionAsRead(
|
||||||
...params: Parameters<BaseClient['markPersonMentionAsRead']>
|
params: Parameters<BaseClient['markPersonMentionAsRead']>[0],
|
||||||
): ReturnType<BaseClient['markPersonMentionAsRead']> {
|
): ReturnType<BaseClient['markPersonMentionAsRead']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async getReplies(
|
async getReplies(
|
||||||
...params: Parameters<BaseClient['getReplies']>
|
params: Parameters<BaseClient['getReplies']>[0],
|
||||||
): ReturnType<BaseClient['getReplies']> {
|
): ReturnType<BaseClient['getReplies']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/user/replies', {
|
||||||
|
// @ts-expect-error same here what is happening
|
||||||
|
params: { query: fromGetReplies(params) },
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
replies: response.replies.map(toCommentReplyView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async banPerson(
|
async banPerson(): ReturnType<BaseClient['banPerson']> {
|
||||||
...params: Parameters<BaseClient['banPerson']>
|
// this is for site view not community view
|
||||||
): ReturnType<BaseClient['banPerson']> {
|
throw new Error('unsupported')
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getBannedPersons(
|
async getBannedPersons(): ReturnType<BaseClient['getBannedPersons']> {
|
||||||
...params: Parameters<BaseClient['getBannedPersons']>
|
// this is for site view not community view
|
||||||
): ReturnType<BaseClient['getBannedPersons']> {
|
throw new Error('unsupported')
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async blockPerson(
|
async blockPerson(
|
||||||
...params: Parameters<BaseClient['blockPerson']>
|
params: Parameters<BaseClient['blockPerson']>[0],
|
||||||
): ReturnType<BaseClient['blockPerson']> {
|
): ReturnType<BaseClient['blockPerson']> {
|
||||||
throw new Error('Unimplemented')
|
const response = (await this.#client.POST('/user/block', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
person_view: toPersonView(response.person_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async getCaptcha(
|
async getCaptcha(): ReturnType<BaseClient['getCaptcha']> {
|
||||||
...params: Parameters<BaseClient['getCaptcha']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['getCaptcha']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async deleteAccount(
|
async deleteAccount(): ReturnType<BaseClient['deleteAccount']> {
|
||||||
...params: Parameters<BaseClient['deleteAccount']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['deleteAccount']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async passwordReset(
|
async passwordReset(): ReturnType<BaseClient['passwordReset']> {
|
||||||
...params: Parameters<BaseClient['passwordReset']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['passwordReset']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async passwordChangeAfterReset(
|
async passwordChangeAfterReset(): ReturnType<
|
||||||
...params: Parameters<BaseClient['passwordChangeAfterReset']>
|
BaseClient['passwordChangeAfterReset']
|
||||||
): ReturnType<BaseClient['passwordChangeAfterReset']> {
|
> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async markAllAsRead(
|
async markAllAsRead(): ReturnType<BaseClient['markAllAsRead']> {
|
||||||
...params: Parameters<BaseClient['markAllAsRead']>
|
const response = (await this.#client.POST('/user/mark_all_as_read')).data!
|
||||||
): ReturnType<BaseClient['markAllAsRead']> {
|
|
||||||
throw new Error('Unimplemented')
|
return {
|
||||||
|
replies: response.replies.map(toCommentReplyView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async saveUserSettings(
|
async saveUserSettings(
|
||||||
...params: Parameters<BaseClient['saveUserSettings']>
|
params: Parameters<BaseClient['saveUserSettings']>[0],
|
||||||
): ReturnType<BaseClient['saveUserSettings']> {
|
): ReturnType<BaseClient['saveUserSettings']> {
|
||||||
throw new Error('Unimplemented')
|
return (
|
||||||
|
await this.#client.PUT('/user/save_user_settings', { body: params })
|
||||||
|
).data!
|
||||||
}
|
}
|
||||||
async changePassword(
|
async changePassword(): ReturnType<BaseClient['changePassword']> {
|
||||||
...params: Parameters<BaseClient['changePassword']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['changePassword']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getReportCount(
|
async getReportCount(): ReturnType<BaseClient['getReportCount']> {
|
||||||
...params: Parameters<BaseClient['getReportCount']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['getReportCount']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getUnreadCount(
|
async getUnreadCount(): ReturnType<BaseClient['getUnreadCount']> {
|
||||||
...params: Parameters<BaseClient['getUnreadCount']>
|
return (await this.#client.GET('/user/unread_count')).data!
|
||||||
): ReturnType<BaseClient['getUnreadCount']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async verifyEmail(
|
async verifyEmail(): ReturnType<BaseClient['verifyEmail']> {
|
||||||
...params: Parameters<BaseClient['verifyEmail']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['verifyEmail']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async addAdmin(
|
async addAdmin(): ReturnType<BaseClient['addAdmin']> {
|
||||||
...params: Parameters<BaseClient['addAdmin']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['addAdmin']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getUnreadRegistrationApplicationCount(
|
async getUnreadRegistrationApplicationCount(): ReturnType<
|
||||||
...params: Parameters<BaseClient['getUnreadRegistrationApplicationCount']>
|
BaseClient['getUnreadRegistrationApplicationCount']
|
||||||
): ReturnType<BaseClient['getUnreadRegistrationApplicationCount']> {
|
> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async listRegistrationApplications(
|
async listRegistrationApplications(): ReturnType<
|
||||||
...params: Parameters<BaseClient['listRegistrationApplications']>
|
BaseClient['listRegistrationApplications']
|
||||||
): ReturnType<BaseClient['listRegistrationApplications']> {
|
> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async approveRegistrationApplication(
|
async approveRegistrationApplication(): ReturnType<
|
||||||
...params: Parameters<BaseClient['approveRegistrationApplication']>
|
BaseClient['approveRegistrationApplication']
|
||||||
): ReturnType<BaseClient['approveRegistrationApplication']> {
|
> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async getRegistrationApplication(
|
async getRegistrationApplication(): ReturnType<
|
||||||
...params: Parameters<BaseClient['getRegistrationApplication']>
|
BaseClient['getRegistrationApplication']
|
||||||
): ReturnType<BaseClient['getRegistrationApplication']> {
|
> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async purgePerson(
|
async purgePerson(): ReturnType<BaseClient['purgePerson']> {
|
||||||
...params: Parameters<BaseClient['purgePerson']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['purgePerson']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async purgeCommunity(
|
async purgeCommunity(): ReturnType<BaseClient['purgeCommunity']> {
|
||||||
...params: Parameters<BaseClient['purgeCommunity']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['purgeCommunity']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async purgePost(
|
async purgePost(): ReturnType<BaseClient['purgePost']> {
|
||||||
...params: Parameters<BaseClient['purgePost']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['purgePost']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async purgeComment(
|
async purgeComment(): ReturnType<BaseClient['purgeComment']> {
|
||||||
...params: Parameters<BaseClient['purgeComment']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['purgeComment']> {
|
|
||||||
throw new Error('Unimplemented')
|
|
||||||
}
|
}
|
||||||
async getFederatedInstances(
|
async getFederatedInstances(
|
||||||
...params: Parameters<BaseClient['getFederatedInstances']>
|
...params: Parameters<BaseClient['getFederatedInstances']>
|
||||||
): ReturnType<BaseClient['getFederatedInstances']> {
|
): ReturnType<BaseClient['getFederatedInstances']> {
|
||||||
throw new Error('Unimplemented')
|
throw new Error('unimplemented')
|
||||||
}
|
}
|
||||||
async blockInstance(
|
async blockInstance(
|
||||||
...params: Parameters<BaseClient['blockInstance']>
|
params: Parameters<BaseClient['blockInstance']>[0],
|
||||||
): ReturnType<BaseClient['blockInstance']> {
|
): ReturnType<BaseClient['blockInstance']> {
|
||||||
throw new Error('Unimplemented')
|
return (await this.#client.POST('/site/block', { body: { ...params } }))!
|
||||||
|
.data!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,29 @@
|
|||||||
import type {
|
import type {
|
||||||
Comment,
|
Comment,
|
||||||
|
CommentReplyView,
|
||||||
CommentSortType,
|
CommentSortType,
|
||||||
CommentView,
|
CommentView,
|
||||||
Community,
|
Community,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
|
CreateComment,
|
||||||
|
CreatePost,
|
||||||
GetComments,
|
GetComments,
|
||||||
GetPost,
|
GetPost,
|
||||||
GetPosts,
|
GetPosts,
|
||||||
|
GetReplies,
|
||||||
|
ListCommunities,
|
||||||
LocalSite,
|
LocalSite,
|
||||||
MyUserInfo,
|
MyUserInfo,
|
||||||
Person,
|
Person,
|
||||||
|
PersonMentionView,
|
||||||
PersonView,
|
PersonView,
|
||||||
Post,
|
Post,
|
||||||
PostView,
|
PostView,
|
||||||
|
PrivateMessageView,
|
||||||
|
Search,
|
||||||
SortType,
|
SortType,
|
||||||
} from '../types'
|
} from '../types'
|
||||||
import type { components, paths } from './schema'
|
import type { components } from './schema'
|
||||||
|
|
||||||
export function toPersonView(
|
export function toPersonView(
|
||||||
personView: components['schemas']['PersonView'],
|
personView: components['schemas']['PersonView'],
|
||||||
@@ -156,6 +164,47 @@ export function toComment(comment: components['schemas']['Comment']): Comment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toCommentReplyView(
|
||||||
|
commentReplyView: components['schemas']['CommentReplyView'],
|
||||||
|
): CommentReplyView {
|
||||||
|
return {
|
||||||
|
...commentReplyView,
|
||||||
|
banned_from_community: false,
|
||||||
|
creator_banned_from_community: false,
|
||||||
|
comment: toComment(commentReplyView.comment),
|
||||||
|
creator: toPerson(commentReplyView.creator),
|
||||||
|
post: toPost(commentReplyView.post),
|
||||||
|
community: toCommunity(commentReplyView.community),
|
||||||
|
recipient: toPerson(commentReplyView.recipient),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toPrivateMessageView(
|
||||||
|
privateMessageView: components['schemas']['PrivateMessageView'],
|
||||||
|
): PrivateMessageView {
|
||||||
|
return {
|
||||||
|
...privateMessageView,
|
||||||
|
creator: toPerson(privateMessageView.creator),
|
||||||
|
recipient: toPerson(privateMessageView.recipient),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toPersonMentionView(
|
||||||
|
personMentionView: components['schemas']['CommentReplyView'],
|
||||||
|
): PersonMentionView {
|
||||||
|
return {
|
||||||
|
...personMentionView,
|
||||||
|
person_mention: personMentionView.comment_reply,
|
||||||
|
creator_banned_from_community: false,
|
||||||
|
banned_from_community: false,
|
||||||
|
comment: toComment(personMentionView.comment),
|
||||||
|
community: toCommunity(personMentionView.community),
|
||||||
|
post: toPost(personMentionView.post),
|
||||||
|
creator: toPerson(personMentionView.creator),
|
||||||
|
recipient: toPerson(personMentionView.recipient),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Query calls
|
// Query calls
|
||||||
export function fromGetPosts(
|
export function fromGetPosts(
|
||||||
getPosts: GetPosts,
|
getPosts: GetPosts,
|
||||||
@@ -179,10 +228,55 @@ export function fromGetComments(
|
|||||||
export function fromGetPost(
|
export function fromGetPost(
|
||||||
getPost: GetPost,
|
getPost: GetPost,
|
||||||
): components['schemas']['GetPost'] {
|
): components['schemas']['GetPost'] {
|
||||||
console.log(getPost)
|
|
||||||
return getPost
|
return getPost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fromGetReplies(
|
||||||
|
getReplies: GetReplies,
|
||||||
|
): components['schemas']['GetReplies'] {
|
||||||
|
return {
|
||||||
|
...getReplies,
|
||||||
|
sort: toCommentSortType(getReplies.sort),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromSearch(search: Search): components['schemas']['Search'] {
|
||||||
|
return {
|
||||||
|
...(search as Omit<Search, 'type_'> & {
|
||||||
|
type_: 'Communities' | 'Users' | 'Url' | 'Posts'
|
||||||
|
}),
|
||||||
|
sort: toSortType(search.sort),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromCreatePost(
|
||||||
|
createPost: CreatePost,
|
||||||
|
): components['schemas']['CreatePost'] {
|
||||||
|
return {
|
||||||
|
...createPost,
|
||||||
|
title: createPost.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromListCommunities(
|
||||||
|
listCommunities: ListCommunities,
|
||||||
|
): components['schemas']['ListCommunities'] {
|
||||||
|
return {
|
||||||
|
...listCommunities,
|
||||||
|
// @ts-expect-error ok so the api tells me something different than the actual dev api tells me to do
|
||||||
|
sort: toCommunitiesSortType(listCommunities.sort),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromCreateComment(
|
||||||
|
createComment: CreateComment,
|
||||||
|
): components['schemas']['CreateComment'] {
|
||||||
|
return {
|
||||||
|
...createComment,
|
||||||
|
body: createComment.content,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
export function toSortType(
|
export function toSortType(
|
||||||
sortType?: SortType,
|
sortType?: SortType,
|
||||||
@@ -203,3 +297,11 @@ export function toCommentSortType(
|
|||||||
if (commentSortType == 'Controversial') commentSortType = undefined
|
if (commentSortType == 'Controversial') commentSortType = undefined
|
||||||
return commentSortType
|
return commentSortType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toCommunitiesSortType(
|
||||||
|
sortType?: SortType,
|
||||||
|
): 'Top' | 'Hot' | 'New' | undefined {
|
||||||
|
if (sortType == 'Hot' || sortType == 'New' || sortType == undefined)
|
||||||
|
return sortType
|
||||||
|
else return 'Top'
|
||||||
|
}
|
||||||
@@ -907,7 +907,9 @@
|
|||||||
"couldnt_find_person": "That user doesn't exist.",
|
"couldnt_find_person": "That user doesn't exist.",
|
||||||
"couldnt_find_community": "That community doesn't exist.",
|
"couldnt_find_community": "That community doesn't exist.",
|
||||||
"not_an_admin": "You are not an admin of this instance.",
|
"not_an_admin": "You are not an admin of this instance.",
|
||||||
"rate_limit_error": "You are performing that action too fast."
|
"rate_limit_error": "You are performing that action too fast.",
|
||||||
|
"unimplemented": "That function of your account's instance is not yet supported by Photon.",
|
||||||
|
"unsupported": "That function is not supported by your account's instance."
|
||||||
},
|
},
|
||||||
"aria": {
|
"aria": {
|
||||||
"pagination": {
|
"pagination": {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
function getError(message: string): { string: string; code: boolean } {
|
function getError(message: string): { string: string; code: boolean } {
|
||||||
try {
|
try {
|
||||||
return { string: errorMessage(JSON.parse(message)), code: false }
|
return { string: errorMessage(message), code: false }
|
||||||
} catch {
|
} catch {
|
||||||
return { string: message, code: true }
|
return { string: message, code: true }
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
class="flex flex-col gap-4 my-auto h-full justify-center max-w-md w-full mx-auto"
|
class="flex flex-col gap-4 my-auto h-full justify-center max-w-md w-full mx-auto"
|
||||||
>
|
>
|
||||||
<h1
|
<h1
|
||||||
class="text-primary-900 dark:text-primary-100 text-6xl font-black flex items-center flex-row gap-2 border-b pb-4 border-slate-200 dark:border-zinc-800 font-mono"
|
class="text-primary-900 dark:text-primary-100 text-6xl font-black flex items-center flex-row gap-2 font-mono"
|
||||||
>
|
>
|
||||||
{page.status}
|
{page.status}
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
import SearchBar from './SearchBar.svelte'
|
import SearchBar from './SearchBar.svelte'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
{$t('routes.search.title')}
|
{$t('routes.search.title')}
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
|
{@const clientType = client().type.name}
|
||||||
<form method="get" action="/search" class="contents" bind:this={form}>
|
<form method="get" action="/search" class="contents" bind:this={form}>
|
||||||
<SearchBar bind:query={data.filters.value.query} />
|
<SearchBar bind:query={data.filters.value.query} />
|
||||||
<div class="flex flex-row flex-wrap items-center gap-4">
|
<div class="flex flex-row flex-wrap items-center gap-4">
|
||||||
@@ -69,9 +71,13 @@
|
|||||||
{$t('filter.type')}
|
{$t('filter.type')}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<Option value="All">{$t('content.all')}</Option>
|
{#if clientType == 'lemmy'}
|
||||||
|
<Option value="All">{$t('content.all')}</Option>
|
||||||
|
{/if}
|
||||||
<Option value="Posts">{$t('content.posts')}</Option>
|
<Option value="Posts">{$t('content.posts')}</Option>
|
||||||
<Option value="Comments">{$t('content.comments')}</Option>
|
{#if clientType == 'lemmy'}
|
||||||
|
<Option value="Comments">{$t('content.comments')}</Option>
|
||||||
|
{/if}
|
||||||
<Option value="Communities">{$t('content.communities')}</Option>
|
<Option value="Communities">{$t('content.communities')}</Option>
|
||||||
<Option value="Users">{$t('content.users')}</Option>
|
<Option value="Users">{$t('content.users')}</Option>
|
||||||
<Option value="Url">{$t('content.url')}</Option>
|
<Option value="Url">{$t('content.url')}</Option>
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ export async function load({ url, fetch }) {
|
|||||||
page: page,
|
page: page,
|
||||||
sort: (sort as SortType) || 'TopAll',
|
sort: (sort as SortType) || 'TopAll',
|
||||||
listing_type: listing_type,
|
listing_type: listing_type,
|
||||||
type_: (type as SearchType) ?? 'All',
|
type_:
|
||||||
|
(type as SearchType) ??
|
||||||
|
(client().type.name == 'lemmy' ? 'All' : 'Posts'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const [posts, comments, users, communities] = [
|
const [posts, comments, users, communities] = [
|
||||||
|
|||||||
Reference in new issue
Block a user