diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-03-28 08:57:10 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-28 08:57:10 +0900 |
| commit | 3c553ba674d951843d098dc79fa2456b5a7df846 (patch) | |
| tree | 3b468556c25dd5b63e3774aca1869b71dd9b1919 /src/api/models | |
| parent | Merge pull request #1316 from akihikodaki/host (diff) | |
| parent | Implement remote account resolution (diff) | |
| download | sharkey-3c553ba674d951843d098dc79fa2456b5a7df846.tar.gz sharkey-3c553ba674d951843d098dc79fa2456b5a7df846.tar.bz2 sharkey-3c553ba674d951843d098dc79fa2456b5a7df846.zip | |
Merge pull request #1318 from akihikodaki/remote
Implement remote account resolution
Diffstat (limited to 'src/api/models')
| -rw-r--r-- | src/api/models/user.ts | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 46d32963bc..e73c95faf2 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -39,6 +39,39 @@ export function isValidBirthday(birthday: string): boolean { return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday); } +export type ILocalAccount = { + keypair: string; + email: string; + links: string[]; + password: string; + token: string; + twitter: { + access_token: string; + access_token_secret: string; + user_id: string; + screen_name: string; + }; + line: { + user_id: string; + }; + profile: { + location: string; + birthday: string; // 'YYYY-MM-DD' + tags: string[]; + }; + last_used_at: Date; + is_bot: boolean; + is_pro: boolean; + two_factor_secret: string; + two_factor_enabled: boolean; + client_settings: any; + settings: any; +}; + +export type IRemoteAccount = { + uri: string; +}; + export type IUser = { _id: mongo.ObjectID; created_at: Date; @@ -60,34 +93,7 @@ export type IUser = { keywords: string[]; host: string; host_lower: string; - account: { - keypair: string; - email: string; - links: string[]; - password: string; - token: string; - twitter: { - access_token: string; - access_token_secret: string; - user_id: string; - screen_name: string; - }; - line: { - user_id: string; - }; - profile: { - location: string; - birthday: string; // 'YYYY-MM-DD' - tags: string[]; - }; - last_used_at: Date; - is_bot: boolean; - is_pro: boolean; - two_factor_secret: string; - two_factor_enabled: boolean; - client_settings: any; - settings: any; - }; + account: ILocalAccount | IRemoteAccount; }; export function init(user): IUser { @@ -162,28 +168,30 @@ export const pack = ( // Remove needless properties delete _user.latest_post; - // Remove private properties - delete _user.account.keypair; - delete _user.account.password; - delete _user.account.token; - delete _user.account.two_factor_temp_secret; - delete _user.account.two_factor_secret; - delete _user.username_lower; - if (_user.account.twitter) { - delete _user.account.twitter.access_token; - delete _user.account.twitter.access_token_secret; - } - delete _user.account.line; + if (!_user.host) { + // Remove private properties + delete _user.account.keypair; + delete _user.account.password; + delete _user.account.token; + delete _user.account.two_factor_temp_secret; + delete _user.account.two_factor_secret; + delete _user.username_lower; + if (_user.account.twitter) { + delete _user.account.twitter.access_token; + delete _user.account.twitter.access_token_secret; + } + delete _user.account.line; - // Visible via only the official client - if (!opts.includeSecrets) { - delete _user.account.email; - delete _user.account.settings; - delete _user.account.client_settings; - } + // Visible via only the official client + if (!opts.includeSecrets) { + delete _user.account.email; + delete _user.account.settings; + delete _user.account.client_settings; + } - if (!opts.detail) { - delete _user.account.two_factor_enabled; + if (!opts.detail) { + delete _user.account.two_factor_enabled; + } } _user.avatar_url = _user.avatar_id != null |