2023-02-06 21:34:18 +00:00
|
|
|
const { WellKnownLocations } = require('../servers/content/web');
|
2023-03-18 20:30:37 +00:00
|
|
|
const { buildUrl } = require('../web_util');
|
2023-02-06 21:34:18 +00:00
|
|
|
|
2023-02-07 01:27:12 +00:00
|
|
|
// deps
|
|
|
|
const { v4: UUIDv4 } = require('uuid');
|
|
|
|
|
2023-02-06 21:34:18 +00:00
|
|
|
exports.makeUserUrl = makeUserUrl;
|
|
|
|
exports.inbox = inbox;
|
|
|
|
exports.outbox = outbox;
|
|
|
|
exports.followers = followers;
|
|
|
|
exports.following = following;
|
|
|
|
exports.actorId = actorId;
|
|
|
|
exports.profile = profile;
|
|
|
|
exports.avatar = avatar;
|
|
|
|
exports.sharedInbox = sharedInbox;
|
2023-02-07 01:27:12 +00:00
|
|
|
exports.objectId = objectId;
|
2023-02-06 21:34:18 +00:00
|
|
|
|
|
|
|
const ActivityPubUsersPrefix = '/ap/users/';
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function makeUserUrl(user, relPrefix = ActivityPubUsersPrefix) {
|
|
|
|
return buildUrl(WellKnownLocations.Internal + `${relPrefix}${user.username}`);
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function inbox(user) {
|
|
|
|
return makeUserUrl(user, ActivityPubUsersPrefix) + '/inbox';
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function outbox(user) {
|
|
|
|
return makeUserUrl(user, ActivityPubUsersPrefix) + '/outbox';
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function followers(user) {
|
|
|
|
return makeUserUrl(user, ActivityPubUsersPrefix) + '/followers';
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function following(user) {
|
|
|
|
return makeUserUrl(user, ActivityPubUsersPrefix) + '/following';
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function actorId(user) {
|
|
|
|
return makeUserUrl(user, ActivityPubUsersPrefix);
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function profile(user) {
|
|
|
|
return buildUrl(WellKnownLocations.Internal + `/wf/@${user.username}`);
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function avatar(user, filename) {
|
|
|
|
return makeUserUrl(user, '/users/') + `/avatar/${filename}`;
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function sharedInbox() {
|
|
|
|
return buildUrl(WellKnownLocations.Internal + '/ap/shared-inbox');
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
2023-02-07 01:27:12 +00:00
|
|
|
|
2023-03-18 20:30:37 +00:00
|
|
|
function objectId(objectType) {
|
|
|
|
return buildUrl(WellKnownLocations.Internal + `/ap/${UUIDv4()}/${objectType}`);
|
2023-02-07 01:27:12 +00:00
|
|
|
}
|