mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 09:45:20 +00:00
- Implemented connecting multiple accounts for google
This commit is contained in:
@ -188,11 +188,17 @@ exports.refreshTokens = functions.pubsub.schedule('every 12 hours').onRun(async
|
||||
profilesSnapshot.forEach(async (profileDoc) => {
|
||||
const profileData = profileDoc.data();
|
||||
|
||||
if (profileData.googleToken) {
|
||||
if (profileData.googleAccounts) {
|
||||
try {
|
||||
const refreshedGoogleToken = await refreshGoogleToken(profileData.googleToken);
|
||||
await profileDoc.ref.update({googleToken: refreshedGoogleToken});
|
||||
console.log(`Google token updated for user ${profileDoc.id}`);
|
||||
for (const googleEmail of Object.keys(profileData?.googleAccounts)) {
|
||||
const googleToken = profileData?.googleAccounts?.[googleEmail];
|
||||
if (googleToken) {
|
||||
const refreshedGoogleToken = await refreshGoogleToken(googleToken);
|
||||
const updatedGoogleAccounts = {...profileData.googleAccounts, [googleEmail]: refreshedGoogleToken};
|
||||
await profileDoc.ref.update({googleAccounts: updatedGoogleAccounts});
|
||||
console.log(`Google token updated for user ${profileDoc.id}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error refreshing Google token for user ${profileDoc.id}:`, error.message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user