Storing social links in profile file, changed format to YAML.

This commit is contained in:
2026-09-29 17:12:16 +02:00
parent 1496a48199
commit e23d8becd4
5 changed files with 125 additions and 24 deletions
+16 -2
View File
@@ -7,11 +7,25 @@ const curateUser = require('../curate/user');
const logger = require('../logger')(__filename);
async function getSocialLinks(username, reddit) {
try {
return await reddit.getSocialLinks(username);
} catch (error) {
// supplementary, not worth failing the whole user fetch over - fall back to none
logger.warn(`Failed to fetch social links for '${username}': ${error.message} (https://reddit.com/user/${username})`);
return [];
}
}
async function getUser(username, reddit) {
try {
const user = await reddit.getUser(username);
const [user, socialLinks] = await Promise.all([
reddit.getUser(username),
getSocialLinks(username, reddit),
]);
return curateUser(user);
return curateUser(user, socialLinks);
} catch (error) {
logger.error(`Failed to fetch reddit user '${username}': ${error.message} (https://reddit.com/user/${username})`);
+16 -2
View File
@@ -8,13 +8,27 @@ const curateUser = require('../curate/user');
const logger = require('../logger')(__filename);
async function getSocialLinks(username, reddit) {
try {
return await reddit.getSocialLinks(username);
} catch (error) {
// supplementary, not worth failing the whole user fetch over - fall back to none
logger.warn(`Failed to fetch social links for '${username}': ${error.message} (https://reddit.com/user/${username})`);
return [];
}
}
async function getUser(username, reddit) {
try {
const user = await reddit.getUser(username);
const [user, socialLinks] = await Promise.all([
reddit.getUser(username),
getSocialLinks(username, reddit),
]);
logger.info(`Fetched user profile for '${username}' (https://reddit.com/user/${username})`);
return curateUser(user);
return curateUser(user, socialLinks);
} catch (error) {
logger.error(`Failed to fetch reddit user '${username}': ${error.message} (https://reddit.com/user/${username})`);