feat(chat-tools): add delete_event tool for trashing wrong-venue duplicates#289
Merged
Conversation
Contributor
Homeboy Results —
|
f3b064f to
e438be4
Compare
…icates Introduces a new data-machine-events/delete-event ability and a delete_event chat tool wrapping it. Closes the gap when a show moves venues and leaves behind a stale duplicate post — get_venue_events finds both, delete_event trashes the wrong one, update_event (optionally) corrects the kept one. - Soft delete via wp_trash_post() so the wp-admin trash safety net applies and the dedupe/upsert system can still see the post if it reappears. - Single (event) or batch (events[]) input; already-trashed posts land in skipped[] rather than erroring. - Snapshots title, venue_name, startDate before trashing so the agent can confirm to the user what was removed. - Emits datamachine_log + new data_machine_events_event_trashed action so future audit subscribers can hook in without coupling to storage here. - permission_callback uses manage_options for now with a TODO referencing #288 (team-member permission audit); rebase to the shared helper once that lands. Closes #286
e438be4 to
963924a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #286
Summary
Adds a
delete_eventchat tool wrapping a newdata-machine-events/delete-eventability. Fills the gap when a show moves venues and the calendar ends up with two posts —get_venue_eventsfinds both,delete_eventtrashes the stale one, andupdate_event(optionally) corrects the kept one.Uses
wp_trash_post()— NOTwp_delete_post()— so:New files
inc/Abilities/DeleteEventAbilities.php— registersdata-machine-events/delete-event. Acceptsevent(single ID) orevents(array of IDs) plus optionalreason. Validates post existence andpost_type === data_machine_events. Skips already-trashed posts intoskipped[]rather than erroring. Returnsdeleted[]with{id, title, venue_name, start_date}snapshots captured pre-trash so the agent can confirm to the user. Emitsdatamachine_log+ newdata_machine_events_event_trashedaction for future audit subscribers.inc/Api/Chat/Tools/DeleteEvent.php—BaseToolwrapper registering thedelete_eventchat tool. Tool description explicitly tells the agent to use it for wrong-venue duplicates or cancellations and that events go to trash (not hard-deleted).Wiring
data-machine-events.phpbootstraps both the chat tool (next toUpdateEvent/MoveEvent) and the ability (next toEventUpdateAbilities/MoveEventAbilities).Permissions
Uses the shared
AbilityPermissions::canWrite()helper introduced in #291, matching the pattern inEventUpdateAbilities.php. Team members with write access get the tool; admin-only gating is gone.How to verify
Chat invocation
Direct ability call
wp --allow-root --path=/var/www/extrachill.com --url=events.extrachill.com \ ability execute data-machine-events/delete-event \ --input='{"event": 12345, "reason": "duplicate at wrong venue"}'Expected:
post_status=trash.deleted[0]with id, title, venue_name, start_date captured pre-trash.datamachine_loginfo entry written with source=delete-event-ability.data_machine_events_event_trashedaction fires.Edge cases handled
skipped[]with reason "Already in trash.", does not error.skipped[]with explicit type mismatch reason.skipped[]with "Post not found.".eventnoreventsprovided →WP_Errorwith HTTP 400.event+events→ deduped before processing.Notes
wp_trash_post()is used, notwp_delete_post(). Hard delete is explicitly out of scope per the issue.