Handle some additional reaction activities
This commit is contained in:
parent
d17c6adba4
commit
1462ff12de
4 changed files with 11 additions and 6 deletions
|
@ -15,7 +15,9 @@ const basic10: Record<string, string> = {
|
|||
'🍮': 'pudding',
|
||||
};
|
||||
|
||||
export async function getFallbackReaction(): Promise<string> {
|
||||
export async function getFallbackReaction(reaction?: string | null): Promise<string> {
|
||||
if (reaction === '👎') return reaction;
|
||||
|
||||
const meta = await fetchMeta();
|
||||
return meta.useStarForReactionFallback ? 'star' : 'like';
|
||||
}
|
||||
|
@ -26,7 +28,7 @@ export async function toDbReaction(reaction?: string | null, enableEmoji = true)
|
|||
// 既存の文字列リアクションはそのまま
|
||||
if (Object.values(basic10).includes(reaction)) return reaction;
|
||||
|
||||
if (!enableEmoji) return await getFallbackReaction();
|
||||
if (!enableEmoji) return await getFallbackReaction(reaction);
|
||||
|
||||
// Unicode絵文字
|
||||
const match = emojiRegex.exec(reaction);
|
||||
|
|
|
@ -15,9 +15,10 @@ export default async (actor: IRemoteUser, activity: ILike) => {
|
|||
|
||||
const note = await Notes.findOne(noteId);
|
||||
if (note == null) {
|
||||
apLogger.warn(`Like activity recivied, but no such note: ${id}`, { id });
|
||||
apLogger.warn(`${activity.type} activity recivied, but no such note: ${id}`, { id });
|
||||
return;
|
||||
}
|
||||
|
||||
await create(actor, note, activity._misskey_reaction);
|
||||
const reaction = activity.type === 'Dislike' ? '👎' : activity._misskey_reaction || activity.content || activity.name;
|
||||
await create(actor, note, reaction);
|
||||
};
|
||||
|
|
|
@ -37,6 +37,8 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
|
|||
unblock(actor, object as IBlock);
|
||||
break;
|
||||
case 'Like':
|
||||
case 'Dislike':
|
||||
case 'EmojiReaction':
|
||||
undoLike(actor, object as ILike);
|
||||
break;
|
||||
case 'Announce':
|
||||
|
|
|
@ -159,7 +159,7 @@ export interface IRemove extends IActivity {
|
|||
}
|
||||
|
||||
export interface ILike extends IActivity {
|
||||
type: 'Like';
|
||||
type: 'Like' | 'Dislike' | 'EmojiReaction';
|
||||
_misskey_reaction?: string;
|
||||
}
|
||||
|
||||
|
@ -180,6 +180,6 @@ export const isAccept = (object: IObject): object is IAccept => object.type ===
|
|||
export const isReject = (object: IObject): object is IReject => object.type === 'Reject';
|
||||
export const isAdd = (object: IObject): object is IAdd => object.type === 'Add';
|
||||
export const isRemove = (object: IObject): object is IRemove => object.type === 'Remove';
|
||||
export const isLike = (object: IObject): object is ILike => object.type === 'Like';
|
||||
export const isLike = (object: IObject): object is ILike => object.type === 'Like' || object.type === 'Dislike' || object.type === 'EmojiReaction';
|
||||
export const isAnnounce = (object: IObject): object is IAnnounce => object.type === 'Announce';
|
||||
export const isBlock = (object: IObject): object is IBlock => object.type === 'Block';
|
||||
|
|
Loading…
Reference in a new issue