mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #7721 from overleaf/jel-td-notify-commons
Only handle confirmed users via commons script GitOrigin-RevId: 0d00147943228bff6c435848ff88481c5c184a8a
This commit is contained in:
parent
9253dac12f
commit
fc9bfa84cd
3 changed files with 24 additions and 2 deletions
|
@ -22,6 +22,17 @@ const InstitutionsAPI = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getConfirmedInstitutionAffiliations(institutionId, callback) {
|
||||||
|
makeAffiliationRequest(
|
||||||
|
{
|
||||||
|
method: 'GET',
|
||||||
|
path: `/api/v2/institutions/${institutionId.toString()}/confirmed_affiliations`,
|
||||||
|
defaultErrorMessage: "Couldn't get institution affiliations",
|
||||||
|
},
|
||||||
|
(error, body) => callback(error, body || [])
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
getInstitutionAffiliationsCounts(institutionId, callback) {
|
getInstitutionAffiliationsCounts(institutionId, callback) {
|
||||||
makeAffiliationRequest(
|
makeAffiliationRequest(
|
||||||
{
|
{
|
||||||
|
@ -267,6 +278,7 @@ function makeAffiliationRequest(options, callback) {
|
||||||
}
|
}
|
||||||
;[
|
;[
|
||||||
'getInstitutionAffiliations',
|
'getInstitutionAffiliations',
|
||||||
|
'getConfirmedInstitutionAffiliations',
|
||||||
'getUserAffiliations',
|
'getUserAffiliations',
|
||||||
'addAffiliation',
|
'addAffiliation',
|
||||||
'removeAffiliation',
|
'removeAffiliation',
|
||||||
|
|
|
@ -4,6 +4,7 @@ const { ObjectId } = require('mongodb')
|
||||||
const Settings = require('@overleaf/settings')
|
const Settings = require('@overleaf/settings')
|
||||||
const {
|
const {
|
||||||
getInstitutionAffiliations,
|
getInstitutionAffiliations,
|
||||||
|
getConfirmedInstitutionAffiliations,
|
||||||
promises: InstitutionsAPIPromises,
|
promises: InstitutionsAPIPromises,
|
||||||
} = require('./InstitutionsAPI')
|
} = require('./InstitutionsAPI')
|
||||||
const FeaturesUpdater = require('../Subscription/FeaturesUpdater')
|
const FeaturesUpdater = require('../Subscription/FeaturesUpdater')
|
||||||
|
@ -261,8 +262,9 @@ const fetchInstitutionAndAffiliations = (institutionId, callback) =>
|
||||||
(institution, cb) =>
|
(institution, cb) =>
|
||||||
institution.fetchV1Data((err, institution) => cb(err, institution)),
|
institution.fetchV1Data((err, institution) => cb(err, institution)),
|
||||||
(institution, cb) =>
|
(institution, cb) =>
|
||||||
getInstitutionAffiliations(institutionId, (err, affiliations) =>
|
getConfirmedInstitutionAffiliations(
|
||||||
cb(err, institution, affiliations)
|
institutionId,
|
||||||
|
(err, affiliations) => cb(err, institution, affiliations)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
callback
|
callback
|
||||||
|
|
|
@ -13,6 +13,7 @@ describe('InstitutionsManager', function () {
|
||||||
this.institutionId = 123
|
this.institutionId = 123
|
||||||
this.user = {}
|
this.user = {}
|
||||||
this.getInstitutionAffiliations = sinon.stub()
|
this.getInstitutionAffiliations = sinon.stub()
|
||||||
|
this.getConfirmedInstitutionAffiliations = sinon.stub()
|
||||||
this.refreshFeatures = sinon.stub().yields()
|
this.refreshFeatures = sinon.stub().yields()
|
||||||
this.users = [
|
this.users = [
|
||||||
{ _id: 'lapsed', features: {} },
|
{ _id: 'lapsed', features: {} },
|
||||||
|
@ -95,11 +96,17 @@ describe('InstitutionsManager', function () {
|
||||||
requires: {
|
requires: {
|
||||||
'./InstitutionsAPI': {
|
'./InstitutionsAPI': {
|
||||||
getInstitutionAffiliations: this.getInstitutionAffiliations,
|
getInstitutionAffiliations: this.getInstitutionAffiliations,
|
||||||
|
getConfirmedInstitutionAffiliations:
|
||||||
|
this.getConfirmedInstitutionAffiliations,
|
||||||
promises: {
|
promises: {
|
||||||
getInstitutionAffiliations:
|
getInstitutionAffiliations:
|
||||||
(this.getInstitutionAffiliationsPromise = sinon
|
(this.getInstitutionAffiliationsPromise = sinon
|
||||||
.stub()
|
.stub()
|
||||||
.resolves(this.affiliations)),
|
.resolves(this.affiliations)),
|
||||||
|
getConfirmedInstitutionAffiliations:
|
||||||
|
(this.getConfirmedInstitutionAffiliationsPromise = sinon
|
||||||
|
.stub()
|
||||||
|
.resolves(this.affiliations)),
|
||||||
getInstitutionAffiliationsCounts:
|
getInstitutionAffiliationsCounts:
|
||||||
(this.getInstitutionAffiliationsCounts = sinon
|
(this.getInstitutionAffiliationsCounts = sinon
|
||||||
.stub()
|
.stub()
|
||||||
|
@ -173,6 +180,7 @@ describe('InstitutionsManager', function () {
|
||||||
|
|
||||||
this.refreshFeatures.withArgs(this.user1Id).yields(null, {}, true)
|
this.refreshFeatures.withArgs(this.user1Id).yields(null, {}, true)
|
||||||
this.getInstitutionAffiliations.yields(null, this.affiliations)
|
this.getInstitutionAffiliations.yields(null, this.affiliations)
|
||||||
|
this.getConfirmedInstitutionAffiliations.yields(null, this.affiliations)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('refresh all users Features', function (done) {
|
it('refresh all users Features', function (done) {
|
||||||
|
|
Loading…
Reference in a new issue