Rename actor_id columns to ap_id (#5393)

* Rename actor_id columns to ap_id

* update api tests

* fix

* lint
This commit is contained in:
Nutomic 2025-02-06 03:56:37 +00:00 committed by GitHub
parent 1edc9f922d
commit 20fa90a23c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 1505 additions and 214 deletions

View file

@ -22,15 +22,17 @@
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/joi": "^17.2.3",
"@types/node": "^22.10.7",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"eslint": "^9.18.0",
"eslint-plugin-prettier": "^5.2.3",
"jest": "^29.5.0",
"lemmy-js-client": "0.20.0-search-combined.1",
"lemmy-js-client": "0.20.0-ap-id.1",
"prettier": "^3.4.2",
"ts-jest": "^29.1.0",
"tsoa": "^6.6.0",
"typescript": "^5.7.3",
"typescript-eslint": "^8.21.0"
}

File diff suppressed because it is too large Load diff

View file

@ -69,7 +69,7 @@ function assertCommentFederation(
expect(commentOne?.comment.ap_id).toBe(commentTwo?.comment.ap_id);
expect(commentOne?.comment.content).toBe(commentTwo?.comment.content);
expect(commentOne?.creator.name).toBe(commentTwo?.creator.name);
expect(commentOne?.community.actor_id).toBe(commentTwo?.community.actor_id);
expect(commentOne?.community.ap_id).toBe(commentTwo?.community.ap_id);
expect(commentOne?.comment.published).toBe(commentTwo?.comment.published);
expect(commentOne?.comment.updated).toBe(commentOne?.comment.updated);
expect(commentOne?.comment.deleted).toBe(commentOne?.comment.deleted);
@ -581,7 +581,7 @@ test("A and G subscribe to B (center) A posts, G mentions B, it gets announced t
// follow community from beta so that it accepts the mention
let betaCommunity = await resolveCommunity(
beta,
alphaCommunity.community.actor_id,
alphaCommunity.community.ap_id,
);
await followCommunity(beta, true, betaCommunity.community!.community.id);

View file

@ -44,9 +44,7 @@ function assertCommunityFederation(
communityOne?: CommunityView,
communityTwo?: CommunityView,
) {
expect(communityOne?.community.actor_id).toBe(
communityTwo?.community.actor_id,
);
expect(communityOne?.community.ap_id).toBe(communityTwo?.community.ap_id);
expect(communityOne?.community.name).toBe(communityTwo?.community.name);
expect(communityOne?.community.title).toBe(communityTwo?.community.title);
expect(communityOne?.community.description).toBe(
@ -198,7 +196,7 @@ test("Admin actions in remote community are not federated to origin", async () =
// gamma follows community and posts in it
let gammaCommunity = (
await resolveCommunity(gamma, communityRes.community.actor_id)
await resolveCommunity(gamma, communityRes.community.ap_id)
).community;
if (!gammaCommunity) {
throw "Missing gamma community";
@ -206,7 +204,7 @@ test("Admin actions in remote community are not federated to origin", async () =
await followCommunity(gamma, true, gammaCommunity.community.id);
gammaCommunity = (
await waitUntil(
() => resolveCommunity(gamma, communityRes.community.actor_id),
() => resolveCommunity(gamma, communityRes.community.ap_id),
g => g.community?.subscribed === "Subscribed",
)
).community;
@ -221,7 +219,7 @@ test("Admin actions in remote community are not federated to origin", async () =
// admin of beta decides to ban gamma from community
let betaCommunity = (
await resolveCommunity(beta, communityRes.community.actor_id)
await resolveCommunity(beta, communityRes.community.ap_id)
).community;
if (!betaCommunity) {
throw "Missing beta community";
@ -230,7 +228,7 @@ test("Admin actions in remote community are not federated to origin", async () =
if (!bannedUserInfo1) {
throw "Missing banned user 1";
}
let bannedUserInfo2 = (await resolvePerson(beta, bannedUserInfo1.actor_id))
let bannedUserInfo2 = (await resolvePerson(beta, bannedUserInfo1.ap_id))
.person;
if (!bannedUserInfo2) {
throw "Missing banned user 2";
@ -383,7 +381,7 @@ test("User blocks instance, communities are hidden", async () => {
test.skip("Community follower count is federated", async () => {
// Follow the beta community from alpha
let community = await createCommunity(beta);
let communityActorId = community.community_view.community.actor_id;
let communityActorId = community.community_view.community.ap_id;
let resolved = await resolveCommunity(alpha, communityActorId);
if (!resolved.community) {
throw "Missing beta community";
@ -441,7 +439,7 @@ test("Dont receive community activities after unsubscribe", async () => {
expect(communityRes.community_view.counts.subscribers).toBe(1);
let betaCommunity = (
await resolveCommunity(beta, communityRes.community_view.community.actor_id)
await resolveCommunity(beta, communityRes.community_view.community.ap_id)
).community;
assertCommunityFederation(betaCommunity, communityRes.community_view);
@ -503,13 +501,12 @@ test("Fetch community, includes posts", async () => {
expect(postRes.post_view.post).toBeDefined();
let resolvedCommunity = await waitUntil(
() =>
resolveCommunity(beta, communityRes.community_view.community.actor_id),
() => resolveCommunity(beta, communityRes.community_view.community.ap_id),
c => c.community?.community.id != undefined,
);
let betaCommunity = resolvedCommunity.community;
expect(betaCommunity?.community.actor_id).toBe(
communityRes.community_view.community.actor_id,
expect(betaCommunity?.community.ap_id).toBe(
communityRes.community_view.community.ap_id,
);
await longDelay();
@ -530,7 +527,7 @@ test("Content in local-only community doesn't federate", async () => {
// cant resolve the community from another instance
await expect(
resolveCommunity(beta, communityRes.actor_id),
resolveCommunity(beta, communityRes.ap_id),
).rejects.toStrictEqual(Error("not_found"));
// create a post, also cant resolve it
@ -545,7 +542,7 @@ test("Remote mods can edit communities", async () => {
let betaCommunity = await resolveCommunity(
beta,
communityRes.community_view.community.actor_id,
communityRes.community_view.community.ap_id,
);
if (!betaCommunity.community) {
throw "Missing beta community";
@ -584,7 +581,7 @@ test("Community name with non-ascii chars", async () => {
let betaCommunity1 = await resolveCommunity(
beta,
communityRes.community_view.community.actor_id,
communityRes.community_view.community.ap_id,
);
expect(betaCommunity1.community!.community.name).toBe(name);

View file

@ -75,7 +75,7 @@ test("Upload image and delete it", async () => {
expect(listAllMediaRes.images.length).toBe(previousThumbnails);
// Make sure the uploader is correct
expect(listMediaRes.images[0].person.actor_id).toBe(
expect(listMediaRes.images[0].person.ap_id).toBe(
`http://lemmy-alpha:8541/u/lemmy_alpha`,
);
@ -268,7 +268,7 @@ test("No image proxying if setting is disabled", async () => {
let community = await createCommunity(alpha);
let betaCommunity = await resolveCommunity(
beta,
community.community_view.community.actor_id,
community.community_view.community.ap_id,
);
await followCommunity(beta, true, betaCommunity.community!.community.id);

View file

@ -39,14 +39,12 @@ import {
listReports,
getMyUser,
listInbox,
allowInstance,
} from "./shared";
import { PostView } from "lemmy-js-client/dist/types/PostView";
import { AdminBlockInstanceParams } from "lemmy-js-client/dist/types/AdminBlockInstanceParams";
import {
AddModToCommunity,
EditSite,
LemmyHttp,
PersonPostMentionView,
PostReport,
PostReportView,
@ -98,7 +96,7 @@ async function assertPostFederation(
expect(postOne?.post.embed_description).toBe(postTwo?.post.embed_description);
expect(postOne?.post.embed_video_url).toBe(postTwo?.post.embed_video_url);
expect(postOne?.post.published).toBe(postTwo?.post.published);
expect(postOne?.community.actor_id).toBe(postTwo?.community.actor_id);
expect(postOne?.community.ap_id).toBe(postTwo?.community.ap_id);
expect(postOne?.post.locked).toBe(postTwo?.post.locked);
expect(postOne?.post.removed).toBe(postTwo?.post.removed);
expect(postOne?.post.deleted).toBe(postTwo?.post.deleted);
@ -262,7 +260,7 @@ test("Collection of featured posts gets federated", async () => {
// fetch the community, ensure that post is also fetched and marked as featured
let betaCommunity = await resolveCommunity(
beta,
community.community_view.community.actor_id,
community.community_view.community.ap_id,
);
expect(betaCommunity).toBeDefined();
@ -368,7 +366,7 @@ test("Remove a post from admin and community on different instance", async () =>
}
let gammaCommunity = (
await resolveCommunity(gamma, betaCommunity.community.actor_id)
await resolveCommunity(gamma, betaCommunity.community.ap_id)
).community?.community;
if (!gammaCommunity) {
throw "Missing gamma community";
@ -407,7 +405,7 @@ test("Remove a post from admin and community on same instance", async () => {
await followBeta(alpha);
let gammaCommunity = await resolveCommunity(
gamma,
betaCommunity.community.actor_id,
betaCommunity.community.ap_id,
);
let postRes = await createPost(gamma, gammaCommunity.community!.community.id);
expect(postRes.post_view.post).toBeDefined();
@ -469,7 +467,7 @@ test("Enforce site ban federation for local user", async () => {
// create a test user
let alphaUserHttp = await registerUser(alpha, alphaUrl);
let alphaUserPerson = (await getMyUser(alphaUserHttp)).local_user_view.person;
let alphaUserActorId = alphaUserPerson?.actor_id;
let alphaUserActorId = alphaUserPerson?.ap_id;
if (!alphaUserActorId) {
throw "Missing alpha user actor id";
}
@ -549,7 +547,7 @@ test("Enforce site ban federation for federated user", async () => {
// create a test user
let alphaUserHttp = await registerUser(alpha, alphaUrl);
let alphaUserPerson = (await getMyUser(alphaUserHttp)).local_user_view.person;
let alphaUserActorId = alphaUserPerson?.actor_id;
let alphaUserActorId = alphaUserPerson?.ap_id;
if (!alphaUserActorId) {
throw "Missing alpha user actor id";
}

View file

@ -47,7 +47,7 @@ test("Follow a private community", async () => {
// follow as new user
const user = await registerUser(beta, betaUrl);
const betaCommunity = (
await resolveCommunity(user, community.community_view.community.actor_id)
await resolveCommunity(user, community.community_view.community.ap_id)
).community;
expect(betaCommunity).toBeDefined();
expect(betaCommunity?.community.visibility).toBe("Private");
@ -134,7 +134,7 @@ test("Only followers can view and interact with private community content", asyn
// user is not following the community and cannot view nor create posts
const user = await registerUser(beta, betaUrl);
const betaCommunity = (
await resolveCommunity(user, community.community_view.community.actor_id)
await resolveCommunity(user, community.community_view.community.ap_id)
).community!.community;
await expect(resolvePost(user, post0.post_view.post)).rejects.toStrictEqual(
Error("not_found"),
@ -179,7 +179,7 @@ test("Reject follower", async () => {
// user is not following the community and cannot view nor create posts
const user = await registerUser(beta, betaUrl);
const betaCommunity1 = (
await resolveCommunity(user, community.community_view.community.actor_id)
await resolveCommunity(user, community.community_view.community.ap_id)
).community!.community;
// follow the community and reject
@ -216,7 +216,7 @@ test("Follow a private community and receive activities", async () => {
// follow with users from beta and gamma
const betaCommunity = (
await resolveCommunity(beta, community.community_view.community.actor_id)
await resolveCommunity(beta, community.community_view.community.ap_id)
).community;
expect(betaCommunity).toBeDefined();
const betaCommunityId = betaCommunity!.community.id;
@ -228,7 +228,7 @@ test("Follow a private community and receive activities", async () => {
await approveFollower(alpha, alphaCommunityId);
const gammaCommunityId = (
await resolveCommunity(gamma, community.community_view.community.actor_id)
await resolveCommunity(gamma, community.community_view.community.ap_id)
).community!.community.id;
const follow_form_gamma: FollowCommunity = {
community_id: gammaCommunityId,
@ -281,7 +281,7 @@ test("Fetch remote content in private community", async () => {
const alphaCommunityId = community.community_view.community.id;
const betaCommunityId = (
await resolveCommunity(beta, community.community_view.community.actor_id)
await resolveCommunity(beta, community.community_view.community.ap_id)
).community!.community.id;
const follow_form_beta: FollowCommunity = {
community_id: betaCommunityId,
@ -312,7 +312,7 @@ test("Fetch remote content in private community", async () => {
// create gamma user
const gammaCommunityId = (
await resolveCommunity(gamma, community.community_view.community.actor_id)
await resolveCommunity(gamma, community.community_view.community.ap_id)
).community!.community.id;
const follow_form: FollowCommunity = {
community_id: gammaCommunityId,

View file

@ -83,6 +83,7 @@ import { GetPosts } from "lemmy-js-client/dist/types/GetPosts";
import { GetPersonDetailsResponse } from "lemmy-js-client/dist/types/GetPersonDetailsResponse";
import { GetPersonDetails } from "lemmy-js-client/dist/types/GetPersonDetails";
import { ListingType } from "lemmy-js-client/dist/types/ListingType";
import { GetCommunityPendingFollowsCountI } from "lemmy-js-client/dist/other_types";
export const fetchFunction = fetch;
export const imageFetchLimit = 50;
@ -882,7 +883,8 @@ export function getCommunityPendingFollowsCount(
api: LemmyHttp,
community_id: CommunityId,
): Promise<GetCommunityPendingFollowsCountResponse> {
return api.getCommunityPendingFollowsCount(community_id);
let form: GetCommunityPendingFollowsCountI = { community_id };
return api.getCommunityPendingFollowsCount(form);
}
export function approveCommunityPendingFollow(

View file

@ -41,7 +41,7 @@ function assertUserFederation(userOne?: PersonView, userTwo?: PersonView) {
expect(userOne?.person.name).toBe(userTwo?.person.name);
expect(userOne?.person.display_name).toBe(userTwo?.person.display_name);
expect(userOne?.person.bio).toBe(userTwo?.person.bio);
expect(userOne?.person.actor_id).toBe(userTwo?.person.actor_id);
expect(userOne?.person.ap_id).toBe(userTwo?.person.ap_id);
expect(userOne?.person.avatar).toBe(userTwo?.person.avatar);
expect(userOne?.person.banner).toBe(userTwo?.person.banner);
expect(userOne?.person.published).toBe(userTwo?.person.published);

View file

@ -568,7 +568,7 @@ pub async fn send_application_approved_email(
.clone()
.ok_or(LemmyErrorType::EmailRequired)?;
let lang = get_interface_language(user);
let subject = lang.registration_approved_subject(&user.person.actor_id);
let subject = lang.registration_approved_subject(&user.person.ap_id);
let body = lang.registration_approved_body(&settings.hostname);
send_email(&subject, email, &user.person.name, &body, settings).await
}
@ -633,14 +633,14 @@ pub fn check_private_instance_and_federation_enabled(local_site: &LocalSite) ->
}
}
/// Read the site for an actor_id.
/// Read the site for an ap_id.
///
/// Used for GetCommunityResponse and GetPersonDetails
pub async fn read_site_for_actor(
actor_id: DbUrl,
ap_id: DbUrl,
context: &LemmyContext,
) -> LemmyResult<Option<Site>> {
let site_id = Site::instance_actor_id_from_url(actor_id.clone().into());
let site_id = Site::instance_ap_id_from_url(ap_id.clone().into());
let site = Site::read_from_apub_id(&mut context.pool(), &site_id.into()).await?;
Ok(site)
}
@ -979,8 +979,8 @@ pub fn generate_local_apub_endpoint(
Ok(Url::parse(&format!("{domain}/{point}/{name}"))?.into())
}
pub fn generate_followers_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{actor_id}/followers"))?.into())
pub fn generate_followers_url(ap_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{ap_id}/followers"))?.into())
}
pub fn generate_inbox_url() -> LemmyResult<DbUrl> {
@ -988,12 +988,12 @@ pub fn generate_inbox_url() -> LemmyResult<DbUrl> {
Ok(Url::parse(&url)?.into())
}
pub fn generate_outbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{actor_id}/outbox"))?.into())
pub fn generate_outbox_url(ap_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{ap_id}/outbox"))?.into())
}
pub fn generate_featured_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{actor_id}/featured"))?.into())
pub fn generate_featured_url(ap_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{ap_id}/featured"))?.into())
}
pub fn generate_moderators_url(community_id: &DbUrl) -> LemmyResult<DbUrl> {

View file

@ -81,14 +81,13 @@ pub async fn create_community(
check_community_visibility_allowed(data.visibility, &local_user_view)?;
// Double check for duplicate community actor_ids
let community_actor_id = generate_local_apub_endpoint(
// Double check for duplicate community ap_ids
let community_ap_id = generate_local_apub_endpoint(
EndpointType::Community,
&data.name,
&context.settings().get_protocol_and_hostname(),
)?;
let community_dupe =
Community::read_from_apub_id(&mut context.pool(), &community_actor_id).await?;
let community_dupe = Community::read_from_apub_id(&mut context.pool(), &community_ap_id).await?;
if community_dupe.is_some() {
Err(LemmyErrorType::CommunityAlreadyExists)?
}
@ -100,9 +99,9 @@ pub async fn create_community(
sidebar,
description,
nsfw: data.nsfw,
actor_id: Some(community_actor_id.clone()),
ap_id: Some(community_ap_id.clone()),
private_key: Some(keypair.private_key),
followers_url: Some(generate_followers_url(&community_actor_id)?),
followers_url: Some(generate_followers_url(&community_ap_id)?),
inbox_url: Some(generate_inbox_url()?),
posting_restricted_to_mods: data.posting_restricted_to_mods,
visibility: data.visibility,

View file

@ -53,7 +53,7 @@ pub async fn create_site(
validate_create_payload(&local_site, &data)?;
let actor_id: DbUrl = Url::parse(&context.settings().get_protocol_and_hostname())?.into();
let ap_id: DbUrl = Url::parse(&context.settings().get_protocol_and_hostname())?.into();
let inbox_url = Some(generate_inbox_url()?);
let keypair = generate_actor_keypair()?;
@ -65,7 +65,7 @@ pub async fn create_site(
name: Some(data.name.clone()),
sidebar: diesel_string_update(sidebar.as_deref()),
description: diesel_string_update(data.description.as_deref()),
actor_id: Some(actor_id),
ap_id: Some(ap_id),
last_refreshed_at: Some(Utc::now()),
inbox_url,
private_key: Some(Some(keypair.private_key)),

View file

@ -414,7 +414,7 @@ async fn create_person(
) -> Result<Person, LemmyError> {
let actor_keypair = generate_actor_keypair()?;
is_valid_actor_name(&username, local_site.actor_name_max_length as usize)?;
let actor_id = generate_local_apub_endpoint(
let ap_id = generate_local_apub_endpoint(
EndpointType::Person,
&username,
&context.settings().get_protocol_and_hostname(),
@ -422,7 +422,7 @@ async fn create_person(
// Register the new person
let person_form = PersonInsertForm {
actor_id: Some(actor_id.clone()),
ap_id: Some(ap_id.clone()),
inbox_url: Some(generate_inbox_url()?),
private_key: Some(actor_keypair.private_key),
..PersonInsertForm::new(username.clone(), actor_keypair.public_key, instance_id)

View file

@ -110,8 +110,8 @@ impl Object for SiteOrCommunity {
impl SiteOrCommunity {
fn id(&self) -> ObjectId<SiteOrCommunity> {
match self {
SiteOrCommunity::Site(s) => ObjectId::from(s.actor_id.clone()),
SiteOrCommunity::Community(c) => ObjectId::from(c.actor_id.clone()),
SiteOrCommunity::Site(s) => ObjectId::from(s.ap_id.clone()),
SiteOrCommunity::Community(c) => ObjectId::from(c.ap_id.clone()),
}
}
}
@ -121,7 +121,7 @@ async fn generate_cc(target: &SiteOrCommunity, pool: &mut DbPool<'_>) -> LemmyRe
SiteOrCommunity::Site(_) => Site::read_remote_sites(pool)
.await?
.into_iter()
.map(|s| s.actor_id.into())
.map(|s| s.ap_id.into())
.collect(),
SiteOrCommunity::Community(c) => vec![c.id()],
})

View file

@ -62,13 +62,13 @@ impl ActivityHandler for RawAnnouncableActivities {
// verify and receive activity
activity.verify(context).await?;
let actor_id = activity.actor().clone().into();
let ap_id = activity.actor().clone().into();
activity.receive(context).await?;
// if community is local, send activity to followers
if let Some(community) = community {
if community.local {
verify_person_in_community(&actor_id, &community, context).await?;
verify_person_in_community(&ap_id, &community, context).await?;
AnnounceActivity::send(self, &community, context).await?;
}
}

View file

@ -55,7 +55,7 @@ impl CollectionAdd {
actor: actor.id().into(),
to: generate_to(community)?,
object: added_mod.id(),
target: generate_moderators_url(&community.actor_id)?.into(),
target: generate_moderators_url(&community.ap_id)?.into(),
cc: vec![community.id()],
kind: AddType::Add,
id: id.clone(),
@ -80,7 +80,7 @@ impl CollectionAdd {
actor: actor.id().into(),
to: generate_to(community)?,
object: featured_post.ap_id.clone().into(),
target: generate_featured_url(&community.actor_id)?.into(),
target: generate_featured_url(&community.ap_id)?.into(),
cc: vec![community.id()],
kind: AddType::Add,
id: id.clone(),

View file

@ -50,7 +50,7 @@ impl CollectionRemove {
actor: actor.id().into(),
to: generate_to(community)?,
object: removed_mod.id(),
target: generate_moderators_url(&community.actor_id)?.into(),
target: generate_moderators_url(&community.ap_id)?.into(),
id: id.clone(),
cc: vec![community.id()],
kind: RemoveType::Remove,
@ -75,7 +75,7 @@ impl CollectionRemove {
actor: actor.id().into(),
to: generate_to(community)?,
object: featured_post.ap_id.clone().into(),
target: generate_featured_url(&community.actor_id)?.into(),
target: generate_featured_url(&community.ap_id)?.into(),
cc: vec![community.id()],
kind: RemoveType::Remove,
id: id.clone(),

View file

@ -135,9 +135,9 @@ pub(crate) async fn send_lock_post(
LockType::Lock,
&context.settings().get_protocol_and_hostname(),
)?;
let community_id = community.actor_id.inner().clone();
let community_id = community.ap_id.inner().clone();
let lock = LockPage {
actor: actor.actor_id.clone().into(),
actor: actor.ap_id.clone().into(),
to: generate_to(&community)?,
object: ObjectId::from(post.ap_id),
cc: vec![community_id.clone()],

View file

@ -80,7 +80,7 @@ impl ActivityHandler for UpdateCommunity {
verify_visibility(&self.to, &self.cc, &community)?;
verify_person_in_community(&self.actor, &community, context).await?;
verify_mod_action(&self.actor, &community, context).await?;
ApubCommunity::verify(&self.object, &community.actor_id.clone().into(), context).await?;
ApubCommunity::verify(&self.object, &community.ap_id.clone().into(), context).await?;
Ok(())
}
@ -98,7 +98,7 @@ impl ActivityHandler for UpdateCommunity {
published: self.object.published,
updated: Some(self.object.updated),
nsfw: Some(self.object.sensitive.unwrap_or(false)),
actor_id: Some(self.object.id.into()),
ap_id: Some(self.object.id.into()),
public_key: Some(self.object.public_key.public_key_pem),
last_refreshed_at: Some(Utc::now()),
icon: Some(self.object.icon.map(|i| i.url.into())),

View file

@ -91,9 +91,9 @@ impl Delete {
DeleteType::Delete,
&context.settings().get_protocol_and_hostname(),
)?;
let cc: Option<Url> = community.map(|c| c.actor_id.clone().into());
let cc: Option<Url> = community.map(|c| c.ap_id.clone().into());
Ok(Delete {
actor: actor.actor_id.clone().into(),
actor: actor.ap_id.clone().into(),
to,
object: IdOrNestedObject::Id(object.id()),
cc: cc.into_iter().collect(),

View file

@ -180,7 +180,7 @@ pub(in crate::activities) async fn verify_delete_activity(
DeletableObjects::Person(person) => {
verify_is_public(&activity.to, &[])?;
verify_person(&activity.actor, context).await?;
verify_urls_match(person.actor_id.inner(), activity.object.id())?;
verify_urls_match(person.ap_id.inner(), activity.object.id())?;
}
DeletableObjects::Post(p) => {
let community = activity.community(context).await?;

View file

@ -77,9 +77,9 @@ impl UndoDelete {
UndoType::Undo,
&context.settings().get_protocol_and_hostname(),
)?;
let cc: Option<Url> = community.map(|c| c.actor_id.clone().into());
let cc: Option<Url> = community.map(|c| c.ap_id.clone().into());
Ok(UndoDelete {
actor: actor.actor_id.clone().into(),
actor: actor.ap_id.clone().into(),
to,
object,
cc: cc.into_iter().collect(),

View file

@ -47,9 +47,9 @@ pub async fn send_accept_or_reject_follow(
let person = Person::read(&mut context.pool(), person_id).await?;
let follow = Follow {
actor: person.actor_id.into(),
to: Some([community.actor_id.clone().into()]),
object: community.actor_id.into(),
actor: person.ap_id.into(),
to: Some([community.ap_id.clone().into()]),
object: community.ap_id.into(),
kind: FollowType::Follow,
id: generate_activity_id(
FollowType::Follow,

View file

@ -82,7 +82,7 @@ pub(crate) async fn verify_person_in_community(
let person = person_id.dereference(context).await?;
if person.banned {
Err(FederationError::PersonIsBannedFromSite(
person.actor_id.to_string(),
person.ap_id.to_string(),
))?
}
let person_id = person.id;
@ -103,7 +103,7 @@ pub(crate) async fn verify_mod_action(
// mod action comes from the same instance as the community, so it was presumably done
// by an instance admin.
// TODO: federate instance admin status and check it here
if mod_id.inner().domain() == community.actor_id.domain() {
if mod_id.inner().domain() == community.ap_id.domain() {
return Ok(());
}
@ -134,13 +134,13 @@ pub(crate) fn verify_visibility(to: &[Url], cc: &[Url], community: &Community) -
/// Marks object as public only if the community is public
pub(crate) fn generate_to(community: &Community) -> LemmyResult<Vec<Url>> {
let actor_id = community.actor_id.clone().into();
let ap_id = community.ap_id.clone().into();
if community.visibility == CommunityVisibility::Public {
Ok(vec![actor_id, public()])
Ok(vec![ap_id, public()])
} else {
Ok(vec![
actor_id.clone(),
Url::parse(&format!("{}/followers", actor_id))?,
ap_id.clone(),
Url::parse(&format!("{}/followers", ap_id))?,
])
}
}

View file

@ -1,7 +1,7 @@
use super::comment_sort_type_with_default;
use crate::{
api::listing_type_with_default,
fetcher::resolve_actor_identifier,
fetcher::resolve_ap_identifier,
objects::community::ApubCommunity,
};
use activitypub_federation::config::Data;
@ -32,7 +32,7 @@ async fn list_comments_common(
let community_id = if let Some(name) = &data.community_name {
Some(
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
resolve_ap_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
.await?,
)
.map(|c| c.id)

View file

@ -1,6 +1,6 @@
use crate::{
api::{listing_type_with_default, post_sort_type_with_default},
fetcher::resolve_actor_identifier,
fetcher::resolve_ap_identifier,
objects::community::ApubCommunity,
};
use activitypub_federation::config::Data;
@ -33,7 +33,7 @@ pub async fn list_posts(
let limit = data.limit;
let community_id = if let Some(name) = &data.community_name {
Some(
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
resolve_ap_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
.await?,
)
.map(|c| c.id)

View file

@ -1,4 +1,4 @@
use crate::{fetcher::resolve_actor_identifier, objects::person::ApubPerson};
use crate::{fetcher::resolve_ap_identifier, objects::person::ApubPerson};
use activitypub_federation::config::Data;
use lemmy_api_common::{context::LemmyContext, LemmyErrorType};
use lemmy_db_schema::{
@ -83,7 +83,7 @@ async fn resolve_person_id_from_id_or_username(
Some(id) => *id,
None => {
if let Some(username) = username {
resolve_actor_identifier::<ApubPerson, Person>(username, context, local_user_view, true)
resolve_ap_identifier::<ApubPerson, Person>(username, context, local_user_view, true)
.await?
.id
} else {

View file

@ -1,4 +1,4 @@
use crate::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
use crate::{fetcher::resolve_ap_identifier, objects::community::ApubCommunity};
use activitypub_federation::config::Data;
use actix_web::web::{Json, Query};
use lemmy_api_common::{
@ -33,7 +33,7 @@ pub async fn get_community(
Some(id) => id,
None => {
let name = data.name.clone().unwrap_or_else(|| "main".to_string());
resolve_actor_identifier::<ApubCommunity, Community>(&name, &context, &local_user_view, true)
resolve_ap_identifier::<ApubCommunity, Community>(&name, &context, &local_user_view, true)
.await?
.id
}
@ -57,7 +57,7 @@ pub async fn get_community(
let moderators = CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
let site = read_site_for_actor(community_view.community.actor_id.clone(), &context).await?;
let site = read_site_for_actor(community_view.community.ap_id.clone(), &context).await?;
let community_id = community_view.community.id;
let discussion_languages = CommunityLanguage::read(&mut context.pool(), community_id).await?;

View file

@ -40,7 +40,7 @@ pub async fn read_person(
)
.await?;
let site = read_site_for_actor(person_view.person.actor_id.clone(), &context).await?;
let site = read_site_for_actor(person_view.person.ap_id.clone(), &context).await?;
Ok(Json(GetPersonDetailsResponse {
person_view,

View file

@ -1,4 +1,4 @@
use crate::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
use crate::{fetcher::resolve_ap_identifier, objects::community::ApubCommunity};
use activitypub_federation::config::Data;
use actix_web::web::{Json, Query};
use lemmy_api_common::{
@ -25,7 +25,7 @@ pub async fn search(
let community_id = if let Some(name) = &data.community_name {
Some(
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, false)
resolve_ap_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, false)
.await?,
)
.map(|c| c.id)

View file

@ -368,7 +368,7 @@ pub(crate) mod tests {
let follows = CommunityFollowerView::for_person(pool, import_user.person.id).await?;
assert_eq!(follows.len(), 1);
assert_eq!(follows[0].community.actor_id, community.actor_id);
assert_eq!(follows[0].community.ap_id, community.ap_id);
Person::delete(pool, export_user.person.id).await?;
Person::delete(pool, import_user.person.id).await?;

View file

@ -41,7 +41,7 @@ impl Collection for ApubCommunityFeatured {
.await?;
Ok(GroupFeatured {
r#type: OrderedCollectionType::OrderedCollection,
id: generate_featured_url(&owner.actor_id)?.into(),
id: generate_featured_url(&owner.ap_id)?.into(),
total_items: ordered_items.len() as i32,
ordered_items,
})

View file

@ -33,7 +33,7 @@ impl Collection for ApubCommunityFollower {
CommunityFollowerView::count_community_followers(&mut context.pool(), community_id).await?;
Ok(GroupFollowers {
id: generate_followers_url(&community.actor_id)?.into(),
id: generate_followers_url(&community.ap_id)?.into(),
r#type: CollectionType::Collection,
total_items: community_followers as i32,
items: vec![],

View file

@ -32,11 +32,11 @@ impl Collection for ApubCommunityModerators {
let moderators = CommunityModeratorView::for_community(&mut data.pool(), owner.id).await?;
let ordered_items = moderators
.into_iter()
.map(|m| ObjectId::<ApubPerson>::from(m.moderator.actor_id))
.map(|m| ObjectId::<ApubPerson>::from(m.moderator.ap_id))
.collect();
Ok(GroupModerators {
r#type: OrderedCollectionType::OrderedCollection,
id: generate_moderators_url(&owner.actor_id)?.into(),
id: generate_moderators_url(&owner.ap_id)?.into(),
ordered_items,
})
}
@ -60,7 +60,7 @@ impl Collection for ApubCommunityModerators {
CommunityModeratorView::for_community(&mut data.pool(), community_id).await?;
// Remove old mods from database which arent in the moderators collection anymore
for mod_user in &current_moderators {
let mod_id = ObjectId::from(mod_user.moderator.actor_id.clone());
let mod_id = ObjectId::from(mod_user.moderator.ap_id.clone());
if !apub.ordered_items.contains(&mod_id) {
let community_moderator_form = CommunityModeratorForm {
community_id: mod_user.community.id,
@ -77,8 +77,8 @@ impl Collection for ApubCommunityModerators {
if let Some(mod_user) = mod_user {
if !current_moderators
.iter()
.map(|c| c.moderator.actor_id.clone())
.any(|x| x == mod_user.actor_id)
.map(|c| c.moderator.ap_id.clone())
.any(|x| x == mod_user.ap_id)
{
let community_moderator_form = CommunityModeratorForm {
community_id: owner.id,
@ -136,7 +136,7 @@ mod tests {
CommunityModerator::join(&mut context.pool(), &community_moderator_form).await?;
assert_eq!(site.actor_id.to_string(), "https://enterprise.lemmy.ml/");
assert_eq!(site.ap_id.to_string(), "https://enterprise.lemmy.ml/");
let json: GroupModerators =
file_to_json_object("assets/lemmy/collections/group_moderators.json")?;

View file

@ -62,7 +62,7 @@ impl Collection for ApubCommunityOutbox {
Ok(GroupOutbox {
r#type: OrderedCollectionType::OrderedCollection,
id: generate_outbox_url(&owner.actor_id)?.into(),
id: generate_outbox_url(&owner.ap_id)?.into(),
total_items: ordered_items.len() as i32,
ordered_items,
})

View file

@ -150,7 +150,7 @@ mod tests {
),
(
"rewrite community link",
format!("[link]({})", community.actor_id),
format!("[link]({})", community.ap_id),
"[link](https://lemmy-alpha/c/my_community@example.com)",
),
(

View file

@ -20,7 +20,7 @@ pub mod user_or_community;
///
/// In case the requesting user is logged in and the object was not found locally, it is attempted
/// to fetch via webfinger from the original instance.
pub async fn resolve_actor_identifier<ActorType, DbActor>(
pub async fn resolve_ap_identifier<ActorType, DbActor>(
identifier: &str,
context: &Data<LemmyContext>,
local_user_view: &Option<LocalUserView>,

View file

@ -49,7 +49,7 @@ pub(crate) async fn get_apub_community_http(
.into();
if community.deleted || community.removed {
return create_apub_tombstone_response(community.actor_id.clone());
return create_apub_tombstone_response(community.ap_id.clone());
}
check_community_fetchable(&community)?;

View file

@ -32,7 +32,7 @@ pub(crate) async fn get_apub_person_http(
create_apub_response(&apub)
} else {
create_apub_tombstone_response(person.actor_id.clone())
create_apub_tombstone_response(person.ap_id.clone())
}
}
@ -43,7 +43,7 @@ pub(crate) async fn get_apub_person_outbox(
let person = Person::read_from_name(&mut context.pool(), &info.user_name, false)
.await?
.ok_or(LemmyErrorType::NotFound)?;
let outbox_id = generate_outbox_url(&person.actor_id)?.into();
let outbox_id = generate_outbox_url(&person.ap_id)?.into();
let outbox = EmptyOutbox::new(outbox_id)?;
create_apub_response(&outbox)
}

View file

@ -51,7 +51,7 @@ pub async fn collect_non_local_mentions(
// Add the mention tag
let parent_creator_tag = Mention {
href: parent_creator.actor_id.clone().into(),
href: parent_creator.ap_id.clone().into(),
name: Some(format!(
"@{}@{}",
&parent_creator.name,
@ -74,7 +74,7 @@ pub async fn collect_non_local_mentions(
let identifier = format!("{}@{}", mention.name, mention.domain);
let person = webfinger_resolve_actor::<LemmyContext, ApubPerson>(&identifier, context).await;
if let Ok(person) = person {
addressed_ccs.push(person.actor_id.to_string().parse()?);
addressed_ccs.push(person.ap_id.to_string().parse()?);
let mention_tag = Mention {
href: person.id(),

View file

@ -110,7 +110,7 @@ impl Object for ApubComment {
let note = Note {
r#type: NoteType::Note,
id: self.ap_id.clone().into(),
attributed_to: creator.actor_id.into(),
attributed_to: creator.ap_id.into(),
to: generate_to(&community)?,
cc: maa.ccs,
content: markdown_to_html(&self.content),

View file

@ -109,9 +109,9 @@ impl Object for ApubCommunity {
icon: self.icon.clone().map(ImageObject::new),
image: self.banner.clone().map(ImageObject::new),
sensitive: Some(self.nsfw),
featured: Some(generate_featured_url(&self.actor_id)?.into()),
featured: Some(generate_featured_url(&self.ap_id)?.into()),
inbox: self.inbox_url.clone().into(),
outbox: generate_outbox_url(&self.actor_id)?.into(),
outbox: generate_outbox_url(&self.ap_id)?.into(),
followers: self.followers_url.clone().map(Into::into),
endpoints: None,
public_key: self.public_key(),
@ -119,7 +119,7 @@ impl Object for ApubCommunity {
published: Some(self.published),
updated: self.updated,
posting_restricted_to_mods: Some(self.posting_restricted_to_mods),
attributed_to: Some(generate_moderators_url(&self.actor_id)?.into()),
attributed_to: Some(generate_moderators_url(&self.ap_id)?.into()),
manually_approves_followers: Some(self.visibility == CommunityVisibility::Private),
};
Ok(group)
@ -156,7 +156,7 @@ impl Object for ApubCommunity {
updated: group.updated,
deleted: Some(false),
nsfw: Some(group.sensitive.unwrap_or(false)),
actor_id: Some(group.id.into()),
ap_id: Some(group.id.into()),
local: Some(false),
last_refreshed_at: Some(Utc::now()),
icon,
@ -214,7 +214,7 @@ impl Object for ApubCommunity {
impl Actor for ApubCommunity {
fn id(&self) -> Url {
self.actor_id.inner().clone()
self.ap_id.inner().clone()
}
fn public_key_pem(&self) -> &str {

View file

@ -108,7 +108,7 @@ impl Object for ApubSite {
icon: self.icon.clone().map(ImageObject::new),
image: self.banner.clone().map(ImageObject::new),
inbox: self.inbox_url.clone().into(),
outbox: Url::parse(&format!("{}site_outbox", self.actor_id))?,
outbox: Url::parse(&format!("{}site_outbox", self.ap_id))?,
public_key: self.public_key(),
language,
content_warning: self.content_warning.clone(),
@ -159,7 +159,7 @@ impl Object for ApubSite {
icon,
banner,
description: apub.summary,
actor_id: Some(apub.id.clone().into()),
ap_id: Some(apub.id.clone().into()),
last_refreshed_at: Some(Utc::now()),
inbox_url: Some(apub.inbox.clone().into()),
public_key: Some(apub.public_key.public_key_pem.clone()),
@ -178,7 +178,7 @@ impl Object for ApubSite {
impl Actor for ApubSite {
fn id(&self) -> Url {
self.actor_id.inner().clone()
self.ap_id.inner().clone()
}
fn public_key_pem(&self) -> &str {
@ -205,7 +205,7 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object<T: Into<Url> + C
context: &Data<LemmyContext>,
) -> LemmyResult<InstanceId> {
let object_id: Url = object_id.clone().into();
let instance_id = Site::instance_actor_id_from_url(object_id);
let instance_id = Site::instance_ap_id_from_url(object_id);
let site = ObjectId::<ApubSite>::from(instance_id.clone())
.dereference(context)
.await;

View file

@ -100,7 +100,7 @@ impl Object for ApubPerson {
let person = Person {
kind,
id: self.actor_id.clone().into(),
id: self.ap_id.clone().into(),
preferred_username: self.name.clone(),
name: self.display_name.clone(),
summary: self.bio.as_ref().map(|b| markdown_to_html(b)),
@ -109,7 +109,7 @@ impl Object for ApubPerson {
image: self.banner.clone().map(ImageObject::new),
matrix_user_id: self.matrix_user_id.clone(),
published: Some(self.published),
outbox: generate_outbox_url(&self.actor_id)?.into(),
outbox: generate_outbox_url(&self.ap_id)?.into(),
endpoints: None,
public_key: self.public_key(),
updated: self.updated,
@ -163,7 +163,7 @@ impl Object for ApubPerson {
banner,
published: person.published,
updated: person.updated,
actor_id: Some(person.id.into()),
ap_id: Some(person.id.into()),
bio,
local: Some(false),
bot_account: Some(person.kind == UserTypes::Service),
@ -188,7 +188,7 @@ impl Object for ApubPerson {
impl Actor for ApubPerson {
fn id(&self) -> Url {
self.actor_id.inner().clone()
self.ap_id.inner().clone()
}
fn public_key_pem(&self) -> &str {
@ -268,7 +268,7 @@ pub(crate) mod tests {
ApubPerson::verify(&json, &url, &context).await?;
let person = ApubPerson::from_json(json, &context).await?;
assert_eq!(person.actor_id, url.into());
assert_eq!(person.ap_id, url.into());
assert_eq!(person.name, "lanodan");
assert!(!person.local);
assert_eq!(context.request_count(), 0);

View file

@ -133,7 +133,7 @@ impl Object for ApubPost {
let page = Page {
kind: PageType::Page,
id: self.ap_id.clone().into(),
attributed_to: AttributedTo::Lemmy(creator.actor_id.into()),
attributed_to: AttributedTo::Lemmy(creator.ap_id.into()),
to: generate_to(&community)?,
cc: vec![],
name: Some(self.name.clone()),

View file

@ -107,8 +107,8 @@ impl Object for ApubPrivateMessage {
let note = PrivateMessage {
kind,
id: self.ap_id.clone().into(),
attributed_to: creator.actor_id.into(),
to: [recipient.actor_id.into()],
attributed_to: creator.ap_id.into(),
to: [recipient.ap_id.into()],
content: markdown_to_html(&self.content),
media_type: Some(MediaTypeHtml::Html),
source: Some(Source::new(self.content.clone())),
@ -131,7 +131,7 @@ impl Object for ApubPrivateMessage {
let person = note.attributed_to.dereference(context).await?;
if person.banned {
Err(FederationError::PersonIsBannedFromSite(
person.actor_id.to_string(),
person.ap_id.to_string(),
))?
} else {
Ok(())

View file

@ -192,7 +192,7 @@ fn site() -> LemmyResult<Site> {
icon: None,
banner: None,
description: None,
actor_id: Url::parse("http://example.com")?.into(),
ap_id: Url::parse("http://example.com")?.into(),
last_refreshed_at: Default::default(),
inbox_url: Url::parse("http://example.com")?.into(),
private_key: None,

View file

@ -133,7 +133,7 @@ impl Community {
timestamp: DateTime<Utc>,
form: &CommunityInsertForm,
) -> Result<Self, Error> {
let is_new_community = match &form.actor_id {
let is_new_community = match &form.ap_id {
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
None => true,
};
@ -142,7 +142,7 @@ impl Community {
// Can't do separate insert/update commands because InsertForm/UpdateForm aren't convertible
let community_ = insert_into(community::table)
.values(form)
.on_conflict(community::actor_id)
.on_conflict(community::ap_id)
.filter_target(coalesce(community::updated, community::published).lt(timestamp))
.do_update()
.set(form)
@ -500,7 +500,7 @@ impl ApubActor for Community {
) -> Result<Option<Self>, Error> {
let conn = &mut get_conn(pool).await?;
community::table
.filter(community::actor_id.eq(object_id))
.filter(community::ap_id.eq(object_id))
.first(conn)
.await
.optional()
@ -600,7 +600,7 @@ mod tests {
deleted: false,
published: inserted_community.published,
updated: None,
actor_id: inserted_community.actor_id.clone(),
ap_id: inserted_community.ap_id.clone(),
local: true,
private_key: None,
public_key: "pubkey".to_owned(),

View file

@ -171,7 +171,7 @@ impl LocalUser {
.filter(community_actions::followed.is_not_null())
.filter(community_actions::person_id.eq(person_id_))
.inner_join(community::table)
.select(community::actor_id)
.select(community::ap_id)
.get_results(conn)
.await?;
@ -195,7 +195,7 @@ impl LocalUser {
.filter(community_actions::blocked.is_not_null())
.filter(community_actions::person_id.eq(person_id_))
.inner_join(community::table)
.select(community::actor_id)
.select(community::ap_id)
.get_results(conn)
.await?;
@ -203,7 +203,7 @@ impl LocalUser {
.filter(person_actions::blocked.is_not_null())
.filter(person_actions::person_id.eq(person_id_))
.inner_join(person::table.on(person_actions::target_id.eq(person::id)))
.select(person::actor_id)
.select(person::ap_id)
.get_results(conn)
.await?;

View file

@ -71,7 +71,7 @@ impl Person {
let conn = &mut get_conn(pool).await?;
insert_into(person::table)
.values(form)
.on_conflict(person::actor_id)
.on_conflict(person::ap_id)
.do_update()
.set(form)
.get_result::<Self>(conn)
@ -155,7 +155,7 @@ impl ApubActor for Person {
let conn = &mut get_conn(pool).await?;
person::table
.filter(person::deleted.eq(false))
.filter(person::actor_id.eq(object_id))
.filter(person::ap_id.eq(object_id))
.first(conn)
.await
.optional()
@ -282,7 +282,7 @@ mod tests {
deleted: false,
published: inserted_person.published,
updated: None,
actor_id: inserted_person.actor_id.clone(),
ap_id: inserted_person.ap_id.clone(),
bio: None,
local: true,
bot_account: false,
@ -298,7 +298,7 @@ mod tests {
let read_person = Person::read(pool, inserted_person.id).await?;
let update_person_form = PersonUpdateForm {
actor_id: Some(inserted_person.actor_id.clone()),
ap_id: Some(inserted_person.ap_id.clone()),
..Default::default()
};
let updated_person = Person::update(pool, inserted_person.id, &update_person_form).await?;

View file

@ -25,7 +25,7 @@ impl Crud for Site {
}
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
let is_new_site = match &form.actor_id {
let is_new_site = match &form.ap_id {
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
None => true,
};
@ -34,7 +34,7 @@ impl Crud for Site {
// Can't do separate insert/update commands because InsertForm/UpdateForm aren't convertible
let site_ = insert_into(site::table)
.values(form)
.on_conflict(site::actor_id)
.on_conflict(site::ap_id)
.do_update()
.set(form)
.get_result::<Self>(conn)
@ -80,7 +80,7 @@ impl Site {
let conn = &mut get_conn(pool).await?;
site::table
.filter(site::actor_id.eq(object_id))
.filter(site::ap_id.eq(object_id))
.first(conn)
.await
.optional()
@ -97,7 +97,7 @@ impl Site {
/// Instance actor is at the root path, so we simply need to clear the path and other unnecessary
/// parts of the url.
pub fn instance_actor_id_from_url(mut url: Url) -> Url {
pub fn instance_ap_id_from_url(mut url: Url) -> Url {
url.set_fragment(None);
url.set_path("");
url.set_query(None);

View file

@ -341,7 +341,7 @@ pub type Person1AliasAllColumnsTuple = (
AliasedField<aliases::Person1, person::banned>,
AliasedField<aliases::Person1, person::published>,
AliasedField<aliases::Person1, person::updated>,
AliasedField<aliases::Person1, person::actor_id>,
AliasedField<aliases::Person1, person::ap_id>,
AliasedField<aliases::Person1, person::bio>,
AliasedField<aliases::Person1, person::local>,
AliasedField<aliases::Person1, person::private_key>,

View file

@ -199,7 +199,7 @@ diesel::table! {
deleted -> Bool,
nsfw -> Bool,
#[max_length = 255]
actor_id -> Varchar,
ap_id -> Varchar,
local -> Bool,
private_key -> Nullable<Text>,
public_key -> Text,
@ -745,7 +745,7 @@ diesel::table! {
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
#[max_length = 255]
actor_id -> Varchar,
ap_id -> Varchar,
bio -> Nullable<Text>,
local -> Bool,
private_key -> Nullable<Text>,
@ -1046,7 +1046,7 @@ diesel::table! {
#[max_length = 150]
description -> Nullable<Varchar>,
#[max_length = 255]
actor_id -> Varchar,
ap_id -> Varchar,
last_refreshed_at -> Timestamptz,
#[max_length = 255]
inbox_url -> Varchar,

View file

@ -39,8 +39,8 @@ pub struct Community {
pub deleted: bool,
/// Whether its an NSFW community.
pub nsfw: bool,
/// The federated actor_id.
pub actor_id: DbUrl,
/// The federated ap_id.
pub ap_id: DbUrl,
/// Whether the community is local.
pub local: bool,
#[serde(skip)]
@ -101,7 +101,7 @@ pub struct CommunityInsertForm {
#[new(default)]
pub nsfw: Option<bool>,
#[new(default)]
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
#[new(default)]
pub local: Option<bool>,
#[new(default)]
@ -141,7 +141,7 @@ pub struct CommunityUpdateForm {
pub updated: Option<Option<DateTime<Utc>>>,
pub deleted: Option<bool>,
pub nsfw: Option<bool>,
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
pub local: Option<bool>,
pub public_key: Option<String>,
pub private_key: Option<Option<String>>,

View file

@ -34,8 +34,8 @@ pub struct Person {
pub published: DateTime<Utc>,
#[cfg_attr(feature = "full", ts(optional))]
pub updated: Option<DateTime<Utc>>,
/// The federated actor_id.
pub actor_id: DbUrl,
/// The federated ap_id.
pub ap_id: DbUrl,
/// An optional bio, in markdown.
#[cfg_attr(feature = "full", ts(optional))]
pub bio: Option<String>,
@ -84,7 +84,7 @@ pub struct PersonInsertForm {
#[new(default)]
pub updated: Option<DateTime<Utc>>,
#[new(default)]
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
#[new(default)]
pub bio: Option<String>,
#[new(default)]
@ -115,7 +115,7 @@ pub struct PersonUpdateForm {
pub avatar: Option<Option<DbUrl>>,
pub banned: Option<bool>,
pub updated: Option<Option<DateTime<Utc>>>,
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
pub bio: Option<Option<String>>,
pub local: Option<bool>,
pub public_key: Option<String>,

View file

@ -35,8 +35,8 @@ pub struct Site {
/// A shorter, one-line description of the site.
#[cfg_attr(feature = "full", ts(optional))]
pub description: Option<String>,
/// The federated actor_id.
pub actor_id: DbUrl,
/// The federated ap_id.
pub ap_id: DbUrl,
/// The time the site was last refreshed.
pub last_refreshed_at: DateTime<Utc>,
/// The site inbox
@ -69,7 +69,7 @@ pub struct SiteInsertForm {
#[new(default)]
pub description: Option<String>,
#[new(default)]
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
#[new(default)]
pub last_refreshed_at: Option<DateTime<Utc>>,
#[new(default)]
@ -94,7 +94,7 @@ pub struct SiteUpdateForm {
pub icon: Option<Option<DbUrl>>,
pub banner: Option<Option<DbUrl>>,
pub description: Option<Option<String>>,
pub actor_id: Option<DbUrl>,
pub ap_id: Option<DbUrl>,
pub last_refreshed_at: Option<DateTime<Utc>>,
pub inbox_url: Option<DbUrl>,
pub private_key: Option<Option<String>>,

View file

@ -917,7 +917,7 @@ mod tests {
display_name: None,
published: data.timmy_local_user_view.person.published,
avatar: None,
actor_id: data.timmy_local_user_view.person.actor_id.clone(),
ap_id: data.timmy_local_user_view.person.ap_id.clone(),
local: true,
banned: false,
deleted: false,
@ -966,7 +966,7 @@ mod tests {
removed: false,
deleted: false,
nsfw: false,
actor_id: data.inserted_community.actor_id.clone(),
ap_id: data.inserted_community.ap_id.clone(),
local: true,
title: "nada".to_owned(),
sidebar: None,

View file

@ -280,7 +280,7 @@ mod tests {
icon: None,
banner: None,
description: None,
actor_id: url.clone().into(),
ap_id: url.clone().into(),
last_refreshed_at: Default::default(),
inbox_url: url.into(),
private_key: None,

View file

@ -814,7 +814,7 @@ mod tests {
let tag_1 = Tag::create(
pool,
&TagInsertForm {
ap_id: Url::parse(&format!("{}/tags/test_tag1", inserted_community.actor_id))?.into(),
ap_id: Url::parse(&format!("{}/tags/test_tag1", inserted_community.ap_id))?.into(),
name: "Test Tag 1".into(),
community_id: inserted_community.id,
published: None,
@ -826,7 +826,7 @@ mod tests {
let tag_2 = Tag::create(
pool,
&TagInsertForm {
ap_id: Url::parse(&format!("{}/tags/test_tag2", inserted_community.actor_id))?.into(),
ap_id: Url::parse(&format!("{}/tags/test_tag2", inserted_community.ap_id))?.into(),
name: "Test Tag 2".into(),
community_id: inserted_community.id,
published: None,
@ -896,7 +896,7 @@ mod tests {
icon: None,
banner: None,
description: None,
actor_id: Url::parse("http://example.com")?.into(),
ap_id: Url::parse("http://example.com")?.into(),
last_refreshed_at: Default::default(),
inbox_url: Url::parse("http://example.com")?.into(),
private_key: None,
@ -1844,7 +1844,7 @@ mod tests {
display_name: None,
published: inserted_person.published,
avatar: None,
actor_id: inserted_person.actor_id.clone(),
ap_id: inserted_person.ap_id.clone(),
local: true,
bot_account: false,
banned: false,
@ -1872,7 +1872,7 @@ mod tests {
removed: false,
deleted: false,
nsfw: false,
actor_id: inserted_community.actor_id.clone(),
ap_id: inserted_community.ap_id.clone(),
local: true,
title: "nada".to_owned(),
sidebar: None,

View file

@ -225,7 +225,7 @@ mod tests {
display_name: None,
published: inserted_sara_person.published,
avatar: None,
actor_id: inserted_sara_person.actor_id.clone(),
ap_id: inserted_sara_person.ap_id.clone(),
local: true,
banned: false,
ban_expires: None,
@ -294,7 +294,7 @@ mod tests {
display_name: None,
published: inserted_timmy_person.published,
avatar: None,
actor_id: inserted_timmy_person.actor_id.clone(),
ap_id: inserted_timmy_person.ap_id.clone(),
local: true,
banned: false,
ban_expires: None,

View file

@ -284,7 +284,7 @@ mod tests {
icon: None,
banner: None,
description: None,
actor_id: Url::parse("https://example.com/site")?.into(),
ap_id: Url::parse("https://example.com/site")?.into(),
last_refreshed_at: Utc::now(),
inbox_url: site_inbox.clone().into(),
private_key: None,
@ -407,7 +407,7 @@ mod tests {
icon: None,
banner: None,
description: None,
actor_id: Url::parse("https://example.com/site")?.into(),
ap_id: Url::parse("https://example.com/site")?.into(),
last_refreshed_at: Utc::now(),
inbox_url: site_inbox.clone().into(),
private_key: None,
@ -524,7 +524,7 @@ mod tests {
icon: None,
banner: None,
description: None,
actor_id: Url::parse("https://example.com/site")?.into(),
ap_id: Url::parse("https://example.com/site")?.into(),
last_refreshed_at: Utc::now(),
inbox_url: site_inbox.clone().into(),
private_key: None,

View file

@ -487,9 +487,9 @@ mod test {
let instance = Instance::read_or_create(&mut context.pool(), "localhost".to_string()).await?;
let actor_keypair = generate_actor_keypair()?;
let actor_id: DbUrl = Url::parse("http://local.com/u/alice")?.into();
let ap_id: DbUrl = Url::parse("http://local.com/u/alice")?.into();
let person_form = PersonInsertForm {
actor_id: Some(actor_id.clone()),
ap_id: Some(ap_id.clone()),
private_key: (Some(actor_keypair.private_key)),
inbox_url: Some(generate_inbox_url()?),
..PersonInsertForm::new("alice".to_string(), actor_keypair.public_key, instance.id)
@ -571,7 +571,7 @@ mod test {
tracing::debug!("received first stats");
assert_eq!(data.instance.id, rcv.state.instance_id);
let sent = send_activity(data.person.actor_id.clone(), &data.context, true).await?;
let sent = send_activity(data.person.ap_id.clone(), &data.context, true).await?;
tracing::debug!("sent activity");
// receive for successfully sent activity
let inbox_rcv = data.inbox_receiver.recv().await.unwrap();
@ -614,7 +614,7 @@ mod test {
// let last_id_before = rcv.state.last_successful_id.unwrap();
let mut sent = Vec::new();
for _ in 0..40 {
sent.push(send_activity(data.person.actor_id.clone(), &data.context, false).await?);
sent.push(send_activity(data.person.ap_id.clone(), &data.context, false).await?);
}
sleep(2 * *WORK_FINISHED_RECHECK_DELAY).await;
tracing::debug!("sent activity");
@ -643,7 +643,7 @@ mod test {
tracing::debug!("sending {} activities", count);
let mut sent = Vec::new();
for _ in 0..count {
sent.push(send_activity(data.person.actor_id.clone(), &data.context, false).await?);
sent.push(send_activity(data.person.ap_id.clone(), &data.context, false).await?);
}
sleep(2 * *WORK_FINISHED_RECHECK_DELAY).await;
tracing::debug!("sent activity");
@ -660,7 +660,7 @@ mod test {
let form = InstanceForm::new(data.instance.domain.clone());
Instance::update(&mut data.context.pool(), data.instance.id, form).await?;
send_activity(data.person.actor_id.clone(), &data.context, true).await?;
send_activity(data.person.ap_id.clone(), &data.context, true).await?;
data.inbox_receiver.recv().await.unwrap();
let instance =
@ -702,7 +702,7 @@ mod test {
}
async fn send_activity(
actor_id: DbUrl,
ap_id: DbUrl,
context: &LemmyContext,
wait: bool,
) -> LemmyResult<SentActivity> {
@ -725,7 +725,7 @@ mod test {
send_all_instances: false,
send_community_followers_of: None,
actor_type: ActorType::Person,
actor_apub_id: actor_id,
actor_apub_id: ap_id,
};
let sent = SentActivity::create(&mut context.pool(), form).await?;

View file

@ -254,7 +254,7 @@ async fn get_feed_user(
let channel = Channel {
namespaces: RSS_NAMESPACE.clone(),
title: format!("{} - {}", site_view.site.name, person.name),
link: person.actor_id.to_string(),
link: person.ap_id.to_string(),
items,
..Default::default()
};
@ -294,7 +294,7 @@ async fn get_feed_community(
let mut channel = Channel {
namespaces: RSS_NAMESPACE.clone(),
title: format!("{} - {}", site_view.site.name, community.name),
link: community.actor_id.to_string(),
link: community.ap_id.to_string(),
items,
..Default::default()
};
@ -468,7 +468,7 @@ fn create_post_items(posts: Vec<PostView>, protocol_and_hostname: &str) -> Lemmy
let post_url = format!("{}/post/{}", protocol_and_hostname, p.post.id);
let community_url = format!("{}/c/{}", protocol_and_hostname, &p.community.name);
let dublin_core_ext = Some(DublinCoreExtension {
creators: vec![p.creator.actor_id.to_string()],
creators: vec![p.creator.ap_id.to_string()],
..DublinCoreExtension::default()
});
let guid = Some(Guid {
@ -476,7 +476,7 @@ fn create_post_items(posts: Vec<PostView>, protocol_and_hostname: &str) -> Lemmy
value: post_url.clone(),
});
let mut description = format!("submitted by <a href=\"{}\">{}</a> to <a href=\"{}\">{}</a><br>{} points | <a href=\"{}\">{} comments</a>",
p.creator.actor_id,
p.creator.ap_id,
&p.creator.name,
community_url,
&p.community.name,
@ -526,7 +526,7 @@ fn create_post_items(posts: Vec<PostView>, protocol_and_hostname: &str) -> Lemmy
}
let category = Category {
name: p.community.title,
domain: Some(p.community.actor_id.to_string()),
domain: Some(p.community.ap_id.to_string()),
};
let i = Item {

View file

@ -59,14 +59,14 @@ async fn user_updates_2020_04_02(
pool: &mut DbPool<'_>,
protocol_and_hostname: &str,
) -> LemmyResult<()> {
use lemmy_db_schema::schema::person::dsl::{actor_id, local, person};
use lemmy_db_schema::schema::person::dsl::{ap_id, local, person};
let conn = &mut get_conn(pool).await?;
info!("Running user_updates_2020_04_02");
// Update the actor_id, private_key, and public_key, last_refreshed_at
// Update the ap_id, private_key, and public_key, last_refreshed_at
let incorrect_persons = person
.filter(actor_id.like("http://changeme%"))
.filter(ap_id.like("http://changeme%"))
.filter(local.eq(true))
.load::<Person>(conn)
.await?;
@ -75,7 +75,7 @@ async fn user_updates_2020_04_02(
let keypair = generate_actor_keypair()?;
let form = PersonUpdateForm {
actor_id: Some(generate_local_apub_endpoint(
ap_id: Some(generate_local_apub_endpoint(
EndpointType::Person,
&cperson.name,
protocol_and_hostname,
@ -98,28 +98,28 @@ async fn community_updates_2020_04_02(
pool: &mut DbPool<'_>,
protocol_and_hostname: &str,
) -> LemmyResult<()> {
use lemmy_db_schema::schema::community::dsl::{actor_id, community, local};
use lemmy_db_schema::schema::community::dsl::{ap_id, community, local};
let conn = &mut get_conn(pool).await?;
info!("Running community_updates_2020_04_02");
// Update the actor_id, private_key, and public_key, last_refreshed_at
// Update the ap_id, private_key, and public_key, last_refreshed_at
let incorrect_communities = community
.filter(actor_id.like("http://changeme%"))
.filter(ap_id.like("http://changeme%"))
.filter(local.eq(true))
.load::<Community>(conn)
.await?;
for ccommunity in &incorrect_communities {
let keypair = generate_actor_keypair()?;
let community_actor_id = generate_local_apub_endpoint(
let community_ap_id = generate_local_apub_endpoint(
EndpointType::Community,
&ccommunity.name,
protocol_and_hostname,
)?;
let form = CommunityUpdateForm {
actor_id: Some(community_actor_id.clone()),
ap_id: Some(community_ap_id.clone()),
private_key: Some(Some(keypair.private_key)),
public_key: Some(keypair.public_key),
last_refreshed_at: Some(Utc::now()),
@ -307,7 +307,7 @@ async fn apub_columns_2021_02_02(pool: &mut DbPool<'_>) -> LemmyResult<()> {
.await?;
for c in &communities {
let followers_url_ = generate_followers_url(&c.actor_id)?;
let followers_url_ = generate_followers_url(&c.ap_id)?;
let inbox_url_ = generate_inbox_url()?;
diesel::update(community.find(c.id))
.set((followers_url.eq(followers_url_), inbox_url.eq(inbox_url_)))
@ -335,9 +335,9 @@ async fn instance_actor_2022_01_28(
return Ok(());
}
let key_pair = generate_actor_keypair()?;
let actor_id = Url::parse(protocol_and_hostname)?;
let ap_id = Url::parse(protocol_and_hostname)?;
let site_form = SiteUpdateForm {
actor_id: Some(actor_id.clone().into()),
ap_id: Some(ap_id.clone().into()),
last_refreshed_at: Some(Utc::now()),
inbox_url: Some(generate_inbox_url()?),
private_key: Some(Some(key_pair.private_key)),
@ -431,7 +431,7 @@ async fn initialize_local_site_2022_10_10(
if let Some(setup) = &settings.setup {
let person_keypair = generate_actor_keypair()?;
let person_actor_id = generate_local_apub_endpoint(
let person_ap_id = generate_local_apub_endpoint(
EndpointType::Person,
&setup.admin_username,
&settings.get_protocol_and_hostname(),
@ -439,7 +439,7 @@ async fn initialize_local_site_2022_10_10(
// Register the user if there's a site setup
let person_form = PersonInsertForm {
actor_id: Some(person_actor_id.clone()),
ap_id: Some(person_ap_id.clone()),
inbox_url: Some(generate_inbox_url()?),
private_key: Some(person_keypair.private_key),
..PersonInsertForm::new(
@ -460,7 +460,7 @@ async fn initialize_local_site_2022_10_10(
// Add an entry for the site table
let site_key_pair = generate_actor_keypair()?;
let site_actor_id = Url::parse(&settings.get_protocol_and_hostname())?;
let site_ap_id = Url::parse(&settings.get_protocol_and_hostname())?;
let name = settings
.setup
@ -468,7 +468,7 @@ async fn initialize_local_site_2022_10_10(
.map(|s| s.site_name)
.unwrap_or_else(|| "New Site".to_string());
let site_form = SiteInsertForm {
actor_id: Some(site_actor_id.clone().into()),
ap_id: Some(site_ap_id.clone().into()),
last_refreshed_at: Some(Utc::now()),
inbox_url: Some(generate_inbox_url()?),
private_key: Some(site_key_pair.private_key),

View file

@ -51,14 +51,14 @@ async fn get_webfinger_response(
.await
.ok()
.flatten()
.map(|c| c.actor_id.into());
.map(|c| c.ap_id.into());
let community_id: Option<Url> = Community::read_from_name(&mut context.pool(), name, false)
.await
.ok()
.flatten()
.and_then(|c| {
if c.visibility == CommunityVisibility::Public {
let id: Url = c.actor_id.into();
let id: Url = c.ap_id.into();
Some(id)
} else {
None

View file

@ -0,0 +1,6 @@
ALTER TABLE person RENAME ap_id TO actor_id;
ALTER TABLE community RENAME ap_id TO actor_id;
ALTER TABLE site RENAME ap_id TO actor_id;

View file

@ -0,0 +1,6 @@
ALTER TABLE person RENAME actor_id TO ap_id;
ALTER TABLE community RENAME actor_id TO ap_id;
ALTER TABLE site RENAME actor_id TO ap_id;