Skip to content

fix(MailReturn): report failed returns and wait for mail delivery - #222

Merged
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix/mail-return-soap-result
Oct 31, 2026
Merged

Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix/mail-return-soap-result

Conversation

@Nyeriah

@Nyeriah Nyeriah commented Oct 31, 2026

Copy link
Copy Markdown
Member

What and why

The Return button on the Mail Return page always reported success. returnMail() sent .mail return over SOAP and ignored the reply, so when the core refused the command the page still removed the row, and the mail was back after a refresh.

The most common way to hit this is returning a mail right after sending it. The core treats mails still in the MailDeliveryDelay window as not found, but the list showed them with a working Return button.

Now:

  • A return only counts as done when the core replies with LANG_MAIL_RETURN_SUCCESS ("Mail #N returned to sender ..."). Any other reply, or a SOAP connection error, is sent back as a mail_return_failed error with the core's text, so the player sees "Mail #N not found." or "Mail has already been returned." and the row stays.
  • The list includes deliver_in (seconds left, computed on the web server). Mails still being delivered show a "Delivers in Xm Ys" countdown with the button disabled until it hits zero.
  • The endpoint also rejects early returns itself with "has not been delivered yet, try again in ...", since the core's "not found" doesn't explain anything.

Decisions worth knowing

  • AcoreSoap::executeCommand() returns the fault text instead of throwing, so command errors and transport errors both arrive as strings. Matching the success text is the only reliable signal. Checking the DB afterwards doesn't work because the core commits the return asynchronously.
  • The match is against the English string. A worldserver running a non-English DBC locale would get every return reported as failed even when it worked.

Review guide

MailReturnController.php has the logic, MailReturnApi.php maps the new exception to a 502 with the message, and mail-return.js adds the countdown. The CSS and the script version bump are cosmetic.

The return endpoint ignored the SOAP reply and always reported success,
so the page dropped the row even when the core refused the command.
Only the core's "Mail #N returned to sender" reply now counts as
success; anything else is returned to the page as an error.

The core also refuses mails still in the MailDeliveryDelay window. The
list now carries the remaining delivery time, the Return button stays
disabled with a countdown until the mail is delivered, and the endpoint
rejects early returns with an explanation.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Nyeriah
Nyeriah merged commit 51a7d59 into azerothcore:master Oct 31, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant