Commit graph

59 commits

Author SHA1 Message Date
TChin
eac9174eb3 Added integration tests for ApiQueryExternalLinks
Bug: T286498
Change-Id: Ie97a517968a498de5b2d282a9e30027c2462d450
2021-07-16 16:30:21 -04:00
daniel
b38e0e8e32 REST edit: handle null edits correctly
For null-edits, the new revision is the same as the old revision.

Bug: T277601
Change-Id: I73f902f7ef890470ff6ee3e4500095adbb00938a
2021-03-19 14:10:25 +01:00
James D. Forrester
5a622b6a2e build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.18.1
Change-Id: I5e3687be2b197134578126e1b890ee37dbc1bc1b
2021-02-18 08:39:09 -08:00
Kosta Harlan
9445358f6e Avoid Promise.all when creating users to prevent deadlock
See also I884ca6e15a1

Bug: T199393
Change-Id: I3d0a8c3896e7879bc48e251beb26b41a328b71d0
2021-01-05 14:13:07 +00:00
daniel
fa8ddd48fc Implement /revision/{id} endpoint
Also implements and endpoint for revision source,
for parity with /page/{title}.

Bug: T267981
Change-Id: I88c714df6e428fbc02aa4ff7f4ecea7d8b458468
2020-12-14 16:54:43 +00:00
daniel
a4b51d2774 Implement /revision/{id}/html endpoint
This doesn't have caching yet.

Bug: T267981
Change-Id: I32a35bb7bc6c6832ce7c79fb942922abc1ddb0e0
2020-12-14 16:54:35 +00:00
daniel
36127ffd9d ApiOptions: log when userjs-* option changes
Bug: T259073
Change-Id: I99b9f224d3c0c21ef22a0ffa98ad2f72bf300943
2020-09-15 16:50:03 +02:00
Nikki Nikkhoui
783258900f UserContribs tags prop as array
Make the tags property in each contribution in
the User Contributions REST endpoint an array of tag
objects (instead of a key/value pair mapping tag names
to tag properties).

Bug: T259716
Change-Id: I8265ded81f05fef5f88d5a565266f91a307dd38c
2020-08-25 22:31:17 +00:00
Nikki Nikkhoui
c26d64fc18 UserContributions endpoint add tags 'display' property
Add a property to the 'tags' object in the /user/{name}/contributions
REST endpoint named 'display' which shows the display
HTML for the tag which is either defined in i18n .json
files or overriden at MediaWiki:tag-$name

Bug: T259716
Depends-On: I57e2a7253944a3fde3f52f52bbf5fe8473c8a415
Change-Id: Id755adcab8b0115e19df2a6046643ebe97881e28
2020-08-19 06:04:50 -07:00
Nikki Nikkhoui
c0f4b8a1eb Make array of tags with property 'text'
Change the tag property on each contribution from an
array of strings to an array of objects with property
'text'.

Bug: T252202
Bug: T235073
Change-Id: I9ececd1f351600e3e0fd54be2fb34449898285e1
2020-08-06 07:35:29 -07:00
jenkins-bot
8991f53965 Merge "REST /page/{title}: Fix title encoding." 2020-07-28 19:09:48 +00:00
Nikki Nikkhoui
3ba476102d /contributions/user/{user}/count
REST Endpoint for getting the number of contributions for a given
user (not yourself).

Change-Id: Ib3bfedcec0aa1af1983cec0a7bda28fc49ddc673
2020-07-28 18:36:41 +00:00
daniel
d2d2906ce7 REST /page/{title}: Fix title encoding.
Page titles used in URL paths, such as the Location header returned
after a page was created, must use the correct encoding for spaces and
pluses.

Bug: T258606
Change-Id: I75e91ac8f8da4eb183a9c8f1a682ea08c2225227
2020-07-23 23:17:17 +02:00
Nikki Nikkhoui
43f2d5440f Rename 'revisions' to 'contributions'
Extensions have the ability to inject their own idea of what
a contribution is into the ContribsPager query resultset (via
the ContribsPager__reallyDoQueryHook). Because of this,
stable chronological ordering of ContribsPager results
becomes virtually impossible

For the purpose of the User Contribution REST endpoints, we will
restrict the resultset to ONLY mediawiki revisions for now.

This patch renames 'revisions' to 'contributions' and adds the
'type' field to future-proof work on adding different kinds of
contributions to the User Contribution REST endpoints.

Bug: T257838
Change-Id: I1e6de1c14a5f47e0310df86325fa6d791833addb
2020-07-22 18:29:29 +02:00
Ostrzyciel
435d5f4d55 Add mw-manual-revert change tag
Based on the patch that introduces manual revert detection, this is
to create a software-defined change tag that will be applied to all
edits that restore a page to an exact previous state. This is also
for consistency with mw-undo and mw-rollback that will make a
"reverted" tag appear on reverted edits in the future.

Note about the REST API tests: in the next patch in this chain
I encountered even more issues with comparing returned changed tags
with expectations, so I decided it'd better if we just checked the
change tags applied manually in these tests. Otherwise we can run into
nasty race conditions, as the reverted tag is processed after sending
the response to client in the deferred update. It also makes the test
hard to maintain.

