Skip to content

ResentMessage stacks duplicate resent tags when resending a resend #16

Description

@jszobody

This issue was written by Claude (Opus 4.8).

Symptom

Resending an already-resent message produces duplicate resent tags. A first resend gets […original tags…, resent]; resending that copies its tags and appends resent again → […, resent, resent]. Each further resend adds another, so the badge row grows resent resent resent ….

Cause

STS\Postmaster\Mail\ResentMessage::build() (around line 67):

foreach ((array) $this->record->tags as $tag) {
    $this->tag($tag);
}

return $this->tag('resent');

It copies every tag from the source record — which already includes resent when the source was itself a resend — then unconditionally adds resent again.

Suggested fix

Don't re-add resent if it's already carried over (and, defensively, dedupe the copied tags):

foreach (array_unique((array) $this->record->tags) as $tag) {
    $this->tag($tag);
}

if (! in_array('resent', (array) $this->record->tags, true)) {
    $this->tag('resent');
}

return $this;

The resent tag is a boolean-style marker ("this send is a resend"); resend depth is already tracked precisely by the resent_from_id chain (resendChain()), so a single resent tag is all that's meaningful.

Workaround in the meantime

Consuming app dedupes on display (array_unique($message->tags)), but the stored tags column still accumulates, so the fix is best at the write side.

Happy to PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions