mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #88] Message delete using curl on windows #60
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gitgrub on GitHub (Apr 11, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/88
Hello,
I have a problem deleting a single message using curl.
Using the "try" button in the api doc works.
But using the curl method deletes all messages. My curl command is:
curl -X DELETE "http://127.0.0.1:8025/api/v1/messages" -H "content-type: application/json" -d '{"ids":["505597d0-1367-456b-8690-b957dde261bb"]}'Actually using python with your api, but trying to delete a message deleted all of them. So I thought I am doing something wrong, that's why I used curl for a test.
What am I doing wrong?
@axllent commented on GitHub (Apr 11, 2023):
That is strange. I have just tested with
curl -X DELETE "http://127.0.0.1:8025/api/v1/messages" -H "content-type: application/json" -d '{"ids":["fb368984-a7bb-41d8-9971-222f8dda46b8"]}'and it works exactly as expected, and only messagefb368984-a7bb-41d8-9971-222f8dda46b8was deleted.Are you 100% sure the messages weren't already deleted before you tried the curl command? The only time all messages will be deleted is if a blank array of
ids(or no ids at all) are defined as valid JSON in your data. If an ID is set but doesn't exist, then nothing is deleted (eg:{"ids":["thisdoesntexist"]}).@gitgrub commented on GitHub (Apr 11, 2023):
Yes, tried again right now. Mailpit version is 1.5.4, OS is win10, curl version "curl 7.83.1 (Windows) libcurl/7.83.1 Schannel".
I am creating three test messages with the built in sendmail command, searching with python shows three different ids.
So I thought maybe this curl version does not send the data right. Now I tried using the command without data:
curl -X DELETE "http://127.0.0.1:8025/api/v1/messages" -H "content-type: application/json"The log says
DEBU[2023/04/11 21:26:26] [db] deleted 3 messages in 129.9897ms, all messages were deleted.Edit:
updated curl to
curl 8.0.1 (x86_64-w64-mingw32), same behavior.@axllent commented on GitHub (Apr 12, 2023):
That is so strange. Can you please try the following for me, and post the response (leaving out your "origin" ip address):
which should return something like:
@gitgrub commented on GitHub (Apr 12, 2023):
Result is:
@gitgrub commented on GitHub (Apr 12, 2023):
Funny, did the same from a linux laptop, now json is here:
@gitgrub commented on GitHub (Apr 12, 2023):
Oh hell, happy win shell quoting, on win we need:
@axllent commented on GitHub (Apr 12, 2023):
That is interesting indeed, bloody Windows. It looks like you have uncovered the issue, although I do not know what to do about it in the docs unfortunately. The Swagger documentation is generated on-the-fly in the browser using RapidDoc which doesn't appear to have an option for that. You could potentially open a bug report there?
@gitgrub commented on GitHub (Apr 12, 2023):
Done: https://github.com/rapi-doc/RapiDoc/issues/918
My real issue was access via python, there is a lot of discussion on stackoverflow that a body with delete command is not well defined, some servers seem to turn it into a post request, others like google just reject it. Idk, did not test this.
The hint for python users for the requests.delete command, is not to use the data parameter (which will be empty, killing all messages), but the json parameter. Now we can delete a single message.
In general: maybe it would be good not to delete all messages if the ids array is empty or not defined.
I do not know how apis like that work, but would imagine something like ids:[all] or [*].
@gitgrub commented on GitHub (Apr 12, 2023):
PS: in that context, so no extra issue:
The web UI is not updated after a delete operation via api.
Maybe use a timeout to not fire too many page refreshes on mass deletion?
@axllent commented on GitHub (Apr 12, 2023):
Thanks. I'm following that thread, and if they implement a work-around I will implement it. In the meantime the "issue" lies there (and Windows) and there is nothing further I can do here unfortunately.
I hear you, but this is a separate issue, and to be honest it's not something on my TODO list right now. If I am going to notify on deletions, then why not changed read statuses, tags etc... it quickly blows out into a full-featured webmail client with everything but actual emailing :-) The point is that creating a multi-browser synced mailbox (for all actions) adds a huge development overhead, and isn't an easy thing to do (correctly) - all for very little benefit. Sure, it would be great if the UI updated if a separate API request deletes or modifies something, but that's really just a nice-to-have for a small subset of users I feel.
@gitgrub commented on GitHub (Apr 12, 2023):
Yes that's right, lets forget about the update thing.
@github-actions[bot] commented on GitHub (May 4, 2023):
This issue is stale because it has been open for 21 days with no activity.
@github-actions[bot] commented on GitHub (May 11, 2023):
This issue was closed because it has been inactive for 7 days since being marked as stale.