feat: remove gsheet intgration route

This commit is contained in:
karishmas6
2024-10-21 02:33:38 +05:30
parent 3782ee2a34
commit 0fe48677d2

View File

@@ -354,3 +354,31 @@ router.post('/gsheets/update', requireSignIn, async (req, res) => {
res.status(500).json({ message: `Error updating robot: ${error.message}` });
}
});
router.post('/gsheets/remove', requireSignIn, async (req, res) => {
const { robotId } = req.body;
if (!robotId) {
return res.status(400).json({ message: 'Robot ID is required' });
}
try {
let robot = await Robot.findOne({ where: { 'recording_meta.id': robotId } });
if (!robot) {
return res.status(404).json({ message: 'Robot not found' });
}
await robot.update({
google_sheet_id: null,
google_sheet_name: null,
google_sheet_email: null,
google_access_token: null,
google_refresh_token: null
});
res.json({ message: 'Google Sheets integration removed successfully' });
} catch (error: any) {
res.status(500).json({ message: `Error removing Google Sheets integration: ${error.message}` });
}
});