This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -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,
});

View File

@ -5,5 +5,5 @@ export default (user: ILocalUser, target: any, object: any) => ({
type: 'Add',
actor: `${config.url}/users/${user.id}`,
target,
object
object,
});

View File

@ -24,6 +24,6 @@ export default (object: any, note: Note) => {
published: note.createdAt.toISOString(),
to,
cc,
object
object,
};
};

View File

@ -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,
});

View File

@ -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;

View File

@ -9,6 +9,6 @@ export default (emoji: Emoji) => ({
icon: {
type: 'Image',
mediaType: emoji.type || 'image/png',
url: emoji.url
}
url: emoji.url,
},
});

View File

@ -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;

View File

@ -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;

View File

@ -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}`,
});

View File

@ -5,5 +5,5 @@ export default (file: DriveFile) => ({
type: 'Image',
url: DriveFiles.getPublicUrl(file),
sensitive: file.isSensitive,
name: file.comment
name: file.comment,
});

View File

@ -41,8 +41,8 @@ export const renderActivity = (x: any): IActivity | null => {
'isCat': 'misskey:isCat',
// vcard
vcard: 'http://www.w3.org/2006/vcard/ns#',
}
]
},
],
}, x);
};

View File

@ -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',
}),
});

View File

@ -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) ];

View File

@ -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,
}))
);

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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,
});

View File

@ -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,
});

View File

@ -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,
});

View File

@ -1,4 +1,4 @@
export default (id: string) => ({
id,
type: 'Tombstone'
type: 'Tombstone',
});

View File

@ -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],
},
};
}