(In reply to Bastien Abadie [:bastien] from comment #10) > Is the herald rule triggered when a new diff is published on the revision though ? Even if we do not have direct access to the DIff ID/PHID, we need a trigger for every new diff. Ok the only way to make this work is to follow the suggested in the User Documention for webhooks [1] and to query the API after getting the initial webhook when a revision changes, to find out what the transactions were. So basically we set up a differential revision herald rule that triggers when change is made. The rule then sends the webhook to your endpoint. The webhook data will include a list of transactions (PHID-XACT-DREV-*). Then your code will need to use the `transaction.search` conduit API endpoint [2] to get additional information about the transactions. Your code will then look for any transaction where there is a diff change (example below) and get the new diff PHID. Then you can make another call to the conduit API to get the full details of the diff using `differential.getrawdiff` [3]. ```json { "result": { "data": [ { "id": 236999, "phid": "PHID-XACT-DREV-ilhpubx4fzqthzy", "type": "comment", "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "objectPHID": "PHID-DREV-syiyscpw7zbvu6c5axyg", "dateCreated": 1733777349, "dateModified": 1733777349, "groupID": "qd36d4dwwjuifxqzlxxvuam2walwzjat", "comments": [ { "id": 21272, "phid": "PHID-XCMT-n27bnx5uu5nogn4refti", "version": 1, "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "dateCreated": 1733777349, "dateModified": 1733777349, "removed": false, "content": { "raw": "Test" } } ], "fields": {} }, { "id": 236998, "phid": "PHID-XACT-DREV-h6lca2lnla4l5bc", "type": "update", "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "objectPHID": "PHID-DREV-syiyscpw7zbvu6c5axyg", "dateCreated": 1733777349, "dateModified": 1733777349, "groupID": "qd36d4dwwjuifxqzlxxvuam2walwzjat", "comments": [], "fields": { "old": "PHID-DIFF-okg32awaq7icxcb42x7r", "new": "PHID-DIFF-fvkaposhkoodd266lf2c", "commitPHIDs": [] } } ], "cursor": { "limit": 100, "after": null, "before": null } }, "error_code": null, "error_info": null } ``` [1] https://phabricator-dev.allizom.org/book/phabricator/article/webhooks [2] https://phabricator-dev.allizom.org/conduit/method/transaction.search [3] https://phabricator-dev.allizom.org/conduit/method/differential.getrawdiff
Bug 1935142 Comment 11 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to Bastien Abadie [:bastien] from comment #10) > Is the herald rule triggered when a new diff is published on the revision though ? Even if we do not have direct access to the DIff ID/PHID, we need a trigger for every new diff. Ok the only way to make this work is to follow the suggested in the User Documention for webhooks [1] and to query the API after getting the initial webhook when a revision changes, to find out what the transactions were. So basically we set up a differential revision herald rule that triggers when any changes are made. The rule then sends the webhook each time to your endpoint. The webhook data will include a list of transactions (PHID-XACT-DREV-*). Then your code will need to use the `transaction.search` conduit API endpoint [2] to get additional information about the transactions. Your code will then look for any transaction where there is a diff change (example below) and get the new diff PHID. Then you can make another call to the conduit API to get the full details of the diff using `differential.getrawdiff` [3]. ```json { "result": { "data": [ { "id": 236999, "phid": "PHID-XACT-DREV-ilhpubx4fzqthzy", "type": "comment", "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "objectPHID": "PHID-DREV-syiyscpw7zbvu6c5axyg", "dateCreated": 1733777349, "dateModified": 1733777349, "groupID": "qd36d4dwwjuifxqzlxxvuam2walwzjat", "comments": [ { "id": 21272, "phid": "PHID-XCMT-n27bnx5uu5nogn4refti", "version": 1, "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "dateCreated": 1733777349, "dateModified": 1733777349, "removed": false, "content": { "raw": "Test" } } ], "fields": {} }, { "id": 236998, "phid": "PHID-XACT-DREV-h6lca2lnla4l5bc", "type": "update", "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm", "objectPHID": "PHID-DREV-syiyscpw7zbvu6c5axyg", "dateCreated": 1733777349, "dateModified": 1733777349, "groupID": "qd36d4dwwjuifxqzlxxvuam2walwzjat", "comments": [], "fields": { "old": "PHID-DIFF-okg32awaq7icxcb42x7r", "new": "PHID-DIFF-fvkaposhkoodd266lf2c", "commitPHIDs": [] } } ], "cursor": { "limit": 100, "after": null, "before": null } }, "error_code": null, "error_info": null } ``` [1] https://phabricator-dev.allizom.org/book/phabricator/article/webhooks [2] https://phabricator-dev.allizom.org/conduit/method/transaction.search [3] https://phabricator-dev.allizom.org/conduit/method/differential.getrawdiff