Skip to content

Commit

Permalink
Fixes fossasia#342: adding support for sending notification if access…
Browse files Browse the repository at this point in the history
… tokem revoked
  • Loading branch information
poonai committed Aug 2, 2017
1 parent 456f8d5 commit ba0ce77
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions backend/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ exports.deleteHook = function (name, hook, accessToken, callback) {
}
});
};

exports.retriveUser = function (token, callback) {
request({
url: 'https://api.github.com/users/',
headers: {
'User-Agent': 'Yaydoc',
'Authorization': 'token ' + crypter.decrypt(accessToken)
}
}, function (error, response, body) {
if (response.status !== 200) {
callback({statusCode: response.status}, null)
} else {
callback(error, JSON.parse(body))
}
})
}
22 changes: 22 additions & 0 deletions model/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,25 @@ module.exports.createOrUpdateRepository = function (name, data, callback) {
module.exports.deleteRepositoryByName = function (name, callback) {
Repository.findOneAndRemove({name: name}, callback);
};

/**
* Count the number of repository
*/

modules.exports.countRepository = function (callback) {
Repository.count({}, callback)
}

/**
* paginates repositories
* @param page: n'th page
* @param limit: limit for number of repository to return
*/

modules.exports.paginateRepository = function (page, limit, callback) {
var skip = 0;
if (page > 0) {
skip = page * limit;
}
Repository.find({}).skip(skip).limit(limit).exec(callback)
}

0 comments on commit ba0ce77

Please sign in to comment.