2023-01-13 06:19:52 +00:00
|
|
|
const UserProps = require('../user_property');
|
2023-01-09 00:11:49 +00:00
|
|
|
|
|
|
|
module.exports = class ActivityPubSettings {
|
|
|
|
constructor(obj) {
|
|
|
|
this.enabled = true; // :TODO: fetch from +op config default
|
|
|
|
this.manuallyApproveFollowers = false;
|
|
|
|
this.hideSocialGraph = false; // followers, following
|
|
|
|
this.showRealName = false;
|
2023-01-14 04:27:02 +00:00
|
|
|
this.image = '';
|
|
|
|
this.icon = '';
|
2023-01-09 00:11:49 +00:00
|
|
|
|
|
|
|
if (obj) {
|
|
|
|
Object.assign(this, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static fromUser(user) {
|
|
|
|
if (!user.activityPubSettings) {
|
|
|
|
const settingsProp = user.getProperty(UserProps.ActivityPubSettings);
|
|
|
|
let settings;
|
|
|
|
try {
|
|
|
|
const parsed = JSON.parse(settingsProp);
|
|
|
|
settings = new ActivityPubSettings(parsed);
|
|
|
|
} catch (e) {
|
|
|
|
settings = new ActivityPubSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
user.activityPubSettings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
return user.activityPubSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
persistToUserProperties(user, cb = null) {
|
|
|
|
return user.persistProperty(
|
|
|
|
UserProps.ActivityPubSettings,
|
|
|
|
JSON.stringify(this),
|
|
|
|
cb
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|