stage3: add piefed login
This commit is contained in:
6 files changed
+116
-25
No files matched your search
@@ -71,7 +71,7 @@ export function client({
|
||||
clientType = profile.current.client
|
||||
}
|
||||
|
||||
const jwt = auth ? auth : profile.current?.jwt
|
||||
const jwt = auth ?? profile.current?.jwt
|
||||
|
||||
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
|
||||
|
||||
@@ -95,11 +95,18 @@ export function getClient(
|
||||
return client({ instanceURL, func, auth })
|
||||
}
|
||||
|
||||
export async function validateInstance(instance: string): Promise<boolean> {
|
||||
export async function validateInstance(
|
||||
instance: string,
|
||||
type: ClientType,
|
||||
): Promise<boolean> {
|
||||
if (instance == '') return false
|
||||
|
||||
try {
|
||||
await getClient(instance).getSite()
|
||||
await client({
|
||||
instanceURL: instance,
|
||||
clientType: type,
|
||||
auth: '',
|
||||
}).getSite()
|
||||
|
||||
return true
|
||||
} catch {
|
||||
|
||||
@@ -129,9 +129,12 @@ export class PiefedClient implements BaseClient {
|
||||
}
|
||||
}
|
||||
async likePost(
|
||||
...params: Parameters<BaseClient['likePost']>
|
||||
params: Parameters<BaseClient['likePost']>[0],
|
||||
): ReturnType<BaseClient['likePost']> {
|
||||
throw new Error('Unimplemented')
|
||||
// TODO remove any
|
||||
return (await this.#client.POST('/post/like', {
|
||||
body: { ...params },
|
||||
})) as any
|
||||
}
|
||||
|
||||
async generateTotpSecret(
|
||||
@@ -225,9 +228,14 @@ export class PiefedClient implements BaseClient {
|
||||
throw new Error('Unimplemented')
|
||||
}
|
||||
async markPostAsRead(
|
||||
...params: Parameters<BaseClient['markPostAsRead']>
|
||||
params: Parameters<BaseClient['markPostAsRead']>[0],
|
||||
): ReturnType<BaseClient['markPostAsRead']> {
|
||||
throw new Error('Unimplemented')
|
||||
const response = await this.#client.POST('/post/mark_as_read', {
|
||||
body: { ...params },
|
||||
})
|
||||
|
||||
// TODO remove any
|
||||
return response.data as any
|
||||
}
|
||||
async hidePost(
|
||||
...params: Parameters<BaseClient['hidePost']>
|
||||
@@ -300,9 +308,12 @@ export class PiefedClient implements BaseClient {
|
||||
throw new Error('Unimplemented')
|
||||
}
|
||||
async likeComment(
|
||||
...params: Parameters<BaseClient['likeComment']>
|
||||
params: Parameters<BaseClient['likeComment']>[0],
|
||||
): ReturnType<BaseClient['likeComment']> {
|
||||
throw new Error('Unimplemented')
|
||||
// TODO remove any
|
||||
return (await this.#client.POST('/comment/like', {
|
||||
body: { ...params },
|
||||
})) as any
|
||||
}
|
||||
async listCommentLikes(
|
||||
...params: Parameters<BaseClient['listCommentLikes']>
|
||||
|
||||
@@ -121,7 +121,6 @@
|
||||
class={[
|
||||
'rounded-xl rounded-l-none text-slate-600 dark:text-zinc-400',
|
||||
inlineAffixes && 'bg-white dark:bg-zinc-900 pl-0',
|
||||
sizeClass[size],
|
||||
]}
|
||||
>
|
||||
{@render suffix?.()}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
</script>
|
||||
|
||||
{#snippet selectTarget(attachment: Attachment)}
|
||||
<Label text={label} customText={customLabel} class={['space-y-1 relative', clazz, baseClass]}>
|
||||
<Label text={label} customText={customLabel} class={['space-y-1 relative', baseClass]}>
|
||||
<div class="relative" role="presentation">
|
||||
<select
|
||||
{@attach attachment}
|
||||
|
||||
Reference in new issue
Block a user