fix lint
This commit is contained in:
		
							parent
							
								
									0abe2dfee0
								
							
						
					
					
						commit
						c69b72e199
					
				
					 573 changed files with 3318 additions and 3318 deletions
				
			
		| 
						 | 
				
			
			@ -28,7 +28,7 @@ export async function parseAudience(actor: IRemoteUser, to?: ApObject, cc?: ApOb
 | 
			
		|||
		return {
 | 
			
		||||
			visibility: 'public',
 | 
			
		||||
			mentionedUsers,
 | 
			
		||||
			visibleUsers: []
 | 
			
		||||
			visibleUsers: [],
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ export async function parseAudience(actor: IRemoteUser, to?: ApObject, cc?: ApOb
 | 
			
		|||
		return {
 | 
			
		||||
			visibility: 'home',
 | 
			
		||||
			mentionedUsers,
 | 
			
		||||
			visibleUsers: []
 | 
			
		||||
			visibleUsers: [],
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -44,14 +44,14 @@ export async function parseAudience(actor: IRemoteUser, to?: ApObject, cc?: ApOb
 | 
			
		|||
		return {
 | 
			
		||||
			visibility: 'followers',
 | 
			
		||||
			mentionedUsers,
 | 
			
		||||
			visibleUsers: []
 | 
			
		||||
			visibleUsers: [],
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return {
 | 
			
		||||
		visibility: 'specified',
 | 
			
		||||
		mentionedUsers,
 | 
			
		||||
		visibleUsers: mentionedUsers
 | 
			
		||||
		visibleUsers: mentionedUsers,
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,13 +20,13 @@ export default class DbResolver {
 | 
			
		|||
 | 
			
		||||
		if (parsed.id) {
 | 
			
		||||
			return (await Notes.findOne({
 | 
			
		||||
				id: parsed.id
 | 
			
		||||
				id: parsed.id,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (parsed.uri) {
 | 
			
		||||
			return (await Notes.findOne({
 | 
			
		||||
				uri: parsed.uri
 | 
			
		||||
				uri: parsed.uri,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -38,13 +38,13 @@ export default class DbResolver {
 | 
			
		|||
 | 
			
		||||
		if (parsed.id) {
 | 
			
		||||
			return (await MessagingMessages.findOne({
 | 
			
		||||
				id: parsed.id
 | 
			
		||||
				id: parsed.id,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (parsed.uri) {
 | 
			
		||||
			return (await MessagingMessages.findOne({
 | 
			
		||||
				uri: parsed.uri
 | 
			
		||||
				uri: parsed.uri,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -59,13 +59,13 @@ export default class DbResolver {
 | 
			
		|||
 | 
			
		||||
		if (parsed.id) {
 | 
			
		||||
			return (await Users.findOne({
 | 
			
		||||
				id: parsed.id
 | 
			
		||||
				id: parsed.id,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (parsed.uri) {
 | 
			
		||||
			return (await Users.findOne({
 | 
			
		||||
				uri: parsed.uri
 | 
			
		||||
				uri: parsed.uri,
 | 
			
		||||
			})) || null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ export default class DbResolver {
 | 
			
		|||
	 */
 | 
			
		||||
	public async getAuthUserFromKeyId(keyId: string): Promise<AuthUser | null> {
 | 
			
		||||
		const key = await UserPublickeys.findOne({
 | 
			
		||||
			keyId
 | 
			
		||||
			keyId,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if (key == null) return null;
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ export default class DbResolver {
 | 
			
		|||
 | 
			
		||||
		return {
 | 
			
		||||
			user,
 | 
			
		||||
			key
 | 
			
		||||
			key,
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ export default class DbResolver {
 | 
			
		|||
 | 
			
		||||
		return {
 | 
			
		||||
			user,
 | 
			
		||||
			key
 | 
			
		||||
			key,
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -115,11 +115,11 @@ export default class DbResolver {
 | 
			
		|||
		if (matchLocal) {
 | 
			
		||||
			return {
 | 
			
		||||
				type: matchLocal[1],
 | 
			
		||||
				id: matchLocal[2]
 | 
			
		||||
				id: matchLocal[2],
 | 
			
		||||
			};
 | 
			
		||||
		} else {
 | 
			
		||||
			return {
 | 
			
		||||
				uri
 | 
			
		||||
				uri,
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ export default class DeliverManager {
 | 
			
		|||
	 */
 | 
			
		||||
	public addFollowersRecipe() {
 | 
			
		||||
		const deliver = {
 | 
			
		||||
			type: 'Followers'
 | 
			
		||||
			type: 'Followers',
 | 
			
		||||
		} as IFollowersRecipe;
 | 
			
		||||
 | 
			
		||||
		this.addRecipe(deliver);
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ export default class DeliverManager {
 | 
			
		|||
	public addDirectRecipe(to: IRemoteUser) {
 | 
			
		||||
		const recipe = {
 | 
			
		||||
			type: 'Direct',
 | 
			
		||||
			to
 | 
			
		||||
			to,
 | 
			
		||||
		} as IDirectRecipe;
 | 
			
		||||
 | 
			
		||||
		this.addRecipe(recipe);
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,7 @@ export default class DeliverManager {
 | 
			
		|||
			if (isFollowers(recipe)) {
 | 
			
		||||
				// followers deliver
 | 
			
		||||
				const followers = await Followings.find({
 | 
			
		||||
					followeeId: this.actor.id
 | 
			
		||||
					followeeId: this.actor.id,
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				for (const following of followers) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
 | 
			
		|||
			renote,
 | 
			
		||||
			visibility: activityAudience.visibility,
 | 
			
		||||
			visibleUsers: activityAudience.visibleUsers,
 | 
			
		||||
			uri
 | 
			
		||||
			uri,
 | 
			
		||||
		});
 | 
			
		||||
	} finally {
 | 
			
		||||
		unlock();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ export default async (actor: IRemoteUser, activity: IFlag): Promise<string> => {
 | 
			
		|||
 | 
			
		||||
	const userIds = uris.filter(uri => uri.startsWith(config.url + '/users/')).map(uri => uri.split('/').pop());
 | 
			
		||||
	const users = await Users.find({
 | 
			
		||||
		id: In(userIds)
 | 
			
		||||
		id: In(userIds),
 | 
			
		||||
	});
 | 
			
		||||
	if (users.length < 1) return `skip`;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ export default async (actor: IRemoteUser, activity: IFlag): Promise<string> => {
 | 
			
		|||
		targetUserHost: users[0].host,
 | 
			
		||||
		reporterId: actor.id,
 | 
			
		||||
		reporterHost: actor.host,
 | 
			
		||||
		comment: `${activity.content}\n${JSON.stringify(uris, null, 2)}`
 | 
			
		||||
		comment: `${activity.content}\n${JSON.stringify(uris, null, 2)}`,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return `ok`;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ export default async (actor: IRemoteUser, activity: IAccept): Promise<string> =>
 | 
			
		|||
 | 
			
		||||
	const following = await Followings.findOne({
 | 
			
		||||
		followerId: follower.id,
 | 
			
		||||
		followeeId: actor.id
 | 
			
		||||
		followeeId: actor.id,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (following) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ export const undoAnnounce = async (actor: IRemoteUser, activity: IAnnounce): Pro
 | 
			
		|||
	const uri = getApId(activity);
 | 
			
		||||
 | 
			
		||||
	const note = await Notes.findOne({
 | 
			
		||||
		uri
 | 
			
		||||
		uri,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (!note) return 'skip: no such Announce';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,12 +19,12 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<string> =>
 | 
			
		|||
 | 
			
		||||
	const req = await FollowRequests.findOne({
 | 
			
		||||
		followerId: actor.id,
 | 
			
		||||
		followeeId: followee.id
 | 
			
		||||
		followeeId: followee.id,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	const following = await Followings.findOne({
 | 
			
		||||
		followerId: actor.id,
 | 
			
		||||
		followeeId: followee.id
 | 
			
		||||
		followeeId: followee.id,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (req) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ export class LdSignature {
 | 
			
		|||
			creator,
 | 
			
		||||
			domain,
 | 
			
		||||
			nonce: crypto.randomBytes(16).toString('hex'),
 | 
			
		||||
			created: (created || new Date()).toISOString()
 | 
			
		||||
			created: (created || new Date()).toISOString(),
 | 
			
		||||
		} as {
 | 
			
		||||
			type: string;
 | 
			
		||||
			creator: string;
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +45,8 @@ export class LdSignature {
 | 
			
		|||
			...data,
 | 
			
		||||
			signature: {
 | 
			
		||||
				...options,
 | 
			
		||||
				signatureValue: signature.toString('base64')
 | 
			
		||||
			}
 | 
			
		||||
				signatureValue: signature.toString('base64'),
 | 
			
		||||
			},
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ export class LdSignature {
 | 
			
		|||
	public async createVerifyData(data: any, options: any) {
 | 
			
		||||
		const transformedOptions = {
 | 
			
		||||
			...options,
 | 
			
		||||
			'@context': 'https://w3id.org/identity/v1'
 | 
			
		||||
			'@context': 'https://w3id.org/identity/v1',
 | 
			
		||||
		};
 | 
			
		||||
		delete transformedOptions['type'];
 | 
			
		||||
		delete transformedOptions['id'];
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ export class LdSignature {
 | 
			
		|||
	public async normalize(data: any) {
 | 
			
		||||
		const customLoader = this.getLoader();
 | 
			
		||||
		return await jsonld.normalize(data, {
 | 
			
		||||
			documentLoader: customLoader
 | 
			
		||||
			documentLoader: customLoader,
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ export class LdSignature {
 | 
			
		|||
					return {
 | 
			
		||||
						contextUrl: null,
 | 
			
		||||
						document: CONTEXTS[url],
 | 
			
		||||
						documentUrl: url
 | 
			
		||||
						documentUrl: url,
 | 
			
		||||
					};
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ export class LdSignature {
 | 
			
		|||
			return {
 | 
			
		||||
				contextUrl: null,
 | 
			
		||||
				document: document,
 | 
			
		||||
				documentUrl: url
 | 
			
		||||
				documentUrl: url,
 | 
			
		||||
			};
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ export async function createImage(actor: IRemoteUser, value: any): Promise<Drive
 | 
			
		|||
		if (file.url !== image.url) {
 | 
			
		||||
			await DriveFiles.update({ id: file.id }, {
 | 
			
		||||
				url: image.url,
 | 
			
		||||
				uri: image.url
 | 
			
		||||
				uri: image.url,
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
			file = await DriveFiles.findOneOrFail(file.id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,10 +75,10 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
 | 
			
		|||
	if (err) {
 | 
			
		||||
		logger.error(`${err.message}`, {
 | 
			
		||||
			resolver: {
 | 
			
		||||
				history: resolver.getHistory()
 | 
			
		||||
				history: resolver.getHistory(),
 | 
			
		||||
			},
 | 
			
		||||
			value: value,
 | 
			
		||||
			object: object
 | 
			
		||||
			object: object,
 | 
			
		||||
		});
 | 
			
		||||
		throw new Error('invalid note');
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -169,16 +169,16 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
 | 
			
		|||
				if (res) {
 | 
			
		||||
					return {
 | 
			
		||||
						status: 'ok',
 | 
			
		||||
						res
 | 
			
		||||
						res,
 | 
			
		||||
					};
 | 
			
		||||
				} else {
 | 
			
		||||
					return {
 | 
			
		||||
						status: 'permerror'
 | 
			
		||||
						status: 'permerror',
 | 
			
		||||
					};
 | 
			
		||||
				}
 | 
			
		||||
			} catch (e) {
 | 
			
		||||
				return {
 | 
			
		||||
					status: (e instanceof StatusError && e.isClientError) ? 'permerror' : 'temperror'
 | 
			
		||||
					status: (e instanceof StatusError && e.isClientError) ? 'permerror' : 'temperror',
 | 
			
		||||
				};
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
| 
						 | 
				
			
			@ -313,7 +313,7 @@ export async function extractEmojis(tags: IObject | IObject[], host: string): Pr
 | 
			
		|||
 | 
			
		||||
		const exists = await Emojis.findOne({
 | 
			
		||||
			host,
 | 
			
		||||
			name
 | 
			
		||||
			name,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if (exists) {
 | 
			
		||||
| 
						 | 
				
			
			@ -333,7 +333,7 @@ export async function extractEmojis(tags: IObject | IObject[], host: string): Pr
 | 
			
		|||
 | 
			
		||||
				return await Emojis.findOne({
 | 
			
		||||
					host,
 | 
			
		||||
					name
 | 
			
		||||
					name,
 | 
			
		||||
				}) as Emoji;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -349,7 +349,7 @@ export async function extractEmojis(tags: IObject | IObject[], host: string): Pr
 | 
			
		|||
			uri: tag.id,
 | 
			
		||||
			url: tag.icon!.url,
 | 
			
		||||
			updatedAt: new Date(),
 | 
			
		||||
			aliases: []
 | 
			
		||||
			aliases: [],
 | 
			
		||||
		} as Partial<Emoji>);
 | 
			
		||||
	}));
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -238,7 +238,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
 | 
			
		|||
		avatarUrl,
 | 
			
		||||
		bannerUrl,
 | 
			
		||||
		avatarBlurhash,
 | 
			
		||||
		bannerBlurhash
 | 
			
		||||
		bannerBlurhash,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	user!.avatarId = avatarId;
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +407,7 @@ const services: {
 | 
			
		|||
	} = {
 | 
			
		||||
	'misskey:authentication:twitter': (userId, screenName) => ({ userId, screenName }),
 | 
			
		||||
	'misskey:authentication:github': (id, login) => ({ id, login }),
 | 
			
		||||
	'misskey:authentication:discord': (id, name) => $discord(id, name)
 | 
			
		||||
	'misskey:authentication:discord': (id, name) => $discord(id, name),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const $discord = (id: string, name: string) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import config from '@/config/index';
 | 
			
		||||
import Resolver from '../resolver';
 | 
			
		||||
import { IObject, IQuestion, isQuestion,  } from '../type';
 | 
			
		||||
import { IObject, IQuestion, isQuestion  } from '../type';
 | 
			
		||||
import { apLogger } from '../logger';
 | 
			
		||||
import { Notes, Polls } from '@/models/index';
 | 
			
		||||
import { IPoll } from '@/models/entities/poll';
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ export async function extractPollFromQuestion(source: string | IObject, resolver
 | 
			
		|||
		choices,
 | 
			
		||||
		votes,
 | 
			
		||||
		multiple,
 | 
			
		||||
		expiresAt
 | 
			
		||||
		expiresAt,
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ export async function updateQuestion(value: any) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	await Polls.update({ noteId: note.id }, {
 | 
			
		||||
		votes: poll.votes
 | 
			
		||||
		votes: poll.votes,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return changed;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,5 +4,5 @@ import { User } from '@/models/entities/user';
 | 
			
		|||
export default (object: any, user: { id: User['id']; host: null }) => ({
 | 
			
		||||
	type: 'Accept',
 | 
			
		||||
	actor: `${config.url}/users/${user.id}`,
 | 
			
		||||
	object
 | 
			
		||||
	object,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,5 +5,5 @@ export default (user: ILocalUser, target: any, object: any) => ({
 | 
			
		|||
	type: 'Add',
 | 
			
		||||
	actor: `${config.url}/users/${user.id}`,
 | 
			
		||||
	target,
 | 
			
		||||
	object
 | 
			
		||||
	object,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,6 @@ export default (object: any, note: Note) => {
 | 
			
		|||
		published: note.createdAt.toISOString(),
 | 
			
		||||
		to,
 | 
			
		||||
		cc,
 | 
			
		||||
		object
 | 
			
		||||
		object,
 | 
			
		||||
	};
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,5 +4,5 @@ import { ILocalUser, IRemoteUser } from '@/models/entities/user';
 | 
			
		|||
export default (blocker: ILocalUser, blockee: IRemoteUser) => ({
 | 
			
		||||
	type: 'Block',
 | 
			
		||||
	actor: `${config.url}/users/${blocker.id}`,
 | 
			
		||||
	object: blockee.uri
 | 
			
		||||
	object: blockee.uri,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ export default (object: any, note: Note) => {
 | 
			
		|||
		actor: `${config.url}/users/${note.userId}`,
 | 
			
		||||
		type: 'Create',
 | 
			
		||||
		published: note.createdAt.toISOString(),
 | 
			
		||||
		object
 | 
			
		||||
		object,
 | 
			
		||||
	} as any;
 | 
			
		||||
 | 
			
		||||
	if (object.to) activity.to = object.to;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,6 @@ export default (emoji: Emoji) => ({
 | 
			
		|||
	icon: {
 | 
			
		||||
		type: 'Image',
 | 
			
		||||
		mediaType: emoji.type || 'image/png',
 | 
			
		||||
		url: emoji.url
 | 
			
		||||
	}
 | 
			
		||||
		url: emoji.url,
 | 
			
		||||
	},
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ export function renderFollowRelay(relay: Relay, relayActor: ILocalUser) {
 | 
			
		|||
		id: `${config.url}/activities/follow-relay/${relay.id}`,
 | 
			
		||||
		type: 'Follow',
 | 
			
		||||
		actor: `${config.url}/users/${relayActor.id}`,
 | 
			
		||||
		object: 'https://www.w3.org/ns/activitystreams#Public'
 | 
			
		||||
		object: 'https://www.w3.org/ns/activitystreams#Public',
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return follow;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ export default (follower: { id: User['id']; host: User['host']; uri: User['host'
 | 
			
		|||
	const follow = {
 | 
			
		||||
		type: 'Follow',
 | 
			
		||||
		actor: Users.isLocalUser(follower) ? `${config.url}/users/${follower.id}` : follower.uri,
 | 
			
		||||
		object: Users.isLocalUser(followee) ? `${config.url}/users/${followee.id}` : followee.uri
 | 
			
		||||
		object: Users.isLocalUser(followee) ? `${config.url}/users/${followee.id}` : followee.uri,
 | 
			
		||||
	} as any;
 | 
			
		||||
 | 
			
		||||
	if (requestId) follow.id = requestId;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,5 +3,5 @@ import config from '@/config/index';
 | 
			
		|||
export default (tag: string) => ({
 | 
			
		||||
	type: 'Hashtag',
 | 
			
		||||
	href: `${config.url}/tags/${encodeURIComponent(tag)}`,
 | 
			
		||||
	name: `#${tag}`
 | 
			
		||||
	name: `#${tag}`,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,5 +5,5 @@ export default (file: DriveFile) => ({
 | 
			
		|||
	type: 'Image',
 | 
			
		||||
	url: DriveFiles.getPublicUrl(file),
 | 
			
		||||
	sensitive: file.isSensitive,
 | 
			
		||||
	name: file.comment
 | 
			
		||||
	name: file.comment,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,8 +41,8 @@ export const renderActivity = (x: any): IActivity | null => {
 | 
			
		|||
				'isCat': 'misskey:isCat',
 | 
			
		||||
				// vcard
 | 
			
		||||
				vcard: 'http://www.w3.org/2006/vcard/ns#',
 | 
			
		||||
			}
 | 
			
		||||
		]
 | 
			
		||||
			},
 | 
			
		||||
		],
 | 
			
		||||
	}, x);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,6 @@ export default (user: ILocalUser, key: UserKeypair, postfix?: string) => ({
 | 
			
		|||
	owner: `${config.url}/users/${user.id}`,
 | 
			
		||||
	publicKeyPem: createPublicKey(key.publicKey).export({
 | 
			
		||||
		type: 'spki',
 | 
			
		||||
		format: 'pem'
 | 
			
		||||
	})
 | 
			
		||||
		format: 'pem',
 | 
			
		||||
	}),
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,14 +13,14 @@ export const renderLike = async (noteReaction: NoteReaction, note: Note) => {
 | 
			
		|||
		actor: `${config.url}/users/${noteReaction.userId}`,
 | 
			
		||||
		object: note.uri ? note.uri : `${config.url}/notes/${noteReaction.noteId}`,
 | 
			
		||||
		content: reaction,
 | 
			
		||||
		_misskey_reaction: reaction
 | 
			
		||||
		_misskey_reaction: reaction,
 | 
			
		||||
	} as any;
 | 
			
		||||
 | 
			
		||||
	if (reaction.startsWith(':')) {
 | 
			
		||||
		const name = reaction.replace(/:/g, '');
 | 
			
		||||
		const emoji = await Emojis.findOne({
 | 
			
		||||
			name,
 | 
			
		||||
			host: null
 | 
			
		||||
			host: null,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if (emoji) object.tag = [ renderEmoji(emoji) ];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	const mentionedUsers = note.mentions.length > 0 ? await Users.find({
 | 
			
		||||
		id: In(note.mentions)
 | 
			
		||||
		id: In(note.mentions),
 | 
			
		||||
	}) : [];
 | 
			
		||||
 | 
			
		||||
	const hashtagTags = (note.tags || []).map(tag => renderHashtag(tag));
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
 | 
			
		|||
	const summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw;
 | 
			
		||||
 | 
			
		||||
	const content = toHtml(Object.assign({}, note, {
 | 
			
		||||
		text: apText
 | 
			
		||||
		text: apText,
 | 
			
		||||
	}));
 | 
			
		||||
 | 
			
		||||
	const emojis = await getEmojis(note.emojis);
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
 | 
			
		|||
	const asPoll = poll ? {
 | 
			
		||||
		type: 'Question',
 | 
			
		||||
		content: toHtml(Object.assign({}, note, {
 | 
			
		||||
			text: text
 | 
			
		||||
			text: text,
 | 
			
		||||
		})),
 | 
			
		||||
		[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
 | 
			
		||||
		[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
 | 
			
		||||
| 
						 | 
				
			
			@ -124,13 +124,13 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
 | 
			
		|||
			name: text,
 | 
			
		||||
			replies: {
 | 
			
		||||
				type: 'Collection',
 | 
			
		||||
				totalItems: poll!.votes[i]
 | 
			
		||||
			}
 | 
			
		||||
		}))
 | 
			
		||||
				totalItems: poll!.votes[i],
 | 
			
		||||
			},
 | 
			
		||||
		})),
 | 
			
		||||
	} : {};
 | 
			
		||||
 | 
			
		||||
	const asTalk = isTalk ? {
 | 
			
		||||
		_misskey_talk: true
 | 
			
		||||
		_misskey_talk: true,
 | 
			
		||||
	} : {};
 | 
			
		||||
 | 
			
		||||
	return {
 | 
			
		||||
| 
						 | 
				
			
			@ -150,7 +150,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
 | 
			
		|||
		sensitive: note.cw != null || files.some(file => file.isSensitive),
 | 
			
		||||
		tag,
 | 
			
		||||
		...asPoll,
 | 
			
		||||
		...asTalk
 | 
			
		||||
		...asTalk,
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +160,7 @@ export async function getEmojis(names: string[]): Promise<Emoji[]> {
 | 
			
		|||
	const emojis = await Promise.all(
 | 
			
		||||
		names.map(name => Emojis.findOne({
 | 
			
		||||
			name,
 | 
			
		||||
			host: null
 | 
			
		||||
			host: null,
 | 
			
		||||
		}))
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ export default function(id: string, totalItems: any, orderedItems: any, partOf:
 | 
			
		|||
		partOf,
 | 
			
		||||
		type: 'OrderedCollectionPage',
 | 
			
		||||
		totalItems,
 | 
			
		||||
		orderedItems
 | 
			
		||||
		orderedItems,
 | 
			
		||||
	} as any;
 | 
			
		||||
 | 
			
		||||
	if (prev) page.prev = prev;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ export async function renderPerson(user: ILocalUser) {
 | 
			
		|||
	const [avatar, banner, profile] = await Promise.all([
 | 
			
		||||
		user.avatarId ? DriveFiles.findOne(user.avatarId) : Promise.resolve(undefined),
 | 
			
		||||
		user.bannerId ? DriveFiles.findOne(user.bannerId) : Promise.resolve(undefined),
 | 
			
		||||
		UserProfiles.findOneOrFail(user.id)
 | 
			
		||||
		UserProfiles.findOneOrFail(user.id),
 | 
			
		||||
	]);
 | 
			
		||||
 | 
			
		||||
	const attachment: {
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ export async function renderPerson(user: ILocalUser) {
 | 
			
		|||
				name: field.name,
 | 
			
		||||
				value: (field.value != null && field.value.match(/^https?:/))
 | 
			
		||||
					? `<a href="${new URL(field.value).href}" rel="me nofollow noopener" target="_blank">${new URL(field.value).href}</a>`
 | 
			
		||||
					: field.value
 | 
			
		||||
					: field.value,
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ export async function renderPerson(user: ILocalUser) {
 | 
			
		|||
		discoverable: !!user.isExplorable,
 | 
			
		||||
		publicKey: renderKey(user, keypair, `#main-key`),
 | 
			
		||||
		isCat: user.isCat,
 | 
			
		||||
		attachment: attachment.length ? attachment : undefined
 | 
			
		||||
		attachment: attachment.length ? attachment : undefined,
 | 
			
		||||
	} as any;
 | 
			
		||||
 | 
			
		||||
	if (profile?.birthday) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,9 +14,9 @@ export default async function renderQuestion(user: { id: User['id'] }, note: Not
 | 
			
		|||
			_misskey_votes: poll.votes[i],
 | 
			
		||||
			replies: {
 | 
			
		||||
				type: 'Collection',
 | 
			
		||||
				totalItems: poll.votes[i]
 | 
			
		||||
			}
 | 
			
		||||
		}))
 | 
			
		||||
				totalItems: poll.votes[i],
 | 
			
		||||
			},
 | 
			
		||||
		})),
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return question;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,5 +5,5 @@ import { MessagingMessage } from '@/models/entities/messaging-message';
 | 
			
		|||
export const renderReadActivity = (user: { id: User['id'] }, message: MessagingMessage) => ({
 | 
			
		||||
	type: 'Read',
 | 
			
		||||
	actor: `${config.url}/users/${user.id}`,
 | 
			
		||||
	object: message.uri
 | 
			
		||||
	object: message.uri,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,5 +4,5 @@ import { User } from '@/models/entities/user';
 | 
			
		|||
export default (object: any, user: { id: User['id'] }) => ({
 | 
			
		||||
	type: 'Reject',
 | 
			
		||||
	actor: `${config.url}/users/${user.id}`,
 | 
			
		||||
	object
 | 
			
		||||
	object,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,5 +5,5 @@ export default (user: { id: User['id'] }, target: any, object: any) => ({
 | 
			
		|||
	type: 'Remove',
 | 
			
		||||
	actor: `${config.url}/users/${user.id}`,
 | 
			
		||||
	target,
 | 
			
		||||
	object
 | 
			
		||||
	object,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
export default (id: string) => ({
 | 
			
		||||
	id,
 | 
			
		||||
	type: 'Tombstone'
 | 
			
		||||
	type: 'Tombstone',
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ export default async function renderVote(user: { id: User['id'] }, vote: PollVot
 | 
			
		|||
			attributedTo: `${config.url}/users/${user.id}`,
 | 
			
		||||
			to: [pollOwner.uri],
 | 
			
		||||
			inReplyTo: note.uri,
 | 
			
		||||
			name: poll.choices[vote.choice]
 | 
			
		||||
		}
 | 
			
		||||
			name: poll.choices[vote.choice],
 | 
			
		||||
		},
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,13 +12,13 @@ export default async (user: { id: User['id'] }, url: string, object: any) => {
 | 
			
		|||
	const req = createSignedPost({
 | 
			
		||||
		key: {
 | 
			
		||||
			privateKeyPem: keypair.privateKey,
 | 
			
		||||
			keyId: `${config.url}/users/${user.id}#main-key`
 | 
			
		||||
			keyId: `${config.url}/users/${user.id}#main-key`,
 | 
			
		||||
		},
 | 
			
		||||
		url,
 | 
			
		||||
		body,
 | 
			
		||||
		additionalHeaders: {
 | 
			
		||||
			'User-Agent': config.userAgent,
 | 
			
		||||
		}
 | 
			
		||||
		},
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	await getResponse({
 | 
			
		||||
| 
						 | 
				
			
			@ -40,18 +40,18 @@ export async function signedGet(url: string, user: { id: User['id'] }) {
 | 
			
		|||
	const req = createSignedGet({
 | 
			
		||||
		key: {
 | 
			
		||||
			privateKeyPem: keypair.privateKey,
 | 
			
		||||
			keyId: `${config.url}/users/${user.id}#main-key`
 | 
			
		||||
			keyId: `${config.url}/users/${user.id}#main-key`,
 | 
			
		||||
		},
 | 
			
		||||
		url,
 | 
			
		||||
		additionalHeaders: {
 | 
			
		||||
			'User-Agent': config.userAgent,
 | 
			
		||||
		}
 | 
			
		||||
		},
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	const res = await getResponse({
 | 
			
		||||
		url,
 | 
			
		||||
		method: req.request.method,
 | 
			
		||||
		headers: req.request.headers
 | 
			
		||||
		headers: req.request.headers,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return await res.json();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,9 +71,9 @@ export async function resolveUser(username: string, host: string | null, option?
 | 
			
		|||
 | 
			
		||||
			await Users.update({
 | 
			
		||||
				usernameLower,
 | 
			
		||||
				host: host
 | 
			
		||||
				host: host,
 | 
			
		||||
			}, {
 | 
			
		||||
				uri: self.href
 | 
			
		||||
				uri: self.href,
 | 
			
		||||
			});
 | 
			
		||||
		} else {
 | 
			
		||||
			logger.info(`uri is fine: ${acctLower}`);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue