Commit graph

27 commits

Author SHA1 Message Date
Fomafix 4bf74e6415 Inject services in Hooks and MobileFrontendHandler
Hooks::canReceiveThanks is still static, because it is also used in
MobileFrontendHandler.

Change-Id: Idff34ebce914ad37bcaea8de04b3ef5e01d7d98d
2024-03-14 20:27:26 +00:00
Umherirrender f5db77c750 Use namespaced classes
This requires 1.42 for some new names

Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I1b433ab02231087e0f84a734092751ce2cf28b2c
2024-01-04 22:22:56 +01:00
Ed Sanders 1e77d0163f Document generated messages
Change-Id: I89101839f7c056cdd509e000fb0bbc8573f97515
2023-11-30 11:52:11 +00:00
Fomafix bfe320c2ea Move onBeforeSpecialMobileDiffDisplay to class MobileFrontendHandler
This avoids a hard dependency on extension MobileFrontend.

Change-Id: I7dd3972145c1fbffae9bc58ed0d3157310a53354
2023-11-16 14:46:27 +00:00
Fomafix af5658ae05 Implement hook interfaces in Hooks
* BeforeCreateEchoEventHook and
* EchoGetBundleRulesHook from extension Echo and
* BeforeSpecialMobileDiffDisplayHook from extension MobileFrontend.

Change-Id: Icede5f70f988957f245fac1984a63f01fa1d0f44
2023-11-08 11:42:01 +00:00
Fomafix 212c72d5e7 Replace global config variable
Change-Id: Ibe5c6d077ebd1413359c1bcb4b16388874f3f5ea
2023-11-07 21:09:55 +00:00
Jon Robson f47a195079 Minerva: Thanks should use Codex classes for thanks link
Without this Thanks button will be unstyled on Minerva skin.
In the desktop Minerva diff page, the button should be a progressive button
for consistency with Special:MobileDiff

Testing:
* Check diff mode (AMC disabled)
* history page (AMC enabled)

Bug: T345768
Change-Id: I038cfab627eea2fdf558accbf390a8d2d02153a1
2023-10-19 21:17:08 +00:00
Martin Urbanec 9cef38e80f IP Masking: Do not allow temporary users to thank other users
It has been decided to not allow temporary users to thank
other users (see task). This is because the transition
between anonymous and temporary account is nearly invisible,
and it might be confusing why the thanking ability appears
and hides.

Bug: T345679
Change-Id: I62e67327c9a80b3da9e98a2dccdd4ec2051f3026
2023-10-03 22:23:02 +00:00
Umherirrender a5fc01da56 Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.

Bug: T338457
Change-Id: If844970f0c8d8f09d0de2a2140b080d1292530a1
2023-09-28 23:32:52 +02:00
gerritbot e2ed94cff3 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I491f0a12aaa4d70a4b6eccda3a478b223896feaa
2023-08-19 14:27:12 +00:00
jenkins-bot e14d02fbd1 Merge "ServiceWiring: Rename LogStore to ThanksLogStore" 2023-06-10 08:28:06 +00:00
Siddharth VP 6b71b859ee Use namespaced Echo classes
Change-Id: I1ff1d1772e615bc618ed2dd0080795cdfd98e79e
2023-06-09 23:16:35 +05:30
Kosta Harlan 21254130e6
Hooks: Don't set Echo options for temp users
Bug: T337851
Change-Id: Ibd7c3987404674aefaefcaf261071b2b4da41f44
2023-06-01 10:54:29 +02:00
Func b96b4e1fde ServiceWiring: Rename LogStore to ThanksLogStore
`LogStore` is too ambiguous, usually services from extension should
be prefixed with its name.

Change-Id: Ia8a8474ac44ee9990b22ca4650d3ae5311744d19
2023-05-26 21:08:54 +08:00
Marcin Kostrzewski e483b844c9 API: Refactor to match modern code standards
I've moved all API classes into a separate folder,
as I felt like grouping modules improves readability.
APIs themselves had storage logic which I extracted and put
in another folder. I was originally going with an interface
to the storage to allow for other storage methods than
log entries, but the code was too tightly coupled with it,
so I've left that for another day. Added dependency injection
for all services and used ServiceOptions for config vars.

