mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 20:23:08 +02:00
[API] Implement disconnect/twitter
This commit is contained in:
parent
651effe6d9
commit
cd6b681748
1 changed files with 19 additions and 0 deletions
|
@ -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へ接続できません');
|
||||
|
|
Loading…
Reference in a new issue