Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!(userid in userMap)) {
userMap[userid] = {
websockets: [],
lastBroadcast: 0
};
} else if (userMap[userid].websockets.includes(ws)) {
return;
}
// Lookup ip info
const lu = geoip.lookup(req.connection.remoteAddress);
ws._sessionInfo = {
id: Math.floor(Math.random() * 1e15).toString(16) + Date.now().toString(16),
city: lu ? lu.city : 'Unknown',
country: lu ? i18nCountries.getName(lu.country, 'en') : 'Unknown',
device: userAgentParser(req.headers['user-agent'])
};
// Push to redis
redisClient.rpush(userid.toString(), JSON.stringify(ws._sessionInfo));
websocket.broadcast({
userid,
data: {
type: 'open-session',
value: ws._sessionInfo
}
});
// Append websocket
userMap[userid].websockets.push(ws);
.map(companyInfo =>
countries.getName(companyInfo.company.country, "en")
)
getCountryName: function (name) {
var countries = require('i18n-iso-countries')
return countries.getName(name, 'en')
},
copyToClipboard: function(){
fromAlpha2Code: code => {
return {
name: countries.getName(code, 'en'),
emoji: flag(code),
};
},
};
.map(companyInfo =>
countries.getName(companyInfo.company.country, "en")
)
generateLadderEmbedTitle ({ type, country_code: cc }, t, language) {
const title = t(`commands:steamladder.ladders.${type}`)
if (cc) {
const suffix = ` - ${title}`
if (this.client.i18next.exists(`commands:steamladder.regions.${cc}`)) {
return t(`commands:steamladder.regions.${cc}`) + suffix
} else if (countries.getName(cc, language.substring(0, 2))) {
return countries.getName(cc, language.substring(0, 2)) + suffix
} else {
return cc + suffix
}
}
return title
}
case 'SYR':
return 'Syria';
case 'MKD':
return 'Macedonia';
case 'IRN':
return 'Iran';
case 'LBY':
return 'Libya';
case 'RUS':
return 'Russia';
case 'RCB':
return 'Congo';
case 'COD':
return 'Congo';
}
return countries.getName(country, 'en');
};
alphaToName (alpha, locale) {
return i18nIsoCode.getName(alpha, locale) || alpha;
}
},
MapModel.prototype.getFriendlyNameForCountry = function(country) {
switch(country) {
case 'SYR': return 'Syria';
case 'MKD': return 'Macedonia';
case 'IRN': return 'Iran';
case 'LBY': return 'Libya';
case 'RUS': return 'Russia';
case 'RCB': return 'Congo';
case 'COD': return 'Congo';
}
return countries.getName(country, 'en');
};