Quote Post Fixe

This commit is contained in:
Tim Zöller 2026-04-27 22:27:16 +02:00
parent d79678aae3
commit 9e529f8b99
2 changed files with 16 additions and 10 deletions

View file

@ -256,12 +256,12 @@ public class FederationService {
* Send an Accept for a quote interaction (FEP-5e53). * Send an Accept for a quote interaction (FEP-5e53).
* This tells the quoting server that the quote has been approved. * This tells the quoting server that the quote has been approved.
* *
* @param createActivityId the ID of the incoming Create activity that contains the quote * @param noteUri the URI of the remote Note that quotes our post
* @param remoteActorUri the actor URI of the user who quoted the post * @param remoteActorUri the actor URI of the user who quoted the post
* @param localUser the local user who owns the quoted post * @param localUser the local user who owns the quoted post
*/ */
@Async("taskExecutor") @Async("taskExecutor")
public void sendAcceptQuote(String createActivityId, String remoteActorUri, User localUser) { public void sendAcceptQuote(String noteUri, String remoteActorUri, User localUser) {
try { try {
RemoteActor remoteActor = fetchRemoteActor(remoteActorUri); RemoteActor remoteActor = fetchRemoteActor(remoteActorUri);
@ -273,13 +273,13 @@ public class FederationService {
acceptActivity.put("type", "Accept"); acceptActivity.put("type", "Accept");
acceptActivity.put("id", acceptId); acceptActivity.put("id", acceptId);
acceptActivity.put("actor", actorUri); acceptActivity.put("actor", actorUri);
acceptActivity.put("object", createActivityId); acceptActivity.put("object", noteUri);
sendActivity(remoteActor.getInboxUrl(), acceptActivity, localUser); sendActivity(remoteActor.getInboxUrl(), acceptActivity, localUser);
log.info("Sent Accept (quote approval) to: {} for Create {}", remoteActor.getActorUri(), createActivityId); log.info("Sent Accept (quote approval) to: {} for Note {}", remoteActor.getActorUri(), noteUri);
} catch (Exception e) { } catch (Exception e) {
log.error("Failed to send Accept for quote: {}", createActivityId, e); log.error("Failed to send Accept for quote: {}", noteUri, e);
} }
} }

View file

@ -287,10 +287,16 @@ public class InboxProcessor {
User localUser = userRepository.findByUsername(username) User localUser = userRepository.findByUsername(username)
.orElseThrow(() -> new IllegalArgumentException("User not found: " + username)); .orElseThrow(() -> new IllegalArgumentException("User not found: " + username));
String createActivityId = (String) createActivity.get("id"); // Mastodon tracks pending quote approvals by the Note URI (the inner
log.info("Approving quote from {} for activity {} (Create id: {})", actor, activityId, createActivityId); // object's "id"), not by the wrapping Create activity's "id". The Accept
// we send back must therefore reference the Note URI so Mastodon can match
// it to the pending approval.
@SuppressWarnings("unchecked")
Map<String, Object> noteObject = (Map<String, Object>) createActivity.get("object");
String noteUri = (String) noteObject.get("id");
log.info("Approving quote from {} for activity {} (Note URI: {})", actor, activityId, noteUri);
federationService.sendAcceptQuote(createActivityId, actor, localUser); federationService.sendAcceptQuote(noteUri, actor, localUser);
} catch (Exception e) { } catch (Exception e) {
log.error("Error handling quote approval for {}", quoteUri, e); log.error("Error handling quote approval for {}", quoteUri, e);