45
src/renderers/get-note-summary.ts
Normal file
45
src/renderers/get-note-summary.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 投稿を表す文字列を取得します。
|
||||
* @param {*} note 投稿
|
||||
*/
|
||||
const summarize = (note: any): string => {
|
||||
let summary = '';
|
||||
|
||||
// チャンネル
|
||||
summary += note.channel ? `${note.channel.title}:` : '';
|
||||
|
||||
// 本文
|
||||
summary += note.text ? note.text : '';
|
||||
|
||||
// メディアが添付されているとき
|
||||
if (note.media) {
|
||||
summary += ` (${note.media.length}つのメディア)`;
|
||||
}
|
||||
|
||||
// 投票が添付されているとき
|
||||
if (note.poll) {
|
||||
summary += ' (投票)';
|
||||
}
|
||||
|
||||
// 返信のとき
|
||||
if (note.replyId) {
|
||||
if (note.reply) {
|
||||
summary += ` RE: ${summarize(note.reply)}`;
|
||||
} else {
|
||||
summary += ' RE: ...';
|
||||
}
|
||||
}
|
||||
|
||||
// Renoteのとき
|
||||
if (note.renoteId) {
|
||||
if (note.renote) {
|
||||
summary += ` RP: ${summarize(note.renote)}`;
|
||||
} else {
|
||||
summary += ' RP: ...';
|
||||
}
|
||||
}
|
||||
|
||||
return summary.trim();
|
||||
};
|
||||
|
||||
export default summarize;
|
@@ -1,5 +1,5 @@
|
||||
import getUserName from '../renderers/get-user-name';
|
||||
import getPostSummary from './get-post-summary';
|
||||
import getNoteSummary from './get-note-summary';
|
||||
import getReactionEmoji from './get-reaction-emoji';
|
||||
|
||||
/**
|
||||
@@ -11,17 +11,17 @@ export default function(notification: any): string {
|
||||
case 'follow':
|
||||
return `${getUserName(notification.user)}にフォローされました`;
|
||||
case 'mention':
|
||||
return `言及されました:\n${getUserName(notification.user)}「${getPostSummary(notification.post)}」`;
|
||||
return `言及されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
|
||||
case 'reply':
|
||||
return `返信されました:\n${getUserName(notification.user)}「${getPostSummary(notification.post)}」`;
|
||||
case 'repost':
|
||||
return `Repostされました:\n${getUserName(notification.user)}「${getPostSummary(notification.post)}」`;
|
||||
return `返信されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
|
||||
case 'renote':
|
||||
return `Renoteされました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
|
||||
case 'quote':
|
||||
return `引用されました:\n${getUserName(notification.user)}「${getPostSummary(notification.post)}」`;
|
||||
return `引用されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
|
||||
case 'reaction':
|
||||
return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getPostSummary(notification.post)}」`;
|
||||
return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getNoteSummary(notification.note)}」`;
|
||||
case 'poll_vote':
|
||||
return `投票されました:\n${getUserName(notification.user)}「${getPostSummary(notification.post)}」`;
|
||||
return `投票されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
|
||||
default:
|
||||
return `<不明な通知タイプ: ${notification.type}>`;
|
||||
}
|
||||
|
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* 投稿を表す文字列を取得します。
|
||||
* @param {*} post 投稿
|
||||
*/
|
||||
const summarize = (post: any): string => {
|
||||
let summary = '';
|
||||
|
||||
// チャンネル
|
||||
summary += post.channel ? `${post.channel.title}:` : '';
|
||||
|
||||
// 本文
|
||||
summary += post.text ? post.text : '';
|
||||
|
||||
// メディアが添付されているとき
|
||||
if (post.media) {
|
||||
summary += ` (${post.media.length}つのメディア)`;
|
||||
}
|
||||
|
||||
// 投票が添付されているとき
|
||||
if (post.poll) {
|
||||
summary += ' (投票)';
|
||||
}
|
||||
|
||||
// 返信のとき
|
||||
if (post.replyId) {
|
||||
if (post.reply) {
|
||||
summary += ` RE: ${summarize(post.reply)}`;
|
||||
} else {
|
||||
summary += ' RE: ...';
|
||||
}
|
||||
}
|
||||
|
||||
// Repostのとき
|
||||
if (post.repostId) {
|
||||
if (post.repost) {
|
||||
summary += ` RP: ${summarize(post.repost)}`;
|
||||
} else {
|
||||
summary += ' RP: ...';
|
||||
}
|
||||
}
|
||||
|
||||
return summary.trim();
|
||||
};
|
||||
|
||||
export default summarize;
|
@@ -8,7 +8,7 @@ import getUserName from './get-user-name';
|
||||
*/
|
||||
export default function(user: IUser): string {
|
||||
let string = `${getUserName(user)} (@${getAcct(user)})\n` +
|
||||
`${user.postsCount}投稿、${user.followingCount}フォロー、${user.followersCount}フォロワー\n`;
|
||||
`${user.notesCount}投稿、${user.followingCount}フォロー、${user.followersCount}フォロワー\n`;
|
||||
|
||||
if (isLocalUser(user)) {
|
||||
const account = user.account;
|
||||
|
Reference in New Issue
Block a user