From ae4fd85c07755c3b67d1106cd570941be5c20a75 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 24 Oct 2021 05:54:06 +0300 Subject: ActivityPub: accept profile updates --- src/main/java/com/juick/www/api/activity/Profile.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/juick/www/api/activity') diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java index 8a879f3b..495ca8f9 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -34,6 +34,7 @@ import com.juick.www.api.activity.model.activities.Flag; import com.juick.www.api.activity.model.activities.Follow; import com.juick.www.api.activity.model.activities.Like; import com.juick.www.api.activity.model.activities.Undo; +import com.juick.www.api.activity.model.activities.Update; import com.juick.www.api.activity.model.objects.Actor; import com.juick.www.api.activity.model.objects.Application; import com.juick.www.api.activity.model.objects.Image; @@ -302,13 +303,13 @@ public class Profile { if (activity instanceof Undo) { Context object = activity.getObject(); if (object instanceof Follow) { - applicationEventPublisher - .publishEvent(new UndoFollowEvent(this, activity.getActor(), ((Activity)object).getObject().getId())); + applicationEventPublisher.publishEvent( + new UndoFollowEvent(this, activity.getActor(), ((Activity) object).getObject().getId())); return new ResponseEntity<>(CommandResult.fromString("Undo follow request accepted"), HttpStatus.OK); } else if (object instanceof Like || object instanceof Announce) { - applicationEventPublisher - .publishEvent(new UndoAnnounceEvent(this, activity.getActor(), ((Activity)object).getObject().getId())); + applicationEventPublisher.publishEvent( + new UndoAnnounceEvent(this, activity.getActor(), ((Activity) object).getObject().getId())); return new ResponseEntity<>(CommandResult.fromString("Undo like/announce request accepted"), HttpStatus.OK); } @@ -401,6 +402,13 @@ public class Profile { logger.info("{} flag some objects: {}", actor, activity.getObject()); return new ResponseEntity<>(CommandResult.fromString("Report accepted"), HttpStatus.ACCEPTED); } + if (activity instanceof Update) { + if (activity.getObject() instanceof Person + && activity.getActor().equals(activity.getObject().getId())) { + logger.info("{} update they profile"); + return new ResponseEntity<>(CommandResult.fromString("Update accepted"), HttpStatus.ACCEPTED); + } + } logger.warn("Unknown activity: {}", jsonMapper.writeValueAsString(activity)); return new ResponseEntity<>(CommandResult.fromString("Unknown activity"), HttpStatus.NOT_IMPLEMENTED); } -- cgit v1.2.3