From e0f560c662d20b1956cb706b6423596efd33e8fb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 27 Aug 2021 16:39:46 +0300 Subject: ActivityPub: fix Application activites, use Actor where possible --- src/main/java/com/juick/ActivityPubManager.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/main/java/com/juick/ActivityPubManager.java') diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java index 1e97a54e..5b0e8d59 100644 --- a/src/main/java/com/juick/ActivityPubManager.java +++ b/src/main/java/com/juick/ActivityPubManager.java @@ -25,6 +25,7 @@ import com.juick.model.Tag; import com.juick.www.api.SystemActivity.ActivityType; import com.juick.www.api.activity.model.Context; import com.juick.www.api.activity.model.activities.*; +import com.juick.www.api.activity.model.objects.Actor; import com.juick.www.api.activity.model.objects.Hashtag; import com.juick.www.api.activity.model.objects.Image; import com.juick.www.api.activity.model.objects.Mention; @@ -97,8 +98,8 @@ public class ActivityPubManager implements ActivityListener, NotificationListene User followedUser = socialService.getUserByAccountUri(acct); if (!followedUser.isAnonymous()) { // automatically accept follower requests - Person me = (Person) signatureManager.getContext(URI.create(acct)).get(); - Person follower = (Person) signatureManager.getContext(URI.create(followEvent.getRequest().getActor())).get(); + Actor me = (Actor) signatureManager.getContext(URI.create(acct)).get(); + Actor follower = (Actor) signatureManager.getContext(URI.create(followEvent.getRequest().getActor())).get(); Accept accept = new Accept(); accept.setActor(me.getId()); accept.setObject(followEvent.getRequest()); @@ -136,10 +137,10 @@ public class ActivityPubManager implements ActivityListener, NotificationListene User user = msg.getUser(); String userUri = personUri(user); Note note = makeNote(msg); - Person me = (Person) signatureManager.getContext(URI.create(userUri)).get(); + Actor me = (Actor) signatureManager.getContext(URI.create(userUri)).get(); socialService.getFollowers(user).forEach(acct -> { try { - Person follower = (Person) signatureManager.getContext(URI.create(acct)).orElseThrow(); + Actor follower = (Actor) signatureManager.getContext(URI.create(acct)).orElseThrow(); Delete delete = new Delete(); delete.setId(note.getId()); delete.setActor(me.getId()); @@ -188,10 +189,10 @@ public class ActivityPubManager implements ActivityListener, NotificationListene String objectUri = event.getMessageUri(); User user = event.getUser(); String userUri = personUri(user); - Person me = (Person) signatureManager.getContext(URI.create(userUri)).get(); + Actor me = (Actor) signatureManager.getContext(URI.create(userUri)).get(); socialService.getFollowers(user).forEach(acct -> { try { - Person follower = (Person) signatureManager.getContext(URI.create(acct)).orElseThrow(); + Actor follower = (Actor) signatureManager.getContext(URI.create(acct)).orElseThrow(); Update update = new Update(); update.setId(objectUri + "#update"); update.setActor(me.getId()); @@ -222,10 +223,10 @@ public class ActivityPubManager implements ActivityListener, NotificationListene public void processUpdateUserEvent(UpdateUserEvent event) { User user = event.getUser(); String userUri = personUri(user); - Person me = (Person) signatureManager.getContext(URI.create(userUri)).get(); + Actor me = (Actor) signatureManager.getContext(URI.create(userUri)).get(); socialService.getFollowers(user).forEach(acct -> { try { - Person follower = (Person) signatureManager.getContext(URI.create(acct)).orElseThrow(); + Actor follower = (Actor) signatureManager.getContext(URI.create(acct)).orElseThrow(); Update update = new Update(); update.setId(userUri + "#update"); update.setActor(me.getId()); @@ -260,7 +261,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene subscribers.forEach(acct -> { Optional context = signatureManager.getContext(URI.create(acct)); if (context.isPresent() && context.get() instanceof Person) { - Person follower = (Person)context.get(); + Actor follower = (Actor)context.get(); Create create = new Create(); create.setId(note.getId()); create.setActor(me.getId()); @@ -409,13 +410,13 @@ public class ActivityPubManager implements ActivityListener, NotificationListene announce.setActor(personUri(serviceUser)); announce.setTo(Collections.singletonList(Context.ACTIVITYSTREAMS_PUBLIC)); announce.setObject(note); - Person me = (Person) signatureManager.getContext(URI.create(announce.getActor())).get(); + Actor me = (Actor) signatureManager.getContext(URI.create(announce.getActor())).get(); socialService.getFollowers(serviceUser).forEach(acct -> { var follower = signatureManager.getContext(URI.create(acct)); follower.ifPresentOrElse((person) -> { try { logger.info("Announcing top: {}", message.getMid()); - signatureManager.post(me, (Person)person, announce); + signatureManager.post(me, (Actor)person, announce); } catch (IOException | NoSuchAlgorithmException e) { logger.warn("activitypub exception", e); } -- cgit v1.2.3