diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-01-21 19:26:45 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-01-21 19:26:45 +0900 |
| commit | cd6b6817481f92bee582e61f1fc3c98326c35804 (patch) | |
| tree | e5d7fa24a72e107d360bb3ad2db799856aef0437 /src | |
| parent | [Doc] Add privacy policy (diff) | |
| download | sharkey-cd6b6817481f92bee582e61f1fc3c98326c35804.tar.gz sharkey-cd6b6817481f92bee582e61f1fc3c98326c35804.tar.bz2 sharkey-cd6b6817481f92bee582e61f1fc3c98326c35804.zip | |
[API] Implement disconnect/twitter
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/service/twitter.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/api/service/twitter.ts b/src/api/service/twitter.ts index 2d97a26dcf..4d4aad498f 100644 --- a/src/api/service/twitter.ts +++ b/src/api/service/twitter.ts @@ -9,6 +9,25 @@ import event from '../event'; import config from '../../conf'; module.exports = (app: express.Application) => { + app.get('/disconnect/twitter', async (req, res): Promise<any> => { + if (res.locals.user == null) return res.send('plz signin'); + const user = await User.findOneAndUpdate({ + token: res.locals.user + }, { + $unset: { + twitter: '' + } + }); + + res.send(`Twitterの連携を解除しました :v:`); + + // Publish i updated event + event(user._id, 'i_updated', await serialize(user, user, { + detail: true, + includeSecrets: true + })); + }); + if (config.twitter == null) { app.get('/connect/twitter', (req, res) => { res.send('現在Twitterへ接続できません'); |