Permalink
Browse files

Move away from Google Plus for user profiles

  • Loading branch information...
Thomas101 committed Dec 21, 2018
1 parent e1d6db1 commit 203becc9d6e228a1a60f8fe698b3906a72ae47f4
@@ -8,7 +8,6 @@ const APIS_DIR = path.join(MODULE_DIR, 'build/src/apis')
const INDEX_PATH = path.join(MODULE_DIR, 'build/src/index.js')
const APIS_INDEX_PATH = path.join(APIS_DIR, 'index.js')
const REQUIRED_APIS = new Set([
'plus',
'gmail',
'oauth2'
])
@@ -42,17 +41,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const gmail = __importStar(require("./gmail"));
const oauth2 = __importStar(require("./oauth2"));
const plus = __importStar(require("./plus"));
exports.APIS = {
gmail: gmail.VERSIONS,
oauth2: oauth2.VERSIONS,
plus: plus.VERSIONS
oauth2: oauth2.VERSIONS
};
class GeneratedAPIs {
constructor() {
this.gmail = gmail.gmail.bind(this);
this.oauth2 = oauth2.oauth2.bind(this);
this.plus = plus.plus.bind(this);
}
}
exports.GeneratedAPIs = GeneratedAPIs;
@@ -729,7 +729,7 @@ class AccountStore extends RendererAccountStore {
return {
...permenantAuth,
pushToken: auth.pushToken,
email: (response.emails.find((a) => a.type === 'account') || {}).value
email: response.email
}
})
})
@@ -26,8 +26,8 @@ google.options({
// transformRequest @Thomas101 - if google ever fix their auth library move transformRequest back here
})

const gPlus = google.plus('v1')
const gmail = google.gmail('v1')
const oauth2 = google.oauth2('v2')
const OAuth2 = google.auth.OAuth2
const { GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET } = Bootstrap.credentials

@@ -135,7 +135,7 @@ class GoogleHTTP {
if (!auth) { return this._rejectWithNoAuth() }

return Promise.resolve()
.then(() => gPlus.people.get({ userId: 'me', auth: auth }))
.then(() => oauth2.userinfo.get({ userId: 'me', auth: auth }))
.then((res) => {
if (res.status === 200) {
return Promise.resolve(res.data)
@@ -7,7 +7,6 @@ import {
GOOGLE_MAILBOX_WATCH_THROTTLE
} from 'shared/constants'
import uuid from 'uuid'
import { URL } from 'url'
import ServerVent from 'Server/ServerVent'
import { accountStore, accountActions } from 'stores/account'
import Debug from 'Debug'
@@ -205,18 +204,6 @@ class GoogleStore {
})
}

/**
* Gets the avatar from the response image
* @param image: the image object provided by google
* @return a url for the image
*/
getAvatarFromResponseImage (image) {
if (!image.url) { return image.url }
const purl = new URL(image.url)
purl.searchParams.delete('sz')
return purl.toString()
}

handleSyncServiceProfile ({ serviceId }) {
if (this.hasOpenRequest(REQUEST_TYPES.PROFILE, serviceId)) {
this.preventDefault()
@@ -232,17 +219,15 @@ class GoogleStore {
.then(() => GoogleHTTP.fetchAccountProfile(auth))
.then((response) => {
this.trackCloseRequest(REQUEST_TYPES.PROFILE, serviceId, requestId)
const email = (response.emails.find((a) => a.type === 'account') || {}).value
const avatar = this.getAvatarFromResponseImage(response.image)
accountActions.reduceAuth(
serviceAuth.id,
AuthReducer.makeValid
)
accountActions.reduceService(
serviceId,
CoreGoogleMailServiceReducer.setProfileInfo,
email,
avatar
response.email,
response.picture
)
this.emitChange()
})

0 comments on commit 203becc

Please sign in to comment.