chore: lint and update package name

This commit is contained in:
Mar0xy 2023-09-24 17:36:13 +02:00
parent 410e6515d3
commit db6dc1b52e
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
12 changed files with 1636 additions and 1683 deletions

View file

@ -1,10 +1,10 @@
{
"name": "misskey",
"name": "sharkey",
"version": "2023.9.0-beta.10",
"codename": "nasubi",
"repository": {
"type": "git",
"url": "https://github.com/misskey-dev/misskey.git"
"url": "https://github.com/transfem-org/sharkey.git"
},
"packageManager": "pnpm@8.7.6",
"workspaces": [

View file

@ -1,19 +1,16 @@
import { fileURLToPath } from 'node:url';
import { Inject, Injectable } from '@nestjs/common';
import megalodon, { Entity, MegalodonInterface } from 'megalodon';
import { IsNull } from 'typeorm';
import multer from 'fastify-multer';
import type { UsersRepository } from '@/models/_.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
import megalodon, { Entity, MegalodonInterface } from 'megalodon';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
import { convertId, IdConvertType as IdType, convertAccount, convertAnnouncement, convertFilter, convertAttachment, convertFeaturedTag, convertList } from './converters.js';
import { IsNull } from 'typeorm';
import type { Config } from '@/config.js';
import { getInstance } from './endpoints/meta.js';
import { MetaService } from '@/core/MetaService.js';
import multer from 'fastify-multer';
import { apiAuthMastodon, apiAccountMastodon, apiFilterMastodon, apiNotifyMastodon, apiSearchMastodon, apiTimelineMastodon, apiStatusMastodon } from './endpoints.js';
const staticAssets = fileURLToPath(new URL('../../../../assets/', import.meta.url));
import { convertId, IdConvertType as IdType, convertAccount, convertAnnouncement, convertFilter, convertAttachment, convertFeaturedTag, convertList } from './converters.js';
import { getInstance } from './endpoints/meta.js';
import { ApiAuthMastodon, ApiAccountMastodon, ApiFilterMastodon, ApiNotifyMastodon, ApiSearchMastodon, ApiTimelineMastodon, ApiStatusMastodon } from './endpoints.js';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
export function getClient(BASE_URL: string, authorization: string | undefined): MegalodonInterface {
const accessTokenArr = authorization?.split(' ') ?? [null];
@ -101,7 +98,7 @@ export class MastodonApiServerService {
const client = getClient(BASE_URL, accessTokens);
try {
const data = await client.dismissInstanceAnnouncement(
convertId(_request.body['id'], IdType.SharkeyId)
convertId(_request.body['id'], IdType.SharkeyId),
);
reply.send(data.data);
} catch (e: any) {
@ -180,7 +177,7 @@ export class MastodonApiServerService {
const client = getClient(BASE_URL, ''); // we are using this here, because in private mode some info isnt
// displayed without being logged in
try {
const data = await apiAuthMastodon(_request, client);
const data = await ApiAuthMastodon(_request, client);
reply.send(data);
} catch (e: any) {
console.error(e);
@ -209,7 +206,7 @@ export class MastodonApiServerService {
const client = getClient(BASE_URL, accessTokens); // we are using this here, because in private mode some info isnt
// displayed without being logged in
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.verifyCredentials());
} catch (e: any) {
console.error(e);
@ -223,7 +220,7 @@ export class MastodonApiServerService {
const client = getClient(BASE_URL, accessTokens); // we are using this here, because in private mode some info isnt
// displayed without being logged in
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.updateCredentials());
} catch (e: any) {
console.error(e);
@ -237,7 +234,7 @@ export class MastodonApiServerService {
const client = getClient(BASE_URL, accessTokens); // we are using this here, because in private mode some info isnt
// displayed without being logged in
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.lookup());
} catch (e: any) {
console.error(e);
@ -257,11 +254,11 @@ export class MastodonApiServerService {
ids = [ids];
}
users = ids;
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getRelationships(users));
} catch (e: any) {
console.error(e);
let data = e.response.data;
const data = e.response.data;
data.users = users;
console.error(data);
reply.code(401).send(data);
@ -288,7 +285,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getStatuses());
} catch (e: any) {
console.error(e);
@ -316,7 +313,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getFollowers());
} catch (e: any) {
console.error(e);
@ -330,7 +327,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getFollowing());
} catch (e: any) {
console.error(e);
@ -358,7 +355,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.addFollow());
} catch (e: any) {
console.error(e);
@ -372,7 +369,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.rmFollow());
} catch (e: any) {
console.error(e);
@ -386,7 +383,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.addBlock());
} catch (e: any) {
console.error(e);
@ -400,7 +397,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.rmBlock());
} catch (e: any) {
console.error(e);
@ -414,7 +411,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.addMute());
} catch (e: any) {
console.error(e);
@ -428,7 +425,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.rmMute());
} catch (e: any) {
console.error(e);
@ -456,7 +453,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getBookmarks());
} catch (e: any) {
console.error(e);
@ -470,7 +467,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getFavourites());
} catch (e: any) {
console.error(e);
@ -484,7 +481,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getMutes());
} catch (e: any) {
console.error(e);
@ -498,7 +495,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.getBlocks());
} catch (e: any) {
console.error(e);
@ -526,7 +523,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.acceptFollow());
} catch (e: any) {
console.error(e);
@ -540,7 +537,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const account = new apiAccountMastodon(_request, client, BASE_URL);
const account = new ApiAccountMastodon(_request, client, BASE_URL);
reply.send(await account.rejectFollow());
} catch (e: any) {
console.error(e);
@ -556,7 +553,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const search = new apiSearchMastodon(_request, client, BASE_URL);
const search = new ApiSearchMastodon(_request, client, BASE_URL);
reply.send(await search.SearchV1());
} catch (e: any) {
console.error(e);
@ -570,7 +567,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const search = new apiSearchMastodon(_request, client, BASE_URL);
const search = new ApiSearchMastodon(_request, client, BASE_URL);
reply.send(await search.SearchV2());
} catch (e: any) {
console.error(e);
@ -584,7 +581,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const search = new apiSearchMastodon(_request, client, BASE_URL);
const search = new ApiSearchMastodon(_request, client, BASE_URL);
reply.send(await search.getStatusTrends());
} catch (e: any) {
console.error(e);
@ -598,7 +595,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const search = new apiSearchMastodon(_request, client, BASE_URL);
const search = new ApiSearchMastodon(_request, client, BASE_URL);
reply.send(await search.getSuggestions());
} catch (e: any) {
console.error(e);
@ -614,7 +611,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const notify = new apiNotifyMastodon(_request, client);
const notify = new ApiNotifyMastodon(_request, client);
reply.send(await notify.getNotifications());
} catch (e: any) {
console.error(e);
@ -628,7 +625,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const notify = new apiNotifyMastodon(_request, client);
const notify = new ApiNotifyMastodon(_request, client);
reply.send(await notify.getNotification());
} catch (e: any) {
console.error(e);
@ -642,7 +639,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const notify = new apiNotifyMastodon(_request, client);
const notify = new ApiNotifyMastodon(_request, client);
reply.send(await notify.rmNotification());
} catch (e: any) {
console.error(e);
@ -656,7 +653,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const notify = new apiNotifyMastodon(_request, client);
const notify = new ApiNotifyMastodon(_request, client);
reply.send(await notify.rmNotifications());
} catch (e: any) {
console.error(e);
@ -672,7 +669,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const filter = new apiFilterMastodon(_request, client);
const filter = new ApiFilterMastodon(_request, client);
!_request.params.id ? reply.send(await filter.getFilters()) : reply.send(await filter.getFilter());
} catch (e: any) {
console.error(e);
@ -686,7 +683,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const filter = new apiFilterMastodon(_request, client);
const filter = new ApiFilterMastodon(_request, client);
reply.send(await filter.createFilter());
} catch (e: any) {
console.error(e);
@ -700,7 +697,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const filter = new apiFilterMastodon(_request, client);
const filter = new ApiFilterMastodon(_request, client);
reply.send(await filter.updateFilter());
} catch (e: any) {
console.error(e);
@ -714,7 +711,7 @@ export class MastodonApiServerService {
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const filter = new apiFilterMastodon(_request, client);
const filter = new ApiFilterMastodon(_request, client);
reply.send(await filter.rmFilter());
} catch (e: any) {
console.error(e);
@ -725,7 +722,7 @@ export class MastodonApiServerService {
//#endregion
//#region Timelines
const TLEndpoint = new apiTimelineMastodon(fastify);
const TLEndpoint = new ApiTimelineMastodon(fastify);
// GET Endpoints
TLEndpoint.getTL();
@ -750,7 +747,7 @@ export class MastodonApiServerService {
//#endregion
//#region Status
const NoteEndpoint = new apiStatusMastodon(fastify);
const NoteEndpoint = new ApiStatusMastodon(fastify);
// GET Endpoints
NoteEndpoint.getStatus();

View file

@ -1,6 +1,6 @@
import { Entity } from 'megalodon';
const CHAR_COLLECTION: string = '0123456789abcdefghijklmnopqrstuvwxyz';
const CHAR_COLLECTION = '0123456789abcdefghijklmnopqrstuvwxyz';
export enum IdConvertType {
MastodonId,
@ -9,25 +9,27 @@ export enum IdConvertType {
export function convertId(in_id: string, id_convert_type: IdConvertType): string {
switch (id_convert_type) {
case IdConvertType.MastodonId:
let out: bigint = BigInt(0);
case IdConvertType.MastodonId: {
let out = BigInt(0);
const lowerCaseId = in_id.toLowerCase();
for (let i = 0; i < lowerCaseId.length; i++) {
const charValue = numFromChar(lowerCaseId.charAt(i));
out += BigInt(charValue) * BigInt(36) ** BigInt(i);
}
return out.toString();
}
case IdConvertType.SharkeyId:
let input: bigint = BigInt(in_id);
case IdConvertType.SharkeyId: {
let input = BigInt(in_id);
let outStr = '';
while (input > BigInt(0)) {
const remainder = Number(input % BigInt(36));
outStr = charFromNum(remainder) + outStr;
input /= BigInt(36);
}
let ReversedoutStr = outStr.split('').reduce((acc, char) => char + acc, '');
const ReversedoutStr = outStr.split('').reduce((acc, char) => char + acc, '');
return ReversedoutStr;
}
default:
throw new Error('Invalid ID conversion type');
@ -81,8 +83,7 @@ export function convertFeaturedTag(tag: Entity.FeaturedTag) {
export function convertNotification(notification: Entity.Notification) {
notification.account = convertAccount(notification.account);
notification.id = convertId(notification.id, IdConvertType.MastodonId);
if (notification.status)
notification.status = convertStatus(notification.status);
if (notification.status) notification.status = convertStatus(notification.status);
return notification;
}
@ -102,13 +103,11 @@ export function convertRelationship(relationship: Entity.Relationship) {
export function convertStatus(status: Entity.Status) {
status.account = convertAccount(status.account);
status.id = convertId(status.id, IdConvertType.MastodonId);
if (status.in_reply_to_account_id)
status.in_reply_to_account_id = convertId(
if (status.in_reply_to_account_id) status.in_reply_to_account_id = convertId(
status.in_reply_to_account_id,
IdConvertType.MastodonId,
);
if (status.in_reply_to_id)
status.in_reply_to_id = convertId(status.in_reply_to_id, IdConvertType.MastodonId);
if (status.in_reply_to_id) status.in_reply_to_id = convertId(status.in_reply_to_id, IdConvertType.MastodonId);
status.media_attachments = status.media_attachments.map((attachment) =>
convertAttachment(attachment),
);

View file

@ -1,17 +1,17 @@
import { apiAuthMastodon } from './endpoints/auth.js';
import { apiAccountMastodon } from './endpoints/account.js';
import { apiSearchMastodon } from './endpoints/search.js';
import { apiNotifyMastodon } from './endpoints/notifications.js';
import { apiFilterMastodon } from './endpoints/filter.js';
import { apiTimelineMastodon } from './endpoints/timeline.js';
import { apiStatusMastodon } from './endpoints/status.js';
import { ApiAuthMastodon } from './endpoints/auth.js';
import { ApiAccountMastodon } from './endpoints/account.js';
import { ApiSearchMastodon } from './endpoints/search.js';
import { ApiNotifyMastodon } from './endpoints/notifications.js';
import { ApiFilterMastodon } from './endpoints/filter.js';
import { ApiTimelineMastodon } from './endpoints/timeline.js';
import { ApiStatusMastodon } from './endpoints/status.js';
export {
apiAccountMastodon,
apiAuthMastodon,
apiSearchMastodon,
apiNotifyMastodon,
apiFilterMastodon,
apiTimelineMastodon,
apiStatusMastodon
}
ApiAccountMastodon,
ApiAuthMastodon,
ApiSearchMastodon,
ApiNotifyMastodon,
ApiFilterMastodon,
ApiTimelineMastodon,
ApiStatusMastodon,
};

View file

@ -1,7 +1,7 @@
import { convertId, IdConvertType as IdType, convertAccount, convertRelationship, convertStatus } from '../converters.js';
import { argsToBools, convertTimelinesArgsId, limitToInt } from './timeline.js';
import type { MegalodonInterface } from 'megalodon';
import type { FastifyRequest } from 'fastify';
import { argsToBools, convertTimelinesArgsId, limitToInt } from './timeline.js';
import { convertId, IdConvertType as IdType, convertAccount, convertRelationship, convertStatus } from '../converters.js';
const relationshipModel = {
id: '',
@ -20,7 +20,7 @@ const relationshipModel = {
note: '',
};
export class apiAccountMastodon {
export class ApiAccountMastodon {
private request: FastifyRequest;
private client: MegalodonInterface;
private BASE_URL: string;
@ -34,7 +34,7 @@ export class apiAccountMastodon {
public async verifyCredentials() {
try {
const data = await this.client.verifyAccountCredentials();
let acct = data.data;
const acct = data.data;
acct.id = convertId(acct.id, IdType.MastodonId);
acct.display_name = acct.display_name || acct.username;
acct.url = `${this.BASE_URL}/@${acct.url}`;
@ -82,13 +82,13 @@ export class apiAccountMastodon {
public async getRelationships(users: [string]) {
try {
relationshipModel.id = users?.toString() || '1';
relationshipModel.id = users.toString() || '1';
if (!users) {
if (!(users.length > 0)) {
return [relationshipModel];
}
let reqIds = [];
const reqIds = [];
for (let i = 0; i < users.length; i++) {
reqIds.push(convertId(users[i], IdType.SharkeyId));
}
@ -106,7 +106,7 @@ export class apiAccountMastodon {
try {
const data = await this.client.getAccountStatuses(
convertId((this.request.params as any).id, IdType.SharkeyId),
convertTimelinesArgsId(argsToBools(limitToInt(this.request.query as any)))
convertTimelinesArgsId(argsToBools(limitToInt(this.request.query as any))),
);
return data.data.map((status) => convertStatus(status));
} catch (e: any) {
@ -120,7 +120,7 @@ export class apiAccountMastodon {
try {
const data = await this.client.getAccountFollowers(
convertId((this.request.params as any).id, IdType.SharkeyId),
convertTimelinesArgsId(limitToInt(this.request.query as any))
convertTimelinesArgsId(limitToInt(this.request.query as any)),
);
return data.data.map((account) => convertAccount(account));
} catch (e: any) {
@ -134,7 +134,7 @@ export class apiAccountMastodon {
try {
const data = await this.client.getAccountFollowing(
convertId((this.request.params as any).id, IdType.SharkeyId),
convertTimelinesArgsId(limitToInt(this.request.query as any))
convertTimelinesArgsId(limitToInt(this.request.query as any)),
);
return data.data.map((account) => convertAccount(account));
} catch (e: any) {
@ -147,7 +147,7 @@ export class apiAccountMastodon {
public async addFollow() {
try {
const data = await this.client.followAccount( convertId((this.request.params as any).id, IdType.SharkeyId) );
let acct = convertRelationship(data.data);
const acct = convertRelationship(data.data);
acct.following = true;
return acct;
} catch (e: any) {
@ -160,7 +160,7 @@ export class apiAccountMastodon {
public async rmFollow() {
try {
const data = await this.client.unfollowAccount( convertId((this.request.params as any).id, IdType.SharkeyId) );
let acct = convertRelationship(data.data);
const acct = convertRelationship(data.data);
acct.following = false;
return acct;
} catch (e: any) {
@ -196,7 +196,7 @@ export class apiAccountMastodon {
try {
const data = await this.client.muteAccount(
convertId((this.request.params as any).id, IdType.SharkeyId),
this.request.body as any
this.request.body as any,
);
return convertRelationship(data.data);
} catch (e: any) {

View file

@ -39,7 +39,7 @@ const writeScope = [
'write:gallery-likes',
];
export async function apiAuthMastodon(request: FastifyRequest, client: MegalodonInterface) {
export async function ApiAuthMastodon(request: FastifyRequest, client: MegalodonInterface) {
const body: any = request.body || request.query;
try {
let scope = body.scopes;

View file

@ -1,8 +1,8 @@
import { IdConvertType as IdType, convertId, convertFilter } from '../converters.js';
import type { MegalodonInterface } from 'megalodon';
import type { FastifyRequest } from 'fastify';
import { IdConvertType as IdType, convertId, convertFilter } from '../converters.js';
export class apiFilterMastodon {
export class ApiFilterMastodon {
private request: FastifyRequest;
private client: MegalodonInterface;

View file

@ -16,7 +16,7 @@ export async function getInstance(
meta.description?.substring(0, 50) || 'See real server website',
description:
meta.description ||
"This is a vanilla Sharkey Instance. It doesn't seem to have a description.",
'This is a vanilla Sharkey Instance. It doesn\'t seem to have a description.',
email: response.email || '',
version: `3.0.0 (compatible; Sharkey ${config.version})`,
urls: response.urls,

View file

@ -1,14 +1,14 @@
import type { MegalodonInterface } from 'megalodon';
import type { FastifyRequest } from 'fastify';
import { convertTimelinesArgsId } from './timeline.js';
import { IdConvertType as IdType, convertId, convertNotification } from '../converters.js';
import { convertTimelinesArgsId } from './timeline.js';
import type { MegalodonInterface, Entity } from 'megalodon';
import type { FastifyRequest } from 'fastify';
function toLimitToInt(q: any) {
if (q.limit) if (typeof q.limit === 'string') q.limit = parseInt(q.limit, 10);
return q;
}
export class apiNotifyMastodon {
export class ApiNotifyMastodon {
private request: FastifyRequest;
private client: MegalodonInterface;
@ -21,13 +21,13 @@ export class apiNotifyMastodon {
try {
const data = await this.client.getNotifications( convertTimelinesArgsId(toLimitToInt(this.request.query)) );
const notifs = data.data;
const processed = notifs.map((n) => {
n = convertNotification(n);
if (n.type !== 'follow' && n.type !== 'follow_request') {
if (n.type === 'reaction') n.type = 'favourite';
return n;
const processed = notifs.map((n: Entity.Notification) => {
let convertedn = convertNotification(n);
if (convertedn.type !== 'follow' && convertedn.type !== 'follow_request') {
if (convertedn.type === 'reaction') convertedn.type = 'favourite';
return convertedn;
} else {
return n;
return convertedn;
}
});
return processed;

View file

@ -1,26 +1,25 @@
import type { MegalodonInterface } from 'megalodon';
import { Converter } from 'megalodon';
import type { FastifyRequest } from 'fastify';
import { convertTimelinesArgsId, limitToInt } from './timeline.js';
import { convertAccount, convertStatus } from '../converters.js';
import { convertTimelinesArgsId, limitToInt } from './timeline.js';
import type { MegalodonInterface } from 'megalodon';
import type { FastifyRequest } from 'fastify';
async function getHighlight(
BASE_URL: string,
domain: string,
accessTokens: string | undefined,
) {
const accessTokenArr = accessTokens?.split(" ") ?? [null];
const accessTokenArr = accessTokens?.split(' ') ?? [null];
const accessToken = accessTokenArr[accessTokenArr.length - 1];
try {
const apicall = await fetch(`${BASE_URL}/api/notes/featured`,
{
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
body: JSON.stringify({i: accessToken})
body: JSON.stringify({ i: accessToken }),
});
const api = await apicall.json();
const data: MisskeyEntity.Note[] = api;
@ -33,7 +32,7 @@ async function getHighlight(
}
async function getFeaturedUser( BASE_URL: string, host: string, accessTokens: string | undefined, limit: number ) {
const accessTokenArr = accessTokens?.split(" ") ?? [null];
const accessTokenArr = accessTokens?.split(' ') ?? [null];
const accessToken = accessTokenArr[accessTokenArr.length - 1];
try {
const apicall = await fetch(`${BASE_URL}/api/users`,
@ -41,15 +40,15 @@ async function getFeaturedUser( BASE_URL: string, host: string, accessTokens: st
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
body: JSON.stringify({i: accessToken, limit, origin: "local", sort: "+follower", state: "alive"})
body: JSON.stringify({ i: accessToken, limit, origin: 'local', sort: '+follower', state: 'alive' }),
});
const api = await apicall.json();
const data: MisskeyEntity.UserDetail[] = api;
return data.map((u) => {
return {
source: "past_interactions",
source: 'past_interactions',
account: Converter.userDetail(u, host),
};
});
@ -59,7 +58,7 @@ async function getFeaturedUser( BASE_URL: string, host: string, accessTokens: st
return [];
}
}
export class apiSearchMastodon {
export class ApiSearchMastodon {
private request: FastifyRequest;
private client: MegalodonInterface;
private BASE_URL: string;
@ -73,7 +72,7 @@ export class apiSearchMastodon {
public async SearchV1() {
try {
const query: any = convertTimelinesArgsId(limitToInt(this.request.query as any));
const type = query.type || "";
const type = query.type || '';
const data = await this.client.search(query.q, { type: type, ...query });
return data.data;
} catch (e: any) {
@ -86,13 +85,13 @@ export class apiSearchMastodon {
try {
const query: any = convertTimelinesArgsId(limitToInt(this.request.query as any));
const type = query.type;
const acct = !type || type === "accounts" ? await this.client.search(query.q, { type: "accounts", ...query }) : null;
const stat = !type || type === "statuses" ? await this.client.search(query.q, { type: "statuses", ...query }) : null;
const tags = !type || type === "hashtags" ? await this.client.search(query.q, { type: "hashtags", ...query }) : null;
const acct = !type || type === 'accounts' ? await this.client.search(query.q, { type: 'accounts', ...query }) : null;
const stat = !type || type === 'statuses' ? await this.client.search(query.q, { type: 'statuses', ...query }) : null;
const tags = !type || type === 'hashtags' ? await this.client.search(query.q, { type: 'hashtags', ...query }) : null;
const data = {
accounts: acct?.data.accounts.map((account) => convertAccount(account)) ?? [],
statuses: stat?.data.statuses.map((status) => convertStatus(status)) ?? [],
hashtags: tags?.data.hashtags ?? []
hashtags: tags?.data.hashtags ?? [],
};
return data;
} catch (e: any) {

View file

@ -1,27 +1,25 @@
import { convertId, IdConvertType as IdType, convertAccount, convertAttachment, convertPoll, convertStatus } from '../converters.js';
import querystring from 'querystring';
import type { Entity, MegalodonInterface } from 'megalodon';
import type { FastifyInstance } from 'fastify';
import { emojiRegexAtStartToEnd } from '@/misc/emoji-regex.js';
import { convertId, IdConvertType as IdType, convertAccount, convertAttachment, convertPoll, convertStatus } from '../converters.js';
import { getClient } from '../MastodonApiServerService.js';
import { convertTimelinesArgsId, limitToInt } from './timeline.js';
import { emojiRegexAtStartToEnd } from "@/misc/emoji-regex.js";
import { MetaService } from '@/core/MetaService.js';
import type { Entity } from 'megalodon';
import type { FastifyInstance } from 'fastify';
function normalizeQuery(data: any) {
const str = querystring.stringify(data);
return querystring.parse(str);
}
export class apiStatusMastodon {
export class ApiStatusMastodon {
private fastify: FastifyInstance;
private metaService: MetaService;
constructor(fastify: FastifyInstance) {
this.fastify = fastify;
}
public async getStatus() {
this.fastify.get<{ Params: { id: string } }>("/v1/statuses/:id", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -36,7 +34,7 @@ export class apiStatusMastodon {
}
public async getContext() {
this.fastify.get<{ Params: { id: string } }>("/v1/statuses/:id/context", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/context', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -44,7 +42,7 @@ export class apiStatusMastodon {
try {
const data = await client.getStatusContext(
convertId(_request.params.id, IdType.SharkeyId),
convertTimelinesArgsId(limitToInt(query))
convertTimelinesArgsId(limitToInt(query)),
);
data.data.ancestors = data.data.ancestors.map((status: Entity.Status) => convertStatus(status));
data.data.descendants = data.data.descendants.map((status: Entity.Status) => convertStatus(status));
@ -57,7 +55,7 @@ export class apiStatusMastodon {
}
public async getHistory() {
this.fastify.get<{ Params: { id: string } }>("/v1/statuses/:id/history", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/history', async (_request, reply) => {
try {
reply.code(401).send({ message: 'Not Implemented' });
} catch (e: any) {
@ -68,7 +66,7 @@ export class apiStatusMastodon {
}
public async getReblogged() {
this.fastify.get<{ Params: { id: string } }>("/v1/statuses/:id/reblogged_by", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/reblogged_by', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -83,7 +81,7 @@ export class apiStatusMastodon {
}
public async getFavourites() {
this.fastify.get<{ Params: { id: string } }>("/v1/statuses/:id/favourited_by", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/favourited_by', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -98,7 +96,7 @@ export class apiStatusMastodon {
}
public async getMedia() {
this.fastify.get<{ Params: { id: string } }>("/v1/media/:id", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/media/:id', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -113,7 +111,7 @@ export class apiStatusMastodon {
}
public async getPoll() {
this.fastify.get<{ Params: { id: string } }>("/v1/polls/:id", async (_request, reply) => {
this.fastify.get<{ Params: { id: string } }>('/v1/polls/:id', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -128,7 +126,7 @@ export class apiStatusMastodon {
}
public async votePoll() {
this.fastify.post<{ Params: { id: string } }>("/v1/polls/:id/votes", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/polls/:id/votes', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -144,24 +142,22 @@ export class apiStatusMastodon {
}
public async postStatus() {
this.fastify.post("/v1/statuses", async (_request, reply) => {
this.fastify.post('/v1/statuses', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
let body: any = _request.body;
try {
if (body.in_reply_to_id)
body.in_reply_to_id = convertId(body.in_reply_to_id, IdType.SharkeyId);
if (body.quote_id)
body.quote_id = convertId(body.quote_id, IdType.SharkeyId);
if (body.in_reply_to_id) body.in_reply_to_id = convertId(body.in_reply_to_id, IdType.SharkeyId);
if (body.quote_id) body.quote_id = convertId(body.quote_id, IdType.SharkeyId);
if (
(!body.poll && body["poll[options][]"]) ||
(!body.media_ids && body["media_ids[]"])
(!body.poll && body['poll[options][]']) ||
(!body.media_ids && body['media_ids[]'])
) {
body = normalizeQuery(body);
}
const text = body.status;
const removed = text.replace(/@\S+/g, "").replace(/\s|/g, "");
const removed = text.replace(/@\S+/g, '').replace(/\s|/g, '');
const isDefaultEmoji = emojiRegexAtStartToEnd.test(removed);
const isCustomEmoji = /^:[a-zA-Z0-9@_]+:$/.test(removed);
if ((body.in_reply_to_id && isDefaultEmoji) || isCustomEmoji) {
@ -171,7 +167,7 @@ export class apiStatusMastodon {
);
reply.send(a.data);
}
if (body.in_reply_to_id && removed === "/unreact") {
if (body.in_reply_to_id && removed === '/unreact') {
try {
const id = body.in_reply_to_id;
const post = await client.getStatus(id);
@ -186,28 +182,25 @@ export class apiStatusMastodon {
if (!body.media_ids) body.media_ids = undefined;
if (body.media_ids && !body.media_ids.length) body.media_ids = undefined;
if (body.media_ids) {
body.media_ids = (body.media_ids as string[]).map((p) =>convertId(p, IdType.SharkeyId));
body.media_ids = (body.media_ids as string[]).map((p) => convertId(p, IdType.SharkeyId));
}
const { sensitive } = body;
body.sensitive = typeof sensitive === "string" ? sensitive === "true" : sensitive;
body.sensitive = typeof sensitive === 'string' ? sensitive === 'true' : sensitive;
if (body.poll) {
if (
body.poll.expires_in != null &&
typeof body.poll.expires_in === "string"
)
body.poll.expires_in = parseInt(body.poll.expires_in);
typeof body.poll.expires_in === 'string'
) body.poll.expires_in = parseInt(body.poll.expires_in);
if (
body.poll.multiple != null &&
typeof body.poll.multiple === "string"
)
body.poll.multiple = body.poll.multiple == "true";
typeof body.poll.multiple === 'string'
) body.poll.multiple = body.poll.multiple === 'true';
if (
body.poll.hide_totals != null &&
typeof body.poll.hide_totals === "string"
)
body.poll.hide_totals = body.poll.hide_totals == "true";
typeof body.poll.hide_totals === 'string'
) body.poll.hide_totals = body.poll.hide_totals === 'true';
}
const data = await client.postStatus(text, body);
@ -220,14 +213,14 @@ export class apiStatusMastodon {
}
public async addFavourite() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/favourite", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/favourite', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const data = (await client.createEmojiReaction(
convertId(_request.params.id, IdType.SharkeyId),
'⭐'
'⭐',
)) as any;
reply.send(convertStatus(data.data));
} catch (e: any) {
@ -238,14 +231,14 @@ export class apiStatusMastodon {
}
public async rmFavourite() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/unfavourite", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/unfavourite', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const data = await client.deleteEmojiReaction(
convertId(_request.params.id, IdType.SharkeyId),
'⭐'
'⭐',
);
reply.send(convertStatus(data.data));
} catch (e: any) {
@ -256,7 +249,7 @@ export class apiStatusMastodon {
}
public async reblogStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/reblog", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/reblog', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -271,7 +264,7 @@ export class apiStatusMastodon {
}
public async unreblogStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/unreblog", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/unreblog', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -286,7 +279,7 @@ export class apiStatusMastodon {
}
public async bookmarkStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/bookmark", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/bookmark', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -301,7 +294,7 @@ export class apiStatusMastodon {
}
public async unbookmarkStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/unbookmark", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/unbookmark', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -316,7 +309,7 @@ export class apiStatusMastodon {
}
public async pinStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/pin", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/pin', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -331,7 +324,7 @@ export class apiStatusMastodon {
}
public async unpinStatus() {
this.fastify.post<{ Params: { id: string } }>("/v1/statuses/:id/unpin", async (_request, reply) => {
this.fastify.post<{ Params: { id: string } }>('/v1/statuses/:id/unpin', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -346,7 +339,7 @@ export class apiStatusMastodon {
}
public async reactStatus() {
this.fastify.post<{ Params: { id: string, name: string } }>("/v1/statuses/:id/react/:name", async (_request, reply) => {
this.fastify.post<{ Params: { id: string, name: string } }>('/v1/statuses/:id/react/:name', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -361,7 +354,7 @@ export class apiStatusMastodon {
}
public async unreactStatus() {
this.fastify.post<{ Params: { id: string, name: string } }>("/v1/statuses/:id/unreact/:name", async (_request, reply) => {
this.fastify.post<{ Params: { id: string, name: string } }>('/v1/statuses/:id/unreact/:name', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -376,7 +369,7 @@ export class apiStatusMastodon {
}
public async updateMedia() {
this.fastify.put<{ Params: { id: string } }>("/v1/media/:id", async (_request, reply) => {
this.fastify.put<{ Params: { id: string } }>('/v1/media/:id', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
@ -391,7 +384,7 @@ export class apiStatusMastodon {
}
public async deleteStatus() {
this.fastify.delete<{ Params: { id: string } }>("/v1/statuses/:id", async (_request, reply) => {
this.fastify.delete<{ Params: { id: string } }>('/v1/statuses/:id', async (_request, reply) => {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
const accessTokens = _request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);

View file

@ -1,15 +1,13 @@
import { convertId, IdConvertType as IdType, convertAccount, convertConversation, convertList, convertStatus } from '../converters.js';
import { ParsedUrlQuery } from 'querystring';
import type { Entity, MegalodonInterface } from 'megalodon';
import type { FastifyInstance } from 'fastify';
import { convertId, IdConvertType as IdType, convertAccount, convertConversation, convertList, convertStatus } from '../converters.js';
import { getClient } from '../MastodonApiServerService.js';
import type { Entity } from 'megalodon';
import type { FastifyInstance } from 'fastify';
export function limitToInt(q: ParsedUrlQuery) {
let object: any = q;
if (q.limit)
if (typeof q.limit === 'string') object.limit = parseInt(q.limit, 10);
if (q.offset)
if (typeof q.offset === 'string') object.offset = parseInt(q.offset, 10);
const object: any = q;
if (q.limit) if (typeof q.limit === 'string') object.limit = parseInt(q.limit, 10);
if (q.offset) if (typeof q.offset === 'string') object.offset = parseInt(q.offset, 10);
return object;
}
@ -22,55 +20,23 @@ export function argsToBools(q: ParsedUrlQuery) {
// - https://docs.joinmastodon.org/methods/accounts/#statuses
// - https://docs.joinmastodon.org/methods/timelines/#public
// - https://docs.joinmastodon.org/methods/timelines/#tag
let object: any = q;
if (q.only_media)
if (typeof q.only_media === 'string')
object.only_media = toBoolean(q.only_media);
if (q.exclude_replies)
if (typeof q.exclude_replies === 'string')
object.exclude_replies = toBoolean(q.exclude_replies);
if (q.exclude_reblogs)
if (typeof q.exclude_reblogs === 'string')
object.exclude_reblogs = toBoolean(q.exclude_reblogs);
if (q.pinned)
if (typeof q.pinned === 'string') object.pinned = toBoolean(q.pinned);
if (q.local)
if (typeof q.local === 'string') object.local = toBoolean(q.local);
const object: any = q;
if (q.only_media) if (typeof q.only_media === 'string') object.only_media = toBoolean(q.only_media);
if (q.exclude_replies) if (typeof q.exclude_replies === 'string') object.exclude_replies = toBoolean(q.exclude_replies);
if (q.exclude_reblogs) if (typeof q.exclude_reblogs === 'string') object.exclude_reblogs = toBoolean(q.exclude_reblogs);
if (q.pinned) if (typeof q.pinned === 'string') object.pinned = toBoolean(q.pinned);
if (q.local) if (typeof q.local === 'string') object.local = toBoolean(q.local);
return q;
}
export function convertTimelinesArgsId(q: ParsedUrlQuery) {
if (typeof q.min_id === 'string')
q.min_id = convertId(q.min_id, IdType.SharkeyId);
if (typeof q.max_id === 'string')
q.max_id = convertId(q.max_id, IdType.SharkeyId);
if (typeof q.since_id === 'string')
q.since_id = convertId(q.since_id, IdType.SharkeyId);
if (typeof q.min_id === 'string') q.min_id = convertId(q.min_id, IdType.SharkeyId);
if (typeof q.max_id === 'string') q.max_id = convertId(q.max_id, IdType.SharkeyId);
if (typeof q.since_id === 'string') q.since_id = convertId(q.since_id, IdType.SharkeyId);
return q;
}
function escapeHTML(str: string) {
if (!str) {
return '';
}
return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&quot;')
.replace(/'/g, '&#039;');
}
function nl2br(str: string) {
if (!str) {
return '';
}
str = str.replace(/\r\n/g, '<br />');
str = str.replace(/(\n|\r)/g, '<br />');
return str;
}
export class apiTimelineMastodon {
export class ApiTimelineMastodon {
private fastify: FastifyInstance;
constructor(fastify: FastifyInstance) {
@ -166,7 +132,7 @@ export class apiTimelineMastodon {
});
}
public async getList(){
public async getList() {
this.fastify.get<{ Params: { id: string } }>('/v1/lists/:id', async (_request, reply) => {
try {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
@ -199,7 +165,7 @@ export class apiTimelineMastodon {
});
}
public async getListAccounts(){
public async getListAccounts() {
this.fastify.get<{ Params: { id: string } }>('/v1/lists/:id/accounts', async (_request, reply) => {
try {
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
@ -209,7 +175,7 @@ export class apiTimelineMastodon {
const query: any = _request.query;
const data = await client.getAccountsInList(
convertId(params.id, IdType.SharkeyId),
convertTimelinesArgsId(query)
convertTimelinesArgsId(query),
);
reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
} catch (e: any) {
@ -230,7 +196,7 @@ export class apiTimelineMastodon {
const query: any = _request.query;
const data = await client.addAccountsToList(
convertId(params.id, IdType.SharkeyId),
(query.accounts_id as string[]).map((id) => convertId(id, IdType.SharkeyId))
(query.accounts_id as string[]).map((id) => convertId(id, IdType.SharkeyId)),
);
reply.send(data.data);
} catch (e: any) {
@ -251,7 +217,7 @@ export class apiTimelineMastodon {
const query: any = _request.query;
const data = await client.deleteAccountsFromList(
convertId(params.id, IdType.SharkeyId),
(query.accounts_id as string[]).map((id) => convertId(id, IdType.SharkeyId))
(query.accounts_id as string[]).map((id) => convertId(id, IdType.SharkeyId)),
);
reply.send(data.data);
} catch (e: any) {
@ -313,5 +279,4 @@ export class apiTimelineMastodon {
}
});
}
}