@@ -12,6 +12,7 @@ const { getPaginationLink, getUsernamesFromPRs } = require("../utils/users");
12
12
const { getQualifiers } = require ( "../utils/helper" ) ;
13
13
const { SOMETHING_WENT_WRONG , INTERNAL_SERVER_ERROR } = require ( "../constants/errorMessages" ) ;
14
14
const { getFilteredPRsOrIssues } = require ( "../utils/pullRequests" ) ;
15
+ const { IN_DISCORD } = require ( "../constants/roles" ) ;
15
16
16
17
const verifyUser = async ( req , res ) => {
17
18
const userId = req . userData . id ;
@@ -107,6 +108,7 @@ const getUsers = async (req, res) => {
107
108
*/
108
109
109
110
const getUser = async ( req , res ) => {
111
+ console . log ( req . params . username ) ;
110
112
try {
111
113
const result = await userQuery . fetchUser ( { username : req . params . username } ) ;
112
114
const { phone, email, ...user } = result . user ;
@@ -462,6 +464,29 @@ const filterUsers = async (req, res) => {
462
464
}
463
465
} ;
464
466
467
+ // const syncInDiscordRole = async (req, res) => {
468
+ // try {
469
+ // } catch (error) {
470
+ // logger.error(`Error while fetching all users: ${error}`);
471
+ // return res.boom.serverUnavailable("Something went wrong please contact admin");
472
+ // }
473
+ // };
474
+
475
+ const fetchInDiscordUsers = async ( req , res ) => {
476
+ try {
477
+ const allUsers = await userQuery . fetchUsersWithRole ( IN_DISCORD ) ;
478
+
479
+ return res . json ( {
480
+ message : "Users found successfully!" ,
481
+ users : allUsers ,
482
+ count : allUsers . length ,
483
+ } ) ;
484
+ } catch ( error ) {
485
+ logger . error ( `Error while fetching all users: ${ error } ` ) ;
486
+ return res . boom . serverUnavailable ( "Something went wrong please contact admin" ) ;
487
+ }
488
+ } ;
489
+
465
490
module . exports = {
466
491
verifyUser,
467
492
generateChaincode,
@@ -481,4 +506,5 @@ module.exports = {
481
506
addDefaultArchivedRole,
482
507
getUserSkills,
483
508
filterUsers,
509
+ fetchInDiscordUsers,
484
510
} ;
0 commit comments