Bug: T337002
Change-Id: Ie8a1f435d635e1d0e1286f673bfe96cc4fdfe4fe
2023-05-20 17:57:26 +03:00
Matěj Suchánek 1f39e662d8 Replace deprecated hook handler with user locator
Change-Id: I97de923f1e63f05ab4e4887fd4fce6a5800e668b
2023-01-04 19:15:06 +01:00
Thiemo Kreuz a9878ab2ab Some smaller general code cleanups
In detail:
* Use more compact syntax to avoid a bit of code duplication.
* Use createMock() shortcut in tests.
* Avoid hiding code in strings.
* Remove a comment that literally repeats what the code says.

Change-Id: Ibedef380489451268e2e87f0864164e8f9737913
2023-01-03 12:30:41 +01:00
TheresNoTime 09e88294fc
Hooks: fix spelling mistake
Change-Id: I3aa9e02eee5cceca37edfacfa95cc89a80bc90c4
2022-12-21 20:38:48 -05:00
Dayllan Maza 819b71f9cd Thank: Fix thank action with no revision id
This is a temporary fix by not showing the thank action
on log entries for pages that use the new PagerTool.

There should be a follow up to allow PagerTool to call
a different hook that can take a reference to log entries
and properly generate the thank action depending on
the type (revision/log)

Bug: T325753
Change-Id: Icaaa044420baa26efdafc7f3fe049b9f58c72ee8
2022-12-21 11:10:22 -05:00
Roan Kattouw 2e2c2c6188 Load Thanks JS on more special pages
Due to Ia03038e86c6a607c8b75eefedbf0285ca1a2f8c8 in MW core, the thanks
links now also appear on Contributions and Recentchanges/Watchlist. Load
the thanks JS module there too, so that users can send thanks without
leaving the page.

(Unfortunately, we can't add this module in the hook that adds the
thanks links, because we don't have access to an OutputPage object
there.)

Bug: T51541
Change-Id: I00ecd3b2c72332b6dc5290e649e6811cea0133af
2022-12-15 16:39:35 -08:00
AnaïsGueyte d287af1af1 Remove GlobalBlock calls from Thanks
Remove the usage of User::isBlockedGlobally and User::getGlobalBlock

Bug: T318891
Change-Id: I79450b34523d0ecb1a7a7b1e5a99b7650e02866e
2022-11-09 14:01:45 -05:00
Amir Sarabadani 725bd574d7 Don't call saveOptions in Hooks::onAccountCreated
It is causing deadlocks because after hook being called and done, core
itself calls saveSettings(). See:
a2e5997a4c/includes/auth/AuthManager.php (1515)

Bug: T306636
Change-Id: I5ded25f56a58bf89b894a8fdd6d8200fb378eb75
2022-06-01 14:19:15 +02:00
Umherirrender 778980cba6 Replace deprecated User::newFromIdentity with UserFactory
Moved the factory deeper into the code right before the one usage it
still needed a full user object.

Narrow done method arguments from User to UserIdentity
and use the identity directly

Change-Id: I2231db43f525a74e93dba8ea5865b256efd2dfce
2022-02-11 20:35:47 +00:00
Tim Starling 8fdb3aca5e Fix history tools performance
Thanks was causing history views to do 4 DB queries per row, due to the
RevisionStore::getPreviousRevision() call. The reason for doing it is
that it doesn't make sense to thank someone for a diff which includes
multiple authors. This does not apply to history pages -- even for
filtered history views, you can thank someone for a specific revision on
the basis of its edit summary.

So, distinguish between history tools and diff tools. Do the expensive
thing only for diff tools.

Bug: T284274
Change-Id: Ib631100b82958065a327dd18c927af4a78b8be15
2021-06-29 13:01:05 +10:00
STran 43dd004a62 Allow partially blocking giving thanks
- Add hook to enable blocking thanks
- Check if user is blocked from 'thanks' action
  and disable giving thanks from  API and UI if so

Bug: T242785
Change-Id: I290a7c39c6fcb22a8ab4a9ecbad76a239cb18ea0
2021-05-12 13:06:09 -07:00
ZabeMath f36a08e6bc Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: Iacc258705c4517c958a2568e47ba4f43963acc2e
2021-04-02 19:22:40 +02:00
Reedy 3749db7eba Namespace extension
Change-Id: Ic9e0b8d6b3cc6b9be4d6b026cb0a3b4a12aef38f
2021-03-20 18:22:17 -07:00
Renamed from includes/ThanksHooks.php (Browse further)