Skip to content

Commit 2f908e8

Browse files
authored
Merge pull request #243 from broadwaylamb/edited-messages
Support `Update{Note}` for direct messages
2 parents c222265 + 1d10de8 commit 2f908e8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/smithereen/activitypub/handlers/UpdateNoteHandler.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
import smithereen.activitypub.ActivityForwardingUtils;
77
import smithereen.activitypub.ActivityHandlerContext;
88
import smithereen.activitypub.ActivityTypeHandler;
9-
import smithereen.activitypub.objects.ForeignActor;
109
import smithereen.activitypub.objects.NoteOrQuestion;
1110
import smithereen.activitypub.objects.activities.Update;
11+
import smithereen.exceptions.ObjectNotFoundException;
1212
import smithereen.model.ForeignUser;
13-
import smithereen.model.OwnerAndAuthor;
13+
import smithereen.model.MailMessage;
1414
import smithereen.model.Post;
15-
import smithereen.exceptions.ObjectNotFoundException;
1615
import smithereen.model.comments.Comment;
17-
import smithereen.model.comments.CommentableContentObject;
16+
import smithereen.storage.MailStorage;
1817
import smithereen.storage.PostStorage;
1918

2019
public class UpdateNoteHandler extends ActivityTypeHandler<ForeignUser, Update, NoteOrQuestion>{
@@ -60,6 +59,11 @@ public void handle(ActivityHandlerContext context, ForeignUser actor, Update act
6059
context.appContext.getWallController().loadAndPreprocessRemotePostMentions(updated, post);
6160
context.appContext.getCommentsController().putOrUpdateForeignComment(updated);
6261
ActivityForwardingUtils.forwardCommentInteraction(context, updated);
62+
}else if(existing instanceof MailMessage existingMessage){
63+
MailMessage updated=post.asNativeMessage(context.appContext);
64+
if(updated.senderID!=existingMessage.senderID || actor.id!=existingMessage.senderID)
65+
throw new IllegalArgumentException("No access to update this message");
66+
MailStorage.updateForeignMessage(updated, true);
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)