From a44510ff17ac6e099ceed9401a62d6d66366c73d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 23 Aug 2021 15:04:09 +0300 Subject: ActivityPub: send Update event on user profile updates --- src/main/java/com/juick/www/api/Users.java | 2 ++ src/main/java/com/juick/www/controllers/Settings.java | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'src/main/java/com/juick/www') diff --git a/src/main/java/com/juick/www/api/Users.java b/src/main/java/com/juick/www/api/Users.java index 8743a275..030d8ced 100644 --- a/src/main/java/com/juick/www/api/Users.java +++ b/src/main/java/com/juick/www/api/Users.java @@ -26,6 +26,7 @@ import com.juick.util.HttpUtils; import com.juick.util.WebUtils; import com.juick.www.WebApp; import com.juick.service.*; +import com.juick.service.activities.UpdateUserEvent; import com.juick.service.component.MailVerificationEvent; import com.juick.service.security.annotation.Visitor; import org.apache.commons.io.IOUtils; @@ -175,6 +176,7 @@ public class Users { String avatarTmpPath = HttpUtils.receiveMultiPartFile(avatar, tmpDir).getHost(); if (StringUtils.isNotEmpty(avatarTmpPath)) { imagesService.saveAvatar(avatarTmpPath, visitor.getUid()); + applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor)); } } diff --git a/src/main/java/com/juick/www/controllers/Settings.java b/src/main/java/com/juick/www/controllers/Settings.java index 5cda7bc4..a9240cab 100644 --- a/src/main/java/com/juick/www/controllers/Settings.java +++ b/src/main/java/com/juick/www/controllers/Settings.java @@ -22,12 +22,14 @@ import com.juick.util.HttpBadRequestException; import com.juick.util.HttpUtils; import com.juick.www.WebApp; import com.juick.service.*; +import com.juick.service.activities.UpdateUserEvent; import com.juick.service.security.annotation.Visitor; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; @@ -79,6 +81,8 @@ public class Settings { private ImagesService imagesService; @Inject private WebApp webApp; + @Inject + private ApplicationEventPublisher applicationEventPublisher; @GetMapping("/settings") protected String doGet( @@ -171,6 +175,7 @@ public class Settings { if (userService.updateUserInfo(visitor)) { result = String.format("

Your info is updated.

Back to blog.

", visitor.getName()); } + applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor)); break; case "jid-del": // FIXME: stop using ugnich-csv in parameters -- cgit v1.2.3