aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-08-23 15:04:09 +0300
committerGravatar Vitaly Takmazov2021-08-23 15:04:09 +0300
commita44510ff17ac6e099ceed9401a62d6d66366c73d (patch)
treee69576a1f74d43c9b778d66d0aa357316087a8f0 /src/main/java/com/juick/www
parentf7ebc8831b032196e6695fa22647717a7bf2b55c (diff)
ActivityPub: send Update event on user profile updates
Diffstat (limited to 'src/main/java/com/juick/www')
-rw-r--r--src/main/java/com/juick/www/api/Users.java2
-rw-r--r--src/main/java/com/juick/www/controllers/Settings.java5
2 files changed, 7 insertions, 0 deletions
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("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getName());
}
+ applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor));
break;
case "jid-del":
// FIXME: stop using ugnich-csv in parameters