stage3: implement all of lemmy compatible piefed api
This commit is contained in:
5 files changed
+246
-118
No files matched your search
@@ -97,7 +97,7 @@ export abstract class BaseClient {
|
|||||||
): Promise<types.CommentResponse>
|
): Promise<types.CommentResponse>
|
||||||
abstract markCommentReplyAsRead(
|
abstract markCommentReplyAsRead(
|
||||||
form: types.MarkCommentReplyAsRead,
|
form: types.MarkCommentReplyAsRead,
|
||||||
): Promise<types.CommentReplyResponse>
|
): Promise<types.CommentReplyResponse | void>
|
||||||
abstract likeComment(
|
abstract likeComment(
|
||||||
form: types.CreateCommentLike,
|
form: types.CreateCommentLike,
|
||||||
): Promise<types.CommentResponse>
|
): Promise<types.CommentResponse>
|
||||||
@@ -159,7 +159,7 @@ export abstract class BaseClient {
|
|||||||
): Promise<types.GetPersonMentionsResponse>
|
): Promise<types.GetPersonMentionsResponse>
|
||||||
abstract markPersonMentionAsRead(
|
abstract markPersonMentionAsRead(
|
||||||
form: types.MarkPersonMentionAsRead,
|
form: types.MarkPersonMentionAsRead,
|
||||||
): Promise<types.PersonMentionResponse>
|
): Promise<types.PersonMentionResponse | void>
|
||||||
abstract getReplies(form: types.GetReplies): Promise<types.GetRepliesResponse>
|
abstract getReplies(form: types.GetReplies): Promise<types.GetRepliesResponse>
|
||||||
abstract banPerson(form: types.BanPerson): Promise<types.BanPersonResponse>
|
abstract banPerson(form: types.BanPerson): Promise<types.BanPersonResponse>
|
||||||
abstract getBannedPersons(): Promise<types.BannedPersonsResponse>
|
abstract getBannedPersons(): Promise<types.BannedPersonsResponse>
|
||||||
|
|||||||
+223
-99
@@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable */
|
|
||||||
import createClient from 'openapi-fetch'
|
import createClient from 'openapi-fetch'
|
||||||
import type { BaseClient, ClientType } from '../base'
|
import type { BaseClient, ClientType } from '../base'
|
||||||
import {
|
import {
|
||||||
@@ -10,6 +9,7 @@ import {
|
|||||||
fromGetReplies,
|
fromGetReplies,
|
||||||
fromListCommunities,
|
fromListCommunities,
|
||||||
fromSearch,
|
fromSearch,
|
||||||
|
toComment,
|
||||||
toCommentReplyView,
|
toCommentReplyView,
|
||||||
toCommentSortType,
|
toCommentSortType,
|
||||||
toCommentView,
|
toCommentView,
|
||||||
@@ -20,8 +20,10 @@ import {
|
|||||||
toPerson,
|
toPerson,
|
||||||
toPersonMentionView,
|
toPersonMentionView,
|
||||||
toPersonView,
|
toPersonView,
|
||||||
|
toPost,
|
||||||
toPostView,
|
toPostView,
|
||||||
toPrivateMessageView,
|
toPrivateMessageView,
|
||||||
|
toSortType,
|
||||||
} from './rewrite'
|
} from './rewrite'
|
||||||
import type { paths } from './schema'
|
import type { paths } from './schema'
|
||||||
|
|
||||||
@@ -46,8 +48,6 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSite(): ReturnType<BaseClient['getSite']> {
|
async getSite(): ReturnType<BaseClient['getSite']> {
|
||||||
// throw new Error('unimplemented')
|
|
||||||
|
|
||||||
const response = (await this.#client.GET('/site')).data!
|
const response = (await this.#client.GET('/site')).data!
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -165,10 +165,15 @@ export class PiefedClient implements BaseClient {
|
|||||||
async likePost(
|
async likePost(
|
||||||
params: Parameters<BaseClient['likePost']>[0],
|
params: Parameters<BaseClient['likePost']>[0],
|
||||||
): ReturnType<BaseClient['likePost']> {
|
): ReturnType<BaseClient['likePost']> {
|
||||||
// TODO remove any
|
const response = (
|
||||||
return (await this.#client.POST('/post/like', {
|
await this.#client.POST('/post/like', {
|
||||||
body: { ...params },
|
body: { ...params },
|
||||||
})) as any
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateTotpSecret(): ReturnType<BaseClient['generateTotpSecret']> {
|
async generateTotpSecret(): ReturnType<BaseClient['generateTotpSecret']> {
|
||||||
@@ -332,18 +337,26 @@ export class PiefedClient implements BaseClient {
|
|||||||
async banFromCommunity(
|
async banFromCommunity(
|
||||||
params: Parameters<BaseClient['banFromCommunity']>[0],
|
params: Parameters<BaseClient['banFromCommunity']>[0],
|
||||||
): ReturnType<BaseClient['banFromCommunity']> {
|
): ReturnType<BaseClient['banFromCommunity']> {
|
||||||
const response = (
|
const response = // piefed has separate methods for ban/unban
|
||||||
await this.#client.POST('/community/moderate/ban', {
|
(
|
||||||
body: {
|
params.ban
|
||||||
...params,
|
? await this.#client.POST('/community/moderate/ban', {
|
||||||
expiredAt: new Date(
|
body: {
|
||||||
params.expires ?? '6767-06-07T00:00:00.000Z',
|
...params,
|
||||||
).toISOString(),
|
expiredAt: new Date(
|
||||||
user_id: params.person_id,
|
params.expires ?? '6767-06-07T00:00:00.000Z',
|
||||||
reason: params.reason ?? 'No reason provided.',
|
).toISOString(),
|
||||||
},
|
user_id: params.person_id,
|
||||||
})
|
reason: params.reason ?? 'No reason provided.',
|
||||||
).data!
|
},
|
||||||
|
})
|
||||||
|
: await this.#client.PUT('/community/moderate/unban', {
|
||||||
|
body: {
|
||||||
|
community_id: params.community_id,
|
||||||
|
user_id: params.person_id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
return {
|
return {
|
||||||
banned: params.ban,
|
banned: params.ban,
|
||||||
@@ -354,34 +367,56 @@ export class PiefedClient implements BaseClient {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async addModToCommunity() // ...params: Parameters<BaseClient['addModToCommunity']>
|
async addModToCommunity(
|
||||||
: ReturnType<BaseClient['addModToCommunity']> {
|
params: Parameters<BaseClient['addModToCommunity']>[0],
|
||||||
throw new Error('unimplemented')
|
): ReturnType<BaseClient['addModToCommunity']> {
|
||||||
|
const response = (
|
||||||
|
await this.#client.POST('/community/mod', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
moderators: response.moderators.map(i => ({
|
||||||
|
community: toCommunity(i.community),
|
||||||
|
moderator: toPerson(i.moderator),
|
||||||
|
})),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async markPostAsRead(
|
async markPostAsRead(
|
||||||
params: Parameters<BaseClient['markPostAsRead']>[0],
|
params: Parameters<BaseClient['markPostAsRead']>[0],
|
||||||
): ReturnType<BaseClient['markPostAsRead']> {
|
): ReturnType<BaseClient['markPostAsRead']> {
|
||||||
const response = await this.#client.POST('/post/mark_as_read', {
|
await this.#client.POST('/post/mark_as_read', {
|
||||||
body: { ...params },
|
body: { ...params },
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO remove any
|
return {
|
||||||
return response.data as any
|
success: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async hidePost(
|
async hidePost(): ReturnType<BaseClient['hidePost']> {
|
||||||
...params: Parameters<BaseClient['hidePost']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['hidePost']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async lockPost(
|
async lockPost(
|
||||||
...params: Parameters<BaseClient['lockPost']>
|
params: Parameters<BaseClient['lockPost']>[0],
|
||||||
): ReturnType<BaseClient['lockPost']> {
|
): ReturnType<BaseClient['lockPost']> {
|
||||||
throw new Error('unimplemented')
|
const response = (await this.#client.POST('/post/lock', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async featurePost(
|
async featurePost(
|
||||||
...params: Parameters<BaseClient['featurePost']>
|
params: Parameters<BaseClient['featurePost']>[0],
|
||||||
): ReturnType<BaseClient['featurePost']> {
|
): ReturnType<BaseClient['featurePost']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/post/feature', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
post_view: toPostView(response.post_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async listPostLikes(): ReturnType<BaseClient['listPostLikes']> {
|
async listPostLikes(): ReturnType<BaseClient['listPostLikes']> {
|
||||||
throw new Error('unsupported')
|
throw new Error('unsupported')
|
||||||
@@ -397,24 +432,36 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async createPostReport(
|
async createPostReport(
|
||||||
...params: Parameters<BaseClient['createPostReport']>
|
params: Parameters<BaseClient['createPostReport']>[0],
|
||||||
): ReturnType<BaseClient['createPostReport']> {
|
): ReturnType<BaseClient['createPostReport']> {
|
||||||
throw new Error('unimplemented')
|
const response = (await this.#client.POST('/post/report', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
post_report_view: {
|
||||||
|
...response.post_report_view,
|
||||||
|
community: toCommunity(response.post_report_view.community),
|
||||||
|
post: toPost(response.post_report_view.post),
|
||||||
|
creator: toPerson(response.post_report_view.creator),
|
||||||
|
resolver: response.post_report_view.resolver
|
||||||
|
? toPerson(response.post_report_view.resolver)
|
||||||
|
: undefined,
|
||||||
|
post_creator: toPerson(response.post_report_view.post_creator),
|
||||||
|
read: false,
|
||||||
|
hidden: false,
|
||||||
|
creator_banned_from_community: false,
|
||||||
|
unread_comments: -1,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async resolvePostReport(
|
async resolvePostReport(): ReturnType<BaseClient['resolvePostReport']> {
|
||||||
...params: Parameters<BaseClient['resolvePostReport']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['resolvePostReport']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async listPostReports(
|
async listPostReports(): ReturnType<BaseClient['listPostReports']> {
|
||||||
...params: Parameters<BaseClient['listPostReports']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['listPostReports']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async getSiteMetadata(
|
async getSiteMetadata(): ReturnType<BaseClient['getSiteMetadata']> {
|
||||||
...params: Parameters<BaseClient['getSiteMetadata']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['getSiteMetadata']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async createComment(
|
async createComment(
|
||||||
@@ -468,31 +515,45 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async markCommentReplyAsRead(
|
async markCommentReplyAsRead(
|
||||||
...params: Parameters<BaseClient['markCommentReplyAsRead']>
|
params: Parameters<BaseClient['markCommentReplyAsRead']>[0],
|
||||||
): ReturnType<BaseClient['markCommentReplyAsRead']> {
|
): ReturnType<BaseClient['markCommentReplyAsRead']> {
|
||||||
throw new Error('unimplemented')
|
await this.#client.POST('/comment/mark_as_read', {
|
||||||
|
body: params,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
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', {
|
const response = (
|
||||||
body: params,
|
await this.#client.POST('/comment/like', {
|
||||||
})) as any
|
body: params,
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async listCommentLikes(): ReturnType<BaseClient['listCommentLikes']> {
|
async listCommentLikes(): ReturnType<BaseClient['listCommentLikes']> {
|
||||||
throw new Error('unsupported')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async saveComment(
|
async saveComment(
|
||||||
...params: Parameters<BaseClient['saveComment']>
|
params: Parameters<BaseClient['saveComment']>[0],
|
||||||
): ReturnType<BaseClient['saveComment']> {
|
): ReturnType<BaseClient['saveComment']> {
|
||||||
throw new Error('unimplemented')
|
const response = (await this.#client.PUT('/comment/save', { body: params }))
|
||||||
|
.data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
comment_view: toCommentView(response.comment_view),
|
||||||
|
recipient_ids: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async distinguishComment(
|
async distinguishComment(): ReturnType<BaseClient['distinguishComment']> {
|
||||||
...params: Parameters<BaseClient['distinguishComment']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['distinguishComment']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getComments(
|
async getComments(
|
||||||
@@ -524,19 +585,32 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async createCommentReport(
|
async createCommentReport(
|
||||||
...params: Parameters<BaseClient['createCommentReport']>
|
params: Parameters<BaseClient['createCommentReport']>[0],
|
||||||
): ReturnType<BaseClient['createCommentReport']> {
|
): ReturnType<BaseClient['createCommentReport']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/comment/report', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
comment_report_view: {
|
||||||
|
...response.comment_report_view,
|
||||||
|
comment: toComment(response.comment_report_view.comment),
|
||||||
|
community: toCommunity(response.comment_report_view.community),
|
||||||
|
comment_creator: toPerson(response.comment_report_view.comment_creator),
|
||||||
|
creator: toPerson(response.comment_report_view.creator),
|
||||||
|
post: toPost(response.comment_report_view.post),
|
||||||
|
resolver: response.comment_report_view.resolver
|
||||||
|
? toPerson(response.comment_report_view.resolver)
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async resolveCommentReport(
|
async resolveCommentReport(): ReturnType<BaseClient['resolveCommentReport']> {
|
||||||
...params: Parameters<BaseClient['resolveCommentReport']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['resolveCommentReport']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async listCommentReports(
|
async listCommentReports(): ReturnType<BaseClient['listCommentReports']> {
|
||||||
...params: Parameters<BaseClient['listCommentReports']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['listCommentReports']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async getPrivateMessages(
|
async getPrivateMessages(
|
||||||
params: Parameters<BaseClient['getPrivateMessages']>[0],
|
params: Parameters<BaseClient['getPrivateMessages']>[0],
|
||||||
@@ -553,39 +627,67 @@ export class PiefedClient implements BaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async createPrivateMessage(
|
async createPrivateMessage(
|
||||||
...params: Parameters<BaseClient['createPrivateMessage']>
|
params: Parameters<BaseClient['createPrivateMessage']>[0],
|
||||||
): ReturnType<BaseClient['createPrivateMessage']> {
|
): ReturnType<BaseClient['createPrivateMessage']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/private_message', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
private_message_view: toPrivateMessageView(response.private_message_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async editPrivateMessage(
|
async editPrivateMessage(
|
||||||
...params: Parameters<BaseClient['editPrivateMessage']>
|
params: Parameters<BaseClient['editPrivateMessage']>[0],
|
||||||
): ReturnType<BaseClient['editPrivateMessage']> {
|
): ReturnType<BaseClient['editPrivateMessage']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.PUT('/private_message', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
private_message_view: toPrivateMessageView(response.private_message_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async deletePrivateMessage(
|
async deletePrivateMessage(
|
||||||
...params: Parameters<BaseClient['deletePrivateMessage']>
|
params: Parameters<BaseClient['deletePrivateMessage']>[0],
|
||||||
): ReturnType<BaseClient['deletePrivateMessage']> {
|
): ReturnType<BaseClient['deletePrivateMessage']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/private_message/delete', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
private_message_view: toPrivateMessageView(response.private_message_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async markPrivateMessageAsRead(
|
async markPrivateMessageAsRead(
|
||||||
...params: Parameters<BaseClient['markPrivateMessageAsRead']>
|
params: Parameters<BaseClient['markPrivateMessageAsRead']>[0],
|
||||||
): ReturnType<BaseClient['markPrivateMessageAsRead']> {
|
): ReturnType<BaseClient['markPrivateMessageAsRead']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.POST('/private_message/mark_as_read', { body: params })
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
...response,
|
||||||
|
private_message_view: toPrivateMessageView(response.private_message_view),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async createPrivateMessageReport(
|
async createPrivateMessageReport(): ReturnType<
|
||||||
...params: Parameters<BaseClient['createPrivateMessageReport']>
|
BaseClient['createPrivateMessageReport']
|
||||||
): ReturnType<BaseClient['createPrivateMessageReport']> {
|
> {
|
||||||
throw new Error('unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async resolvePrivateMessageReport(
|
async resolvePrivateMessageReport(): ReturnType<
|
||||||
...params: Parameters<BaseClient['resolvePrivateMessageReport']>
|
BaseClient['resolvePrivateMessageReport']
|
||||||
): ReturnType<BaseClient['resolvePrivateMessageReport']> {
|
> {
|
||||||
throw new Error('unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async listPrivateMessageReports(
|
async listPrivateMessageReports(): ReturnType<
|
||||||
...params: Parameters<BaseClient['listPrivateMessageReports']>
|
BaseClient['listPrivateMessageReports']
|
||||||
): ReturnType<BaseClient['listPrivateMessageReports']> {
|
> {
|
||||||
throw new Error('unimplemented')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async register(): ReturnType<BaseClient['register']> {
|
async register(): ReturnType<BaseClient['register']> {
|
||||||
throw new Error('unsupported')
|
throw new Error('unsupported')
|
||||||
@@ -603,15 +705,34 @@ export class PiefedClient implements BaseClient {
|
|||||||
jwt: response.data?.jwt,
|
jwt: response.data?.jwt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async logout(
|
async logout(): ReturnType<BaseClient['logout']> {
|
||||||
...params: Parameters<BaseClient['logout']>
|
throw new Error('unsupported')
|
||||||
): ReturnType<BaseClient['logout']> {
|
|
||||||
throw new Error('unimplemented')
|
|
||||||
}
|
}
|
||||||
async getPersonDetails(
|
async getPersonDetails(
|
||||||
...params: Parameters<BaseClient['getPersonDetails']>
|
params: Parameters<BaseClient['getPersonDetails']>[0],
|
||||||
): ReturnType<BaseClient['getPersonDetails']> {
|
): ReturnType<BaseClient['getPersonDetails']> {
|
||||||
throw new Error('unimplemented')
|
const response = (
|
||||||
|
await this.#client.GET('/user', {
|
||||||
|
params: {
|
||||||
|
query: {
|
||||||
|
...params,
|
||||||
|
// @ts-expect-error more param cursedness
|
||||||
|
include_content: true,
|
||||||
|
sort: toSortType(params.sort),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return {
|
||||||
|
comments: response.comments.map(toCommentView),
|
||||||
|
moderates: response.moderates.map(i => ({
|
||||||
|
community: toCommunity(i.community),
|
||||||
|
moderator: toPerson(i.moderator),
|
||||||
|
})),
|
||||||
|
person_view: toPersonView(response.person_view),
|
||||||
|
posts: response.posts.map(toPostView),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async getPersonMentions(
|
async getPersonMentions(
|
||||||
params: Parameters<BaseClient['getPersonMentions']>[0],
|
params: Parameters<BaseClient['getPersonMentions']>[0],
|
||||||
@@ -630,7 +751,10 @@ export class PiefedClient implements BaseClient {
|
|||||||
async markPersonMentionAsRead(
|
async markPersonMentionAsRead(
|
||||||
params: Parameters<BaseClient['markPersonMentionAsRead']>[0],
|
params: Parameters<BaseClient['markPersonMentionAsRead']>[0],
|
||||||
): ReturnType<BaseClient['markPersonMentionAsRead']> {
|
): ReturnType<BaseClient['markPersonMentionAsRead']> {
|
||||||
throw new Error('unimplemented')
|
// @ts-expect-error this method isnt documented
|
||||||
|
await this.#client.POST('/mention/mark_as_read', {
|
||||||
|
body: params,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
async getReplies(
|
async getReplies(
|
||||||
params: Parameters<BaseClient['getReplies']>[0],
|
params: Parameters<BaseClient['getReplies']>[0],
|
||||||
@@ -740,10 +864,10 @@ export class PiefedClient implements BaseClient {
|
|||||||
async purgeComment(): ReturnType<BaseClient['purgeComment']> {
|
async purgeComment(): ReturnType<BaseClient['purgeComment']> {
|
||||||
throw new Error('unsupported')
|
throw new Error('unsupported')
|
||||||
}
|
}
|
||||||
async getFederatedInstances(
|
async getFederatedInstances(): ReturnType<
|
||||||
...params: Parameters<BaseClient['getFederatedInstances']>
|
BaseClient['getFederatedInstances']
|
||||||
): ReturnType<BaseClient['getFederatedInstances']> {
|
> {
|
||||||
throw new Error('unimplemented')
|
return (await this.#client.GET('/federated_instances')).data!
|
||||||
}
|
}
|
||||||
async blockInstance(
|
async blockInstance(
|
||||||
params: Parameters<BaseClient['blockInstance']>[0],
|
params: Parameters<BaseClient['blockInstance']>[0],
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
|
import { LemmyClient } from '$lib/client/lemmy/lemmy'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { searchParam } from '$lib/util.svelte.js'
|
import { searchParam } from '$lib/util.svelte.js'
|
||||||
import { Select } from 'mono-svelte'
|
import { Select } from 'mono-svelte'
|
||||||
@@ -72,18 +74,20 @@
|
|||||||
<Option value="New" icon={Star}>
|
<Option value="New" icon={Star}>
|
||||||
{$t('filter.sort.new')}
|
{$t('filter.sort.new')}
|
||||||
</Option>
|
</Option>
|
||||||
<Option value="Old" icon={Clock}>
|
{#if client() instanceof LemmyClient}
|
||||||
{$t('filter.sort.old')}
|
<Option value="Old" icon={Clock}>
|
||||||
</Option>
|
{$t('filter.sort.old')}
|
||||||
<Option value="Controversial" icon={ArrowTrendingDown}>
|
</Option>
|
||||||
{$t('filter.sort.controversial')}
|
<Option value="Controversial" icon={ArrowTrendingDown}>
|
||||||
</Option>
|
{$t('filter.sort.controversial')}
|
||||||
<Option value="MostComments" icon={ChatBubbleOvalLeft}>
|
</Option>
|
||||||
{$t('filter.sort.mostcomments')}
|
<Option value="MostComments" icon={ChatBubbleOvalLeft}>
|
||||||
</Option>
|
{$t('filter.sort.mostcomments')}
|
||||||
<Option value="NewComments" icon={ChatBubbleLeftRight}>
|
</Option>
|
||||||
{$t('filter.sort.newcomments')}
|
<Option value="NewComments" icon={ChatBubbleLeftRight}>
|
||||||
</Option>
|
{$t('filter.sort.newcomments')}
|
||||||
|
</Option>
|
||||||
|
{/if}
|
||||||
</Select>
|
</Select>
|
||||||
{#if selected?.startsWith('Top')}
|
{#if selected?.startsWith('Top')}
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ export async function load({ params, url, fetch }) {
|
|||||||
const commentParams: GetComments = {
|
const commentParams: GetComments = {
|
||||||
post_id: Number(params.id),
|
post_id: Number(params.id),
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
page: 1,
|
|
||||||
max_depth: max_depth,
|
max_depth: max_depth,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { client, getClient } from '$lib/client/lemmy.svelte'
|
import { client, getClient } from '$lib/client/lemmy.svelte'
|
||||||
|
import { PiefedClient } from '$lib/client/piefed/piefed.js'
|
||||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||||
import { ReactiveState } from '$lib/promise.svelte.js'
|
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||||
import type { ListingType, SearchType, SortType } from 'lemmy-js-client'
|
import type { ListingType, SearchType, SortType } from 'lemmy-js-client'
|
||||||
@@ -9,7 +10,9 @@ export async function load({ url, fetch }) {
|
|||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
const community = Number(url.searchParams.get('community')) || undefined
|
const community = Number(url.searchParams.get('community')) || undefined
|
||||||
const sort = url.searchParams.get('sort') || 'New'
|
const sort = url.searchParams.get('sort') || 'New'
|
||||||
const type = url.searchParams.get('type') || 'All'
|
const type =
|
||||||
|
url.searchParams.get('type') ||
|
||||||
|
(client() instanceof PiefedClient ? 'Posts' : 'All')
|
||||||
const listing_type =
|
const listing_type =
|
||||||
(url.searchParams.get('listing_type') as ListingType) || 'All'
|
(url.searchParams.get('listing_type') as ListingType) || 'All'
|
||||||
|
|
||||||
@@ -21,9 +24,7 @@ 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_: type as SearchType,
|
||||||
(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