2021-03-23 17:43:07 +09:00
|
|
|
import config from '@/config';
|
2020-02-06 17:07:37 +09:00
|
|
|
import { NoteReaction } from '../../../models/entities/note-reaction';
|
2019-04-07 21:50:36 +09:00
|
|
|
import { Note } from '../../../models/entities/note';
|
2020-04-14 00:42:59 +09:00
|
|
|
import { Emojis } from '../../../models';
|
|
|
|
import renderEmoji from './emoji';
|
2018-04-07 17:05:14 +09:00
|
|
|
|
2020-04-14 00:42:59 +09:00
|
|
|
export const renderLike = async (noteReaction: NoteReaction, note: Note) => {
|
|
|
|
const reaction = noteReaction.reaction;
|
|
|
|
|
|
|
|
const object = {
|
|
|
|
type: 'Like',
|
|
|
|
id: `${config.url}/likes/${noteReaction.id}`,
|
|
|
|
actor: `${config.url}/users/${noteReaction.userId}`,
|
|
|
|
object: note.uri ? note.uri : `${config.url}/notes/${noteReaction.noteId}`,
|
|
|
|
content: reaction,
|
|
|
|
_misskey_reaction: reaction
|
|
|
|
} as any;
|
|
|
|
|
|
|
|
if (reaction.startsWith(':')) {
|
|
|
|
const name = reaction.replace(/:/g, '');
|
|
|
|
const emoji = await Emojis.findOne({
|
|
|
|
name,
|
|
|
|
host: null
|
|
|
|
});
|
|
|
|
|
|
|
|
if (emoji) object.tag = [ renderEmoji(emoji) ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return object;
|
|
|
|
};
|