diff options
author | Vitaly Takmazov | 2021-08-27 16:39:46 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-08-27 16:39:46 +0300 |
commit | e0f560c662d20b1956cb706b6423596efd33e8fb (patch) | |
tree | fd457bb0fa8edb0418f3744ec568fa9a54a0e3d1 /src/main/java/com/juick/ActivityPubManager.java | |
parent | 174c1af0738a3839586aa3b932540ad9c0c9537b (diff) |
ActivityPub: fix Application activites, use Actor where possible
Diffstat (limited to 'src/main/java/com/juick/ActivityPubManager.java')
-rw-r--r-- | src/main/java/com/juick/ActivityPubManager.java | 23 |
1 files changed, 12 insertions, 11 deletions
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> 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); } |