aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/www/api')
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java22
1 files changed, 13 insertions, 9 deletions
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 cf5fb843..eb8909b5 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -48,6 +48,7 @@ import com.juick.www.WebApp;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
import com.juick.service.activities.AnnounceEvent;
+import com.juick.service.activities.DirectMessageEvent;
import com.juick.service.activities.FollowEvent;
import com.juick.service.activities.UndoAnnounceEvent;
import com.juick.service.activities.UndoFollowEvent;
@@ -297,17 +298,15 @@ public class Profile {
}
if (activity instanceof Undo) {
- Map object = (Map) activity.getObject();
- String objectType = (String) object.get("type");
- String objectObject = (String) object.get("object");
- if (objectType.equals("Follow")) {
+ Activity object = (Activity) activity.getObject();
+ if (object instanceof Follow) {
applicationEventPublisher
- .publishEvent(new UndoFollowEvent(this, activity.getActor(), objectObject));
+ .publishEvent(new UndoFollowEvent(this, activity.getActor(), object.getObject().getId()));
return new ResponseEntity<>(CommandResult.fromString("Undo follow request accepted"),
HttpStatus.OK);
- } else if (objectType.equals("Like") || objectType.equals("Announce")) {
+ } else if (object instanceof Like || object instanceof Announce) {
applicationEventPublisher
- .publishEvent(new UndoAnnounceEvent(this, activity.getActor(), objectObject));
+ .publishEvent(new UndoAnnounceEvent(this, activity.getActor(), object.getObject().getId()));
return new ResponseEntity<>(CommandResult.fromString("Undo like/announce request accepted"),
HttpStatus.OK);
}
@@ -364,10 +363,15 @@ public class Profile {
if (result.getNewMessage().isPresent()) {
messagesService.updateReplyUri(result.getNewMessage().get(), noteId);
return new ResponseEntity<>(result, HttpStatus.OK);
- } else {
- return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
}
}
+ return new ResponseEntity<>(CommandResult.fromString("Invalid recipient"), HttpStatus.BAD_REQUEST);
+ }
+ } else {
+ if (note.getTo().stream().anyMatch(recipient -> recipient.startsWith(baseUri))) {
+ logger.warn("Possible direct message from {}", note.getAttributedTo());
+ applicationEventPublisher.publishEvent(new DirectMessageEvent(this, note));
+ return new ResponseEntity<>(CommandResult.fromString("Message accepted"), HttpStatus.ACCEPTED);
}
}
}