mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 21:45:59 +02:00
Implement remote account resolution
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import { IUser } from '../api/models/user';
|
||||
|
||||
/**
|
||||
* ユーザーを表す文字列を取得します。
|
||||
* @param user ユーザー
|
||||
*/
|
||||
export default function(user: IUser): string {
|
||||
return `${user.name} (@${user.username})\n` +
|
||||
`${user.posts_count}投稿、${user.following_count}フォロー、${user.followers_count}フォロワー\n` +
|
||||
`場所: ${user.account.profile.location}、誕生日: ${user.account.profile.birthday}\n` +
|
||||
`「${user.description}」`;
|
||||
}
|
||||
3
src/common/user/get-acct.ts
Normal file
3
src/common/user/get-acct.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default user => {
|
||||
return user.host === null ? user.username : `${user.username}@${user.host}`;
|
||||
};
|
||||
18
src/common/user/get-summary.ts
Normal file
18
src/common/user/get-summary.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ILocalAccount, IUser } from '../../api/models/user';
|
||||
import getAcct from './get-acct';
|
||||
|
||||
/**
|
||||
* ユーザーを表す文字列を取得します。
|
||||
* @param user ユーザー
|
||||
*/
|
||||
export default function(user: IUser): string {
|
||||
let string = `${user.name} (@${getAcct(user)})\n` +
|
||||
`${user.posts_count}投稿、${user.following_count}フォロー、${user.followers_count}フォロワー\n`;
|
||||
|
||||
if (user.host === null) {
|
||||
const account = user.account as ILocalAccount;
|
||||
string += `場所: ${account.profile.location}、誕生日: ${account.profile.birthday}\n`;
|
||||
}
|
||||
|
||||
return string + `「${user.description}」`;
|
||||
}
|
||||
4
src/common/user/parse-acct.ts
Normal file
4
src/common/user/parse-acct.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default acct => {
|
||||
const splitted = acct.split('@', 2);
|
||||
return { username: splitted[0], host: splitted[1] || null };
|
||||
};
|
||||
Reference in New Issue
Block a user