Skip to content

Api: add REST API handler and JSON format for Tracker items#3

Open
amirdhs wants to merge 8 commits into
masterfrom
feature/REST-API
Open

Api: add REST API handler and JSON format for Tracker items#3
amirdhs wants to merge 8 commits into
masterfrom
feature/REST-API

Conversation

@amirdhs

@amirdhs amirdhs commented May 28, 2026

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 28, 2026 15:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a REST/JSON layer for the Tracker app analogous to other EGroupware apps' CalDAV handlers. The handler hooks into the GroupDAV endpoint and the JsTracker class converts tracker items to/from a JSON representation.

Changes:

  • New ApiHandler (CalDAV Handler subclass) implementing PROPFIND/GET/PUT/POST/PATCH/DELETE, sync-collection, filter mapping, ETag and exception handling for /tracker collections.
  • New JsTracker (CalDAV JsBase subclass) providing JsTicket() serialization and parseJsTicket()/parseStatus()/parseAssigned() deserialization including custom-status and custom-field support.
  • Auto-creates a "Default" tracker queue on first REST use if none exist, so search/list does not return empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
src/ApiHandler.php New REST handler for /tracker collection: routing, filters, sync-collection, ACL, ETag, exception responses.
src/JsTracker.php New JSON renderer/parser for tracker items (JsTicket/parseJsTicket), including status label mapping and assigned/account handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ApiHandler.php Outdated
Comment thread src/ApiHandler.php
Comment thread src/JsTracker.php
Comment thread src/JsTracker.php
Comment thread src/ApiHandler.php Outdated
Comment thread src/ApiHandler.php
Comment thread src/JsTracker.php
Comment thread src/JsTracker.php
@ralfbecker

ralfbecker commented Jun 1, 2026

Copy link
Copy Markdown
Member

Hi Amir,

as I said in our AI meeting:

  1. all of the Copilot requests are valid in my opinion and should be addressed
  2. your pull request completely missed the replies:
    a) GET requests should return an object with reply_id => reply-object
    b) there need to be an endpoint path for the replies: /tracker/{id}/replies/{reply_id} with:
    • POST to /tracker/{id}/replies/ to create a new reply
    • GET/PUT/DELETE/PATCH to /tracker/{id}/replies/{reply_id} to get, replace, delete or change a reply
      c) documentation on how to use the general links facility to add or modify attachments to tickets AND replies

Ralf

amirdhs and others added 4 commits June 2, 2026 21:17
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Align propfind paging stride with the fetch size so nresults values above CHUNK_SIZE do not overlap pages, and only emit deleted tickets as path-only entries during sync-collection reports.

Based on Copilot review.
@ralfbecker

Copy link
Copy Markdown
Member

Hi Amir,
can you mark the Copilot requests to fixed as resolved, so I don't have to go through all commits and figure out, they are fixed or not.
Then we can discus the ones not yet fixed ...

Ralf

@amirdhs

amirdhs commented Jun 8, 2026

Copy link
Copy Markdown
Author

Hi Amir, can you mark the Copilot requests to fixed as resolved, so I don't have to go through all commits and figure out, they are fixed or not. Then we can discus the ones not yet fixed ...

Ralf

Hi Ralf,
done – the fixed Copilot requests are now marked as resolved.

Adds two new PHPUnit test classes under tests/REST/:
- TrackerRestCreateReadDelete: covers create, read, update and delete
  of tracker tickets via the JSON REST API (groupdav.php endpoint).
- TrackerRestPermissions: covers role-based access scenarios for
  manager, technician and reporter actors against the same endpoint.

Both suites auto-skip until a tracker_groupdav handler is implemented.

@ralfbecker ralfbecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, found a couple more things ;)

Ralf

Comment thread src/ApiHandler.php Outdated
Comment thread src/JsTracker.php Outdated
Comment thread src/JsTracker.php Outdated
@amirdhs amirdhs force-pushed the feature/REST-API branch from 96789bb to 83e2569 Compare June 11, 2026 13:24
- Remove auto-create queue from constructor; return 403 Forbidden in
  propfind and new-ticket PUT/POST when the user has no queue access
- Change assigned field from sequential array to JMAP-style map
  keyed by numeric account-id string, so PATCH can add/remove
  individual assignees: {"uid": true} to add, {"uid": null} to remove
- Fix parseAssigned to apply map as delta on top of $old for PATCH
- Add TrackerRestAssignedPatch test covering add and remove via PATCH
@amirdhs amirdhs force-pushed the feature/REST-API branch from 83e2569 to d69d5da Compare June 11, 2026 13:32
@amirdhs amirdhs requested a review from ralfbecker June 11, 2026 13:35
Comment thread src/JsTracker.php

case 'assigned':
$ticket['tr_assigned'] = self::parseAssigned($value);
$ticket['tr_assigned'] = self::parseAssigned($value, (array)($old['assigned'] ?? []), $method);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Responsible and parseResponsible methods from Api\src\CalDAV\JsCalendar by extending it instead of JsBase.

It makes sense to stay relativ close with Tickets to the standardized Tasks, as they are very similar with the exception of the replies.
So we should use participants instead of assigned and cc. Maybe have a quick check, if the other attributes use different names from Tasks/InfoLog, and change them too, obviously only if they exist in InfoLog/Tasks.

Sorry, for not writing that in the first review :(

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.

4 participants