2023-02-06 21:34:18 +00:00
|
|
|
const { WellKnownLocations } = require('../servers/content/web');
|
|
|
|
|
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/';
|
|
|
|
|
|
|
|
function makeUserUrl(webServer, user, relPrefix = ActivityPubUsersPrefix) {
|
|
|
|
return webServer.buildUrl(
|
|
|
|
WellKnownLocations.Internal + `${relPrefix}${user.username}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function inbox(webServer, user) {
|
|
|
|
return makeUserUrl(webServer, user, ActivityPubUsersPrefix) + '/inbox';
|
|
|
|
}
|
|
|
|
|
|
|
|
function outbox(webServer, user) {
|
|
|
|
return makeUserUrl(webServer, user, ActivityPubUsersPrefix) + '/outbox';
|
|
|
|
}
|
|
|
|
|
|
|
|
function followers(webServer, user) {
|
|
|
|
return makeUserUrl(webServer, user, ActivityPubUsersPrefix) + '/followers';
|
|
|
|
}
|
|
|
|
|
|
|
|
function following(webServer, user) {
|
|
|
|
return makeUserUrl(webServer, user, ActivityPubUsersPrefix) + '/following';
|
|
|
|
}
|
|
|
|
|
|
|
|
function actorId(webServer, user) {
|
|
|
|
return makeUserUrl(webServer, user, ActivityPubUsersPrefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
function profile(webServer, user) {
|
|
|
|
return webServer.buildUrl(WellKnownLocations.Internal + `/wf/@${user.username}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
function avatar(webServer, user, filename) {
|
2023-02-07 05:45:01 +00:00
|
|
|
return makeUserUrl(webServer, user, '/users/') + `/avatar/${filename}`;
|
2023-02-06 21:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function sharedInbox(webServer) {
|
|
|
|
return webServer.buildUrl(WellKnownLocations.Internal + '/ap/shared-inbox');
|
|
|
|
}
|
2023-02-07 01:27:12 +00:00
|
|
|
|
|
|
|
function objectId(webServer, objectType) {
|
|
|
|
return webServer.buildUrl(
|
|
|
|
WellKnownLocations.Internal + `/ap/${UUIDv4()}/${objectType}`
|
|
|
|
);
|
|
|
|
}
|