Bug: T256001
Change-Id: Ic367886f39faedcb823222b7d63bf4d5cb236ae9
2020-07-16 13:29:12 +02:00
Nikki Nikkhoui
764fd295c4 ActionAPI Tag end to end test
Create initial test for action api action=tag
end to end test.

Bug: T256826
Change-Id: I7b4f43112534efd7258cf1368d198fbe4bdef7d8
2020-07-14 13:16:52 -07:00
daniel
7717db62e1 REST /user/{name}/contribs
Bug: T235073
Change-Id: Ia262d055185c20142629d0824e4ba14a5e5fa9d3
2020-07-09 12:34:52 -07:00
daniel
afdcacbfd5 REST /me/contributions/count filter by tag
Bug: T251806
Change-Id: Ib071ebb91f20a0ca1c0e14b4a271fc17f343a648
2020-07-06 19:56:17 +02:00
daniel
c1a73e64e1 REST me/contributions/count endpoint
Introduce endpoint for getting a uer's contribution count.

Bug: T251805
Change-Id: I409b7943941437f46dd8cdb2194fca9b7404f185
2020-07-06 09:28:33 +00:00
daniel
2cf5a251b9 me/contributions: filter by tag
Bug: T251803
Change-Id: I5ba4164abe414df4b24858422f2a601e00516d7f
2020-07-02 22:27:21 +02:00
daniel
01b959fb83 UserContributions endpoint: return deltas
Bug: T252202
Change-Id: Ie38c658bddb974ded85a532b2fc556af5706275e
2020-06-26 11:44:57 +02:00
jenkins-bot
038f57ec69 Merge "REST /me/contributions: return change tags" 2020-06-25 18:03:14 +00:00
Nikki Nikkhoui
7452d8c067 REST /me/contributions: return change tags
The endpoint for user contributions should include change tags in the
result. Bump the version of npm module api-testing.

Bug: T252202
Change-Id: Iccc0c378bc65d0f34b38557f4c78f424d95a951f
2020-06-25 19:28:02 +02:00
Ed Sanders
c7926a58d6 api-testing: Fix variable scopes to avoid shadowing
Change-Id: I3ba5e9bd98c0e66c7e4050ca5c9f0320042149d7
2020-06-24 13:21:36 +01:00
Ed Sanders
08510de602 api-testing: Use wikimedia/mocha eslint config
Change-Id: Iec346d87f252c66fbff1e0fa522d7440df6f1764
2020-06-18 19:20:33 +01:00
jenkins-bot
2d34500f59 Merge "UserContributions endpoint: filter suppressed revisions" 2020-06-16 18:33:33 +00:00
jenkins-bot
94a0cdec43 Merge "REST api: bump some endpoints to v1" 2020-06-16 16:36:21 +00:00
daniel
96aacab20b UserContributions endpoint: filter suppressed revisions
ContributionsLookup needs to have the acting user (the authority) passde
in explicitly, so suppressed user contributions can be filtered according
to the user's permissions.

Bug: T252202
Change-Id: I94098f87ae45cd4e1db4a7168bf6e9478e9e32fc
2020-06-16 08:20:32 -07:00
daniel
5601152836 REST /me/contributions: implement backwards paging
This is part of a chain of patches that implement the user
contributions endpoint. This patch adds the ability to navigate
towards newer newer contributions from a response listign older
contributions.

Bug: T252202
Change-Id: I54c43f3c7bd5d2fa55431eda733291a7067bfc75
2020-06-15 11:41:36 -07:00
Nikki Nikkhoui
fbe321166e REST /me/contributions: allow paging forward
This is part of a chain of patches that implement the
user contributions endpoint.

In this patch, we add the ability to page through changes,
from latest to oldest only.

Bug: T252202
Change-Id: If1e862e419ce86b68606ddf28a78304461d3a6d8
2020-06-12 13:50:16 +02:00
daniel
2f3e07a6c9 REST api: bump some endpoints to v1
The following endpoints move from v0 to v1:

  GET page/{title}/links/language
  GET page/{title}
  PUT page/{title}
  POST page
  GET page/{title}/bare
  GET page/{title}/html
  GET page/{title}/with_html
  GET page/{title}/links/media
  GET file/{title}

NOTE: after merging this, give SRE a heads up, e.g. by
putting a note on the train ticket when this is merged
(navigate from T254174 as appropriate). 

Bug: T255043
Change-Id: I3b8890da901e6312582d9a215c6a647173f16149
2020-06-11 20:16:47 +00:00
daniel
5ac84ffd12 REST /me/contributions: return revisions
This is part of a chain of patches to complete the REST User Contributions
endpoint. This change returns a list of the 2 (hard-coded for now) most
recent revisions for a given user.

Package.json was also updated for new api-testing module (v 1.1.0)

