Page MenuHomePhorge

Add conduit endpoints for querying legalpad
ClosedPublic

Authored by roguelazer on Aug 4 2021, 23:28.

Details

Reviewers
speck
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rPa4948ec800e9: Add conduit endpoints for querying legalpad
Summary

This diff adds conduit methods for searching for legalpad documents and signatures. This is very helpful for auditing who's actually signed a document. It also fixes the "contributorPHIDs" constraint in the existing search engine.

In order to expose legalpad signatures through Conduit, this adds a phid column to the legalpad_documentsignature table. It includes a migration (in the style of many previous phid-adding migrations) to actually populate the column.

Test Plan

We run this on my company's internal fork and it seems to work okay. I don't think any other conduit methods anywhere have tests (???), but if you can point me at one I'm glad to write a unit test!

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Aug 4 2021, 23:28

Wow, this is something I developed for wikimedia but not nearly as extensive! I'll try to give some code review when I have a few minutes to look this over.

I'm not familiar with the search engine or legalpad frameworks but things look like they line up

src/applications/legalpad/conduit/LegalpadDocumentSearchConduitAPIMethod.php
4

I believe there's a getApplication() function that should be overridden to associate these APIs with the Legalpad application. Doing so will cause the APIs to require access to the Legalpad application by the accessor/viewer.

Additionally is there a way to provide more information about search constraints for these apis, a la getMethodDocumentation()?

src/applications/legalpad/phid/PhabricatorLegalpadDocumentSignaturePHIDType.php
7

:legs:

src/applications/legalpad/query/LegalpadDocumentSearchEngine.php
56

Ah, caught a copy/paste issue?

src/applications/legalpad/storage/LegalpadDocumentSignature.php
63

Maybe use $this->getPHIDType()

roguelazer added inline comments.
src/applications/legalpad/conduit/LegalpadDocumentSearchConduitAPIMethod.php
4

getApplication is implemented by PhabricatorSearchEngineAPIMethod: rP src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php:29-33

getMethodDocumentation and getMethodDescription are also implemented automatically in PhabricatorSearchEngineAPIMethod. It doesn't look to me like they're overridden by any of the other subclasses of PhabricatorSearchEngineAPIMethod?

src/applications/legalpad/query/LegalpadDocumentSearchEngine.php
56

Yep. I guess people don't use these constraints very often...

src/applications/legalpad/storage/LegalpadDocumentSignature.php
63

will do!

roguelazer marked 3 inline comments as done.
  • DRY up LegalpadDocumentSignature::generatePHID()

FWIW here is my implementation which overlaps somewhat:

https://phabricator.wikimedia.org/rPHAB4e9fe6e8a314ceb2be1e74dd448fe91bc5f78182

I don't think I innovated anything and your code looks roughly better than mine I think.

Ok my implementation had a couple of additional search constraints which are missing here. Otherwise this looks good to me and is more complete. I'll probably abandon my patch and apply this one if you don't mind including the additional search constraints. (See suggested edits.)

src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php
26
45
src/applications/legalpad/conduit/LegalpadDocumentSearchConduitAPIMethod.php
4

Thanks for checking. Does the conduit page for these new apis identify the search criteria (constraints?) that can be used? If so then this is probably all connected via some reflection.

roguelazer added inline comments.
src/applications/legalpad/conduit/LegalpadDocumentSearchConduitAPIMethod.php
4

It does:

Screen Shot 2021-08-24 at 12.01.49.png (1×4 px, 304 KB)

  • add additional constraints as requested

I think this looks good, and based on the (non-search-engine) conduit API stuff I'm familiar with I think everything looks correct.

One thing I'd like to increase on Phorge changes is adding comment documentation where it makes sense. I'm not sure what additional documentation would make sense here, as most of understanding this is understanding the existing Legal Document/Signature models and the Search Engine framework.

src/applications/legalpad/conduit/LegalpadDocumentSearchConduitAPIMethod.php
4

Ah thanks!

This revision is now accepted and ready to land.Aug 24 2021, 19:22

I'm going to look at trying to land this today. Additionally I created T15042 to avoid situations like this where the changes are accepted but don't get landed for some time.

This revision was automatically updated to reflect the committed changes.

Thanks for landing, and sorry for the delay; was away on vacation. I'll try to be more responsive in the future!