From 58359b1e45861fea725aa7accfe5879d2d7fbeb7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 4 Jan 2023 16:24:47 +0300 Subject: ActivityPub: fix actor to user conversion, handle Block activity --- src/main/java/com/juick/www/api/activity/Profile.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/www/api') 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 4dcd4910..d2468d70 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -17,6 +17,7 @@ package com.juick.www.api.activity; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.model.Message; import com.juick.model.User; @@ -28,6 +29,7 @@ import com.juick.www.api.activity.helpers.ProfileUriBuilder; import com.juick.www.api.activity.model.Activity; import com.juick.www.api.activity.model.Context; import com.juick.www.api.activity.model.activities.Announce; +import com.juick.www.api.activity.model.activities.Block; import com.juick.www.api.activity.model.activities.Create; import com.juick.www.api.activity.model.activities.Delete; import com.juick.www.api.activity.model.activities.Flag; @@ -40,6 +42,7 @@ import com.juick.www.api.activity.model.objects.Note; import com.juick.www.api.activity.model.objects.OrderedCollection; import com.juick.www.api.activity.model.objects.OrderedCollectionPage; import com.juick.www.api.activity.model.objects.Person; +import com.juick.util.HttpBadRequestException; import com.juick.util.HttpNotFoundException; import com.juick.service.MessagesService; import com.juick.service.UserService; @@ -70,7 +73,6 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.NoSuchElementException; -import java.util.stream.Collectors; import java.util.stream.Stream; @RestController @@ -405,6 +407,9 @@ public class Profile { } } } + if (activity instanceof Block) { + logger.info("{} blocks {} (room_full_of_people_who_care.jpg)", activity.getActor(), activity.getObject().getId()); + } logger.warn("Unknown activity: {}", jsonMapper.writeValueAsString(activity)); return new ResponseEntity<>(CommandResult.fromString("Unknown activity"), HttpStatus.NOT_IMPLEMENTED); } @@ -418,7 +423,7 @@ public class Profile { } @PostMapping(value = { "/u/", "/api/u/" }, produces = MediaType.APPLICATION_JSON_VALUE) - public User fetchUser(@RequestParam URI uri) { + public User fetchUser(@RequestParam URI uri) throws JsonProcessingException, HttpBadRequestException { return activityPubManager.actorToUser(uri); } } -- cgit v1.2.3