Bug: T252202
Change-Id: I42a5dfc0e1ff7600848e89ac2c4b002e8a3612df
2020-06-09 08:19:45 -07:00
Nikki Nikkhoui
300fcfd00b REST me/contributions: Returns 401 Unauthorized
This is the first in a chain of patches that iteratively create
the me/contributions endpoint that returns a list
of contributions by the currently logged in user.

This patch contains stubs for major classes needed
as well as implementation and test just for returning
a 401 Unauthorized for anonymous users.

Bug:T252202
Change-Id: Ib75711bb015f476e9d486cb3008eb7b06b148d00
2020-06-09 15:00:25 +00:00
jenkins-bot
12e424bb78 Merge "Move final batch of tests from api-testing to core" 2020-06-08 19:37:11 +00:00
daniel
2051b84e5f PageHistoryHandler: fix self-reference route
THis introduces Handler::getRouteUrl() and uses it in
PageHistoryHandler() to generate self-reference links to adjacent
segments of the response.

Bug: T252566
Change-Id: Ie7b2c6cc63c8a499d4714336b917a9e3328294ca
2020-06-08 18:56:26 +02:00
Clara Andrew-Wani
daf10105a8 Move final batch of tests from api-testing to core
Moving tests that were added to api-testing repo after the initial
move to core.

Tests are from:
* Ifdfc56a80e70f169fa857af4123041723463cf90
* I55f9b23805f4c10449a508633f36c0bb75b06717
* I04db44c89a7b0bcb6dabb2ab9d9d96d495d98e82
* I3b74a9fb2f318158a72856599db837f63426ae4d

Change-Id: I83fc653f1a2f44cc12a5452cd659e809e6332b37
2020-06-05 11:28:52 -04:00
Ed Sanders
8b720e9bd6 eslint: Update to eslint-config-wikimedia 0.16.0
* valid-jsdoc replaced with jsdoc plugin
* New /selenium config

Change-Id: I471eebac0312cb25c539c3f6a3ecfc7cfd4ed8d6
2020-06-02 21:32:56 +01:00
jenkins-bot
f11aee48da Merge "CreationHandler: fix redirect URL" 2020-05-26 19:07:43 +00:00
daniel
504e9c446f CreationHandler: fix redirect URL
Add missing version prefix to Location header emitted after successful
creation.

Bug: T253143
Change-Id: I6262f61668cefacce12ed6f2a976340e10cf105b
2020-05-25 11:13:18 +02:00
Nikki Nikkhoui
eeac328472 Move Search endpoints into core routes
Move both search endpoints from coreDevelopmentRoutes to coreRoutes, making them
accessible in a production environment.

Change-Id: I14c1a9eb4c76a22f72caa7ae201699d4ef9eb282
2020-05-20 11:52:47 -07:00
Ed Sanders
d94f90e088 eslint: Code style fixes for upcoming config change
Change-Id: Ief44c0bb26c5a1c1773cab5dba51d5e856612bf7
2020-05-14 22:19:55 +01:00
Peter Ovchyn
7df7b923da rest: Add 'thumbnail' and 'description' fields to the search response
By default, core adds those fields as null to each row.
provideThumbnail and provideDescription hooks are introduced.
Extension should subscribe on the hooks to provide a thumbnail and description respectively.

Bug: T250144
Change-Id: I42c6c8ff9d887a440174af2a21c7921573b06640
2020-05-05 19:35:52 +03:00
jenkins-bot
f98a9e576a Merge "SearchHandler: emit Cache-Control header." 2020-04-06 15:53:50 +00:00
daniel
7d8fe94ea2 SearchHandler: emit Cache-Control header.
Completion search used for type-ahead should make use of http caches,
like ApiOpenSearch does.

Bug: T245675
Change-Id: Ia8366684203381b6c4dc55669a6877e53e9ffe40
2020-04-06 13:37:49 +02:00
jenkins-bot
83fc4e8c11 Merge "SearchHandler: add support for completion search" 2020-03-27 15:55:48 +00:00
daniel
76b703fe5c SearchHandler: add support for completion search
This defines a new REST route, /coredev/v0/search/title

Bug: T246387
Change-Id: Ib8d64f3028d3fa2ce239f922181064a3fc91a488
2020-03-26 20:38:30 +01:00
jenkins-bot
fde16090b6 Merge "REST endpoints: Add etag and last-modified headers" 2020-03-26 03:15:58 +00:00
jenkins-bot
6d791abd80 Merge "Define POST handler for /page/: create page" 2020-03-26 01:33:50 +00:00
daniel
22561b64a7 REST endpoints: Add etag and last-modified headers
Modified endpoints:
* /v1/page/{title}/history
* /v1/revision/{id}/bare
* /coredev/v0/page/{title}/links/language
* /coredev/v0/page/{title}/links/media
* /coredev/v0/file/{title}

Bug: T238374
Change-Id: I3ddf8fafc17eba3aec724a445d38af98bbc74dc1
2020-03-26 00:18:34 +01:00
daniel
c4382301cc REST Handlers: use max-age not maxage for cache-control
Smally typo, big consequence.

Change-Id: I1d8f43dd3b11e4854b08d41fb5f0c7ede3dba90e
2020-03-25 22:38:03 +01:00