Split mentions into 4 cases:
- Mentioned on article talk page
- Mentioned on agent's talk page
- Mentioned on another user's talk page
- Mentioned on any other page
Adjust secondary link
icon: article or talk
text: without namespace for article and article talk
Bug: T56433
Change-Id: Ibf965dad4f9cc468fdd4321b2450d6eaec0ac1d7
Wrap the CallbackFilterIterator backport class in a conditional check
for PHP runtimes that include the class natively. This really should
only be needed for linting as the class is loaded via an autoloader
and thus should not be loaded if the runtime already has it
available.
Bug: T124828
Change-Id: I39d27385186d4693a8babdd2b818e6b4bc16255a
Only display when it's different than the pre-populated
edit summary (Undo revision 123 by User).
Bug: T121808
Change-Id: I5a00ff174fd31fdbf776a06b7b9375f63b921677
There was no point in letting it extend EchoFlyoutFormatter instead
of the base EchoEventFormatter. The only things in EchoFlyoutFormatter
are formatModel & getIconURL, both of which aren't being called.
Change-Id: I89511530a41976974f4d51d55379a617dfe503ec
WikiMap is almost useful for this purpose, but not quite
because it doesn't provide the script path, only the article path.
Change-Id: I1627d58cab5ff518be3c3e14e05a53899b083503
All extensions seem to have been updated to use the current formats,
so we can get rid of this tech debt.
Depends-On: I7503db28b0d81fb818b525ea9362e49b9b56342a
Change-Id: Idbcbbf95eab1172015bceea4e8124ba4c639efa8
Also updated description value in agent link: '' is used everywhere
else to mean "no description" (because that's exactly what '' is)
Change-Id: Ib77c0f1843593abf67e9d726a80bb4fbe1ec7d84
We already output unix timestamp both in user preference timezone as well as
utc, but we only had the user timezone version for TS_MW format.
While we could change the frontend to use the unix timestamp format, I don't see
any reason not to also include the MW format in utc. Frontend can now easily use
that.
Also fixed creation of the moment object. The timestamp was created as UTC, but
the way it got there was wrong: it expects the timezone offset (Z) to be
included in the timestamp, which is not the case (so it just ended up at +0:00,
which was fine, but confusing). I removed the 'Z' and forced it to be
interpreted as utc.
Bug: T121813
Change-Id: I09403615a1ffbde5dd69af9914afdbdd86cbfe4d
We're trying to get rid of links in notification
messages, and the link was redundant with the primary link
in both cases.
Change-Id: I69e888a355c263b5a8c5ca7a46430746895de44c
They're currently auto-converted to the new format, but ideally,
we wouldn't need that B/C code. And since this is the extension
others will likely look at for examples when implementing, we
should do it right here.
Also: there is no B/C correction for missing keys in secondary
links (description, icon).
Change-Id: If1a8b9911e81bb4c565f21a4b9e31fdc73426d93
Also removes tests for the class.
Bug: T119253
Change-Id: I4c0d7187c2b847297dd0867faecba26185cfba37
Depends-On: Iccafbbdb06711463fee0f30a11326c7771df30e2
Right now, it'll only respond a certain, fixed, amount,
not allowing you to paginate the list.
Note: haven't properly tested all possible cases yet!
Change-Id: I84761b13a1b9203cb8e3fcc80941d739cd28659f
The only difference at this point is that fetchByUser initializes
the EchoNotification object with $targetPages. It doesn't really
matter that it doesn't have the target pages, since fetchUnreadByUser
is currently only used in the flyout, where those target pages aren't
used. But regardless of what method was used to fetch the data, I
think the data should be the same.
And now, there's less code duplication...
Change-Id: I04c7b98794af5427a2217dd337108e7eea1e65c5
Added code to redirect the user and display a short message informing
them of the need to login.
Bug: T118873
Change-Id: I2145bc1502dbd19d660302d9f19e0d4a2ad5ad50
Presentation models that display the number of bundled notifications
typically group these by a property like agent or page ID. For example,
every edit someone makes to a user talk page generates an event,
so there could be 5 edit-user-talk events by only 2 distinct users;
in that case we want to display "Foo and 1 other user left a message",
not "Foo and 4 other users".
With this change, a presentation model that wants such behavior
can pass a callback to getBundleCount() that retursn the user ID, which
will cause getBundleCount() to return the number of distinct
users rather than the total number of notifications.
Change-Id: I79c8dd14277eff0d2ec27f155b1d13dca1e571a8
I'm not really sure where to stick the primary link. I could wrap the
entire notification in a <a> tag, but all the text becomes ugly (I
suppose we could hack around it with CSS?). For now I just added it
before all the secondary links.
Change-Id: I4f6add9ecfb367660d1a6346825382ad415bdb77
The implementation of this sucks as the presentation model
should not be making database queries. But the API it provides
is what we want and will be supported even if the backend
implementation is changed.
Change-Id: Ifd0d11260990fd0e00e8f32eee273f9717d3e1fb
We should probably merge this ASAP now that a lot of presentation
models still have to be implemented. There's a bit of B/C code that
will take care of the previous format, but it would be nice to be
able to remove that soon.
Meanwhile I've also changed getPrimaryLink to follow the same format.
Bug: T115421
Change-Id: Ic18a050d2ee0239f287a6d55c572df6f8aebb59a
This implements a backend layer and database storage for tracking what
wikis a user has unread notifications on. It is not yet exposed via any
API.
Whenever the notification counts on the local wiki are reset, a deferred
update is queued to also update the central database table.
Change-Id: Id1498bdeb5811d6848dc66781ffca03e726eab90
Instead of relying on the frontend to render, this enables the frontend
to do it.
The API will now accept a new format: 'model', which is basically the
presentation model's data in json format.
Some of the render code is currently only in the backend (e.g. get icon
path from icon type) so other api formats will stay available. At some
point, however, we may be able to kill those.
Bug: T115418
Change-Id: Ibc3ad54c94d6ea9bf751f3927cf69e1d062f4780
It's basically impossible for DatabaseBase::select() to return false now
that ignoreErrors() is protected. So always return an array so callers
don't have to worry about false.
And remove a test that checked the result if DatabaseBase::select() did
return false.
Change-Id: I9ca8511585403d8c0ec262898ad4e61c2b038d51
`getMessageWithAgent` is used by `getHeaderMessage` is can
be reused by other presentation models who need the
agent in their body message.
Bug: T118059
Change-Id: I0cbccaeb8b6e60d03bc75bc85c74591619b4399a
Since EchoEventPresentationModel::canRender can reject notifications,
its result should no longer be used for infinite scroll.
Current code checks if the amount of to-be-rendered data exceeds what
we need to display, but if we reject some notifications that may no
longer be the case, even though there is more data still.
Change-Id: I3e5f8c2d1fc0c63db7b277324c96af043689ddce
getTextSnippet() has a `Language` type hint that will fatal if $wgLang
is a StubUserLang object, so make sure we unstub it if nothing else
already has.
Bug: T118542
Change-Id: I847680074fbbf95bbe3b6002151d2a18c45ebe6e
Wikis can customize the 'notification-welcome-link' to a page title
(like "Project:Welcome" for example) and the "Welcome!" notification new
users receive will have a primary link to that page.
Bug: T117509
Change-Id: I29f6d69db480fa7d39573941e762c4dad8737ed0
Because 'welcome' doesn't.
Returning `false` indicates that there is no link, and the
FlyoutFormatter was updated accordingly.
Change-Id: Ifd329b396f3361fc7c08c607a6407181ffdb8bf6
This seems better for availability than stopping the world
and rolling everything back (or just throwing post-commit
errors that didn't stop the original change anyway).
Change-Id: I816b3cb5f0d26de608e620a01571a332aa832c05
The conversion of EchoEvent into a EchoEventPresentationModel is now
done by EchoFlyoutFormatter, instead of having each subclass do it. It
also does the canRender() check so subclasses don't need to worry about
it.
The subclasses no longer have access to the underlying EchoEvent object,
so the timestamp is exposed in EchoEventPresentationModel.
Change-Id: I7f0a650373eebac7aa2231b1795b51a6d031ad67
Adds EchoEventPresentationModel::canRender() for notification types to
indicate that something can't be rendered if for example, a page is
deleted.
In that case, the notification is marked as read in a deferred update.
All callers were also updated to check if the notification was formatted
properly.
Bug: T116888
Change-Id: Idb975feaec893ef86c41cc487102e3539c07e328
The workflow to format a notification is
* Get EchoEvent, User, and Language
* Get EchoEventFormatter implementation for notification type
** EchoEventFormatter returns structured data about each part of the
notification (header, body, primary link, secondary link(s))
* Each output type will have a formatter class (e.g.
EchoSpecialNotificationsFormatter, EchoPlainTextEmailFormatter) which
takes a EchoEventPresentationModel and generates whatever it wants
(HTML, plain-text email, etc).
Included is an example conversion of the user-rights and mention
formatters. The previous infrastructure will remain in place for
backwards compatability until other extensions can be updated.
Bug: T107823
Change-Id: I4397872a7ec062148dfcb066ddd8ab83f40486ac
We only track revisions for some notification types, others still
reference usernames, but don't check for suppression status. If no
revision is available, use User::isHidden() to check whether
EchoEvent::getAgent() has been hidden.
Bug: T110553
Change-Id: I31e635e365bbb0f6c6ac63be2bdb07e5e2d67c96
This changes the revert notification (special page version) to link
to the contributions page for anonymous (logged out) editors.
It still links to the user page for logged in editors.
Bug: T55564
Change-Id: Ib1f17fb88237b96cda63dd30ed488a8ffd84750e
And rename "nojs" to "styles". It was supposed to mean base styles that
are used by no-JavaScript and JavaScript mode, but it confused people.
Hopefully "styles" is clearer.
Change-Id: Ie8d668fb0d95a9162392c5fa7c3200bcacef1025
Also:
* Clear the newtalk flag when they mark all their edit-user-talk
read.
* Remove the section caching system. It was designed to avoid
performance problems with Flow messages, but now that standard talk pages
are in 'messages', messages should be relatively common (alerts
were already not cached by this).
* Minor cleanups to reflect that messages are not only Flow (and
a typo fix in the Gruntfile).
Bug: T108760
Change-Id: I82d7b1d08331693830d6a1749612b55e96b95cf9
The key used was empty, and therefore did not work. Use the correct
key when caching 'hasMessages' for the user to see their message
badge when receiving the first message.
Change-Id: Ib5b07854f96efed974d53267d9ed573c6ca1cf04
So we're not abusing user preferences for the last seen time.
EchoSeenTime is a small wrapper around ObjectCache that handles the
fallback to user preferences during the transition.
All JavaScript code now needs to use mw.config.get('wgEchoSeenTime').
Bug: T95839
Change-Id: Ia45ba5e30eb4564250539d04d5886d2598ebd49a
Split the notifications into 'alert' and 'message' badget with two
different flyouts. Also clean up styling and module behavior.
** Depends on ooui change Id4bbe14ba0bf6c for footers in popups.
** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in
inverted icons.
** MobileFrontend must also be updated to support the new modules
in this patch I168f485d6e54cb4067
In this change:
* Split notifcations into alert and messages and display those in
two different badges.
* Create two separate flyout/popups for each category with their
notifications.
* Create a view-model to control notification state and emit events
for both the popup and the badge to intercept and react to.
* Clean up module load and distribution:
* Create an ext.echo.ui module for javascript-ui support and ooui
widgets.
* Create an ext.echo.nojs module that unifies all base classes that
are needed for both nojs and js support, that the js version
builds upon.
* Create a separate ext.echo.logger module as a singleton that can
be called to perform all logging.
* Clean up style uses
* Move the special page LESS file into nojs module so all styles
load properly even in nojs mode.
* Transfer some of the styling from JS to LESS for consistency.
* Make the 'read more' button load already with the styles it
needs to look like a button, since its behavior is similar in
nojs and js vesions, but before its classes were applied only
by the js, making it inconsistent and also making its appearance
'jump' from a link to a button.
* Delete and clean up all old and unused files.
* Moved 'Help.png' icon from modules/overlay to modules/icons for
later use.
Bug: T108190
Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
To avoid using $wgLang directly. We still have to use it in
detectSectionTitleAndText for now though.
Change-Id: Ic901ed05d4e8f6291caa55d866ce58f7300880f5
Although it wasn't here even before
c94c3f3dad , loadFromRow will make
use if it if it's present. Otherwise, it's the current timestamp
(which seems odd; if we really don't need the timestamp in a
particular scenario, null would be more straightforward).
This is also public (getTimestamp()).
Change-Id: I9d88d86dde5b7f9b5965c81225a2aab4354c2baa
Follow-up I6c956738, which started trying to pull notification_timestamp out
of nowhere. Although EchoEvent::newFromRow may try to use this if it's set, it
wasn't previously getting selected and this is now causing exceptions.
Bug: T105890
Change-Id: I2dd9e268428d651813d8c43d85d54fc97634cd41
As needed by EchoEvent::loadFromRow().
Alternatively, just '*' as in MWEchoEmailBatch::getEvents().
Bug: T105890
Change-Id: I6c956738125658607d5e548efad4031c3298020f
* These tend to log errors many times in a row for the same few
users in any given time period. There is probably some usage
pattern issue in JS on top of the abuse of preferences for
such tracking state. In any case, this should help.
Bug: T95839
Change-Id: I4d57b1db43a63300a412a5de220b66081da754f1
Push the $wgEchoNotifications dependency to
NotificationFormatter::factory(), and only catch exceptions we're
actually expecting (NotificationFormatter::format()).
And clean up the logging to use structured logging while we're at it.
Change-Id: I7e18c318c5c81b6a38e55f27ef8f604654f10858
The logic to get the URL for an icon was duplicated in the
EmailFormatter and BasicFormatter. It is now in the abstract
NotificationFormatter, which EmailFormatter and BasicFormatter now
use.
Changes in logic:
* Throw an exception if an invalid notification type is provided instead
of a PHP notice
* icons using 'url' may have different ltr/rtl icons
* Throw exception if icon is supposed to have different icons for
ltr/rtl, but doesn't, instead of debug logging
The new function is static so it can be used in EmailFormatter as it
does not inherit from NotificationFormatter.
Bug: T60726
Change-Id: Ia3c01c35f58eed8cc2c039249ab1ec1a80a8abbb
Fixes: PHP Notice: Found alias defined for Userlogin when
searching for special page aliases for UserLogin.
Change-Id: Ib64d4c76d3915ae752a9c56eb9635653e0da5623
This preference has been disabled since bug 47562, and doesn't make
sense to keep around given that the flyout is the main interaction most
users have with Echo.
Change-Id: I7e8ddf96dbde9a95ac01a0cc83bad396151d01bd
Old jobs were queued with array( $userId => $userId ), so there will be no
'0' index. Use array_values() since we don't care about the keys.
Change-Id: I1155d310c7fa09c728797d35d63c7cec0383511c
Rather than making each notification type opt-in to using the job queue,
make them opt-out by setting an 'immediate' => true flag.
Configure the 'edit-user-talk' notification type to be immediate since
it should not lag behind the orange bar indicator.
Change-Id: I707bc01a97082887c3f1c353d45cdf1c1eaeff04
EchoNotificationDeleteJob now only processes one user at a time. If
given multiple user ids, it will queue individual jobs for each user id
rather than processing many at once.
Bug: T102574
Change-Id: I627f059280d8fab3854d9ca8417f22179478772c
Instead, have subclasses implement checking required parameters
manually.
The only subclass that was using this was EchoBasicFormatter and has
been updated.
Change-Id: I23e2fa7044e0d59125530024f8c6c35516d3b90b
Pull out the logic that extracts usernames from links. This allows
it to be reused by the LQT->Flow import code.
Bug: T101979
Change-Id: Ib16a09cf1f388f56944cd1bb564384535728156e
* Do not default section to footer. If the section
is not found, it is left empty and the notification
message is simpler.
* Change notification-edit-talk-page-email-batch-body2
Replace : at the end with . so it does not look
incomplete.
Bug: T99989
Change-Id: Ic982a81eada388d750760787245dea8f72368147
All uses of $wgEchoBackendName were hardcoded to 'Db' and removed.
This exposed a interesting bug in MWEchoEmailBundler which was
instantiating a subclass using the parent class's private constructor, a
"feature" of PHP which is supported in 5.2.6+ (http://3v4l.org/h4Mq3).
While it worked, PHPStorm complained about it so I made the constructor
protected, which makes more sense anyways.
Both EmailBatch and EmailBundler need further refactoring, but that will
be done in follow up patches.
Change-Id: I2032f5b2f4f3a62f830cc5344b25a92074bd0c61
Update the "processEchoEmailBatch" to allow sending all
notifications immediately even if configured to be
daily or weekly.
Change-Id: I6ebeea86708247700d1950e0f6471c7b3d1fecd2
getNotificationCount & getLastUnreadNotificationTime have an
argument $cached that allows cache to be bypassed & read from
DB. That result is then stored to cache.
In practice, it seems to be used only for cache invalidation.
getLastUnreadNotificationTime didn't allow to specify the DB
to be read from, and EchoNotificationMapper::fetchUnreadByUser
only read from slave.
So when we wanted to invalidate the cache, we would end up
immediately repopulating it with data from a (potentially and
likely) lagging slave.
I've made it accept the DB type, similar to getNotificationCount.
Bug: T98421
Change-Id: Ie4b09eeb04b9827b454cb2d92ee8c674bdd59a19
I tried to stick as close to the existing code as possible.
Special:Notifications is slightly different from the overlay,
however. I made it add .mw-echo-unread class for consistency,
but that JS doesn't record seen time (it only loads older
entries), not does the CSS fadeout apply there (it marks
everything as read as soon as it's displayed, so different
behavior from overlay)
PS: I'm not sure about browser compat for the fadeout. But
even if some obscure browsers don't support this, meh. It's
not an "important" feature that can't be missed.
Bug: T94634
Change-Id: Ibb201823fb52ef8a3d5eaa39b0b724ede8d271d1
Link the bottom of the talk page and use the edit summary as text
if the parser failed to find something. This is what core's enotif
does already.
Change-Id: Iadc7011ea2627e00f0c51472da7aad1355afeddb
The default value is never used, it is overridden in the constructor.
Having it here just misleads someone looking at the code to think it
might pull all columns by default.
Change-Id: I0e743c371d4bd2fab5b89740ba1e0f082512ec34
While user-locators are the "new hotness", most events still get their
list of users by calling a hook. That means this log message basically
just spams up the prod echo log for no benefit.
Change-Id: Iba5a8267c4ecc5a7446b287759d8b66adf0e2387
* Parser generates signature to compare against
* Signature can be overwritten per wiki, in NS_MEDIAWIKI
* Such overwritten default can be different depending on
page the signature is on[1]
* Our comparison signature generation was page-agnostic
(always from Title::newMainPage)
* Signatures didn't match up on own talk pages, where
default signature is different
Also added 2 new tests cases & improved tests by also
setting the page
1: https://en.wikipedia.org/w/index.php?title=MediaWiki%3ASignature&diff=176507985&oldid=176229132
Bug: T78424
Change-Id: Ice151d4d16236a5d1556ef62805b61310c7beb85
Previously, there were a couple of hacks in play.
It was also not picking up ~~~ (signature without timestamp)
And it relied an a nasty regular expression which, although
based on Parser, may some day get out of date.
And it relied heavily on a specific signature format, which
isn't guaranteed (it's an i18n msg)
This patch changes the approach: it will use a very simple
regex to match links, and will send those through Parser to
generate the signature anew. My reasoning is that that should
be exactly the same as what Echo just received (should've
also gone through parser)
Biggest discomfort of this approach is that it's much stricter.
It should still match whatever it generated from a ~~~ or ~~~~,
but no longer the e.g. not-real signatures we were doing in
our tests. Also had to update our tests, because signatures
change depending on anon. So I had to generate all the users.
And fix some of the signature formats used in the tests.
Bug: T75426
Bug: T87852
Bug: T75366
Bug: T78424
Change-Id: Ibeff36397129fdd5d376f3668a23a45f9a014525
In some languages the \w+ does not match the characters used
when translating UTC and the regular expression attempting to
match the timezone fails. Testing in prod wikis where this fails
such as ne.wikipedia.org shows it still works, it just generates
a more generic regular expression.
Since the overall process still works acceptably on the wikis outputting
warnings this patch just adds a guard to prevent the warning and does
not attempt to fix the underlying issue.
Bug: T76558
Change-Id: If8e1ddd2d642b042cc24c51d5ba5aa8b34bc9552
There were two different circumstances that could trigger echo's signature
detection to fail: multibyte characters in signature, and signatures near
$wgMaxSigChars limit that expanded past the limit due to wfEscapeWikiText().
This patch adjusts to use mb_substr to appropriatly handle the multibyte
characters, and adds a couple extra charactesr to $wgMaxSigChars to allow
for wfEscapeWikiText(). This isn't perfect, but a stricter implementation
would require much more work than i think we should spend here.
Bug: 73426
Change-Id: Ic51c2bc2a08600f188db13a9a0537f1321c9a655
Previously this was loading 25 unread notifications. If less than 25 were
found it would add in 3 read notifications so it wasn't empty.
This patch changes things around to always return 25 notifications if the
user has at least that many. Instead of backfilling a static count of 3
we backfill 25 - $count with previously read notifications.
Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
Currently echo attempts to find a signature by looking for a series of
strings starting with what it thinks are the current aliases of NS_USER
and NS_USER_TALK. This has shown to be error prone, see the linked bug
for how a change to ru.wikipedia.org/wiki/Mediawiki:Signature broke
mention notifications.
Patch switches things arround to pull wikilinks out of the text and run
them through the Title class. The results of this parsing are checked
for NS_USER and NS_USER_TALK, giving a much stronger guarantee of finding
translated namespaces.
Bug: 71353
Change-Id: Ib0d0f4e068339d2fd28761087c05f5a1acb3c1fc
Has a performance impact, so this depends on deploying the job
that deletes older notifications.
Bug: 69919
Change-Id: Ia485c853d1b04c3c85e25e6a12f5060a046e9b11
The only issue is that the badge is not up to date till
you refresh the page, I think that's fine for now
Change-Id: I585b4cc185bf859ddb06829df75309ff3d56d8b8
* cache function result in local variables
* Update the logic of generating notification date header
Change-Id: I04c3ed853076f17c819da8f27bfdb169e99b2a3a
Core titleCache doesn't do what I expect it to do, issuing
Title::newFromId( 1 ) mulitple times would issue multiple
idential queries to the database. It doesn't return what's
already in the cache.
The goal of this patch is to batch load titles via newFromIDs,
and save the number of mysql queries
Change-Id: I8fe767ac2669e67bdf7d17eecccfc0dcb6b5fc7d
The new locateUsersWatchingTitle implementation could end up returning
thousands of users, currently on enwiki there are 25 titles with more
than 10k subscribed users and aprox 550 titles with more than 1k subscribed
users.
This switches the user collection to an iterator based implementation so that
we no longer need to have the entire users list at any one time.
Change-Id: I3d3fa9328f348bb48682d3658622952ce82d3925