aboutsummaryrefslogtreecommitdiffstats
path: root/includes/changes
diff options
context:
space:
mode:
authorTimo Tijhof <krinklemail@gmail.com>2020-04-16 01:46:47 +0100
committerKunal Mehta <legoktm@debian.org>2023-05-19 15:48:40 +0300
commit34dc4e6d26b5ea00313d6f4edd02bdd491f79ef2 (patch)
tree1bc65ec973ded539bd49e49964ff7d3743300cfc /includes/changes
parent44504ffaff7933ff638f5bb0dd62bb253970f78b (diff)
downloadmediawikicore-34dc4e6d26b5ea00313d6f4edd02bdd491f79ef2.tar.gz
mediawikicore-34dc4e6d26b5ea00313d6f4edd02bdd491f79ef2.zip
rcfeed: Add 'notify_url' and 'title_url' to MachineReadableRCFeedFormatter
* Move the current URL logic from IRCColourfulRCFeedFormatter to a new method RecentChange::getNotifyUrl (covered by tests now). * Re-use this method in MachineReadableRCFeedFormatter so that the diff/patrol/rcid etc URL is also available in the modern JSON-based EventStreams service. And in particular to allow porting of the legacy irc.wikimedia.org backend to a much simpler one that is based on this. * Also expose a title_url field which was previously missing, and made consumption of the data needlessly difficult. Bug: T234234 Depends-On: Id740134ef30b2276688d7b7caedb6bb652158761 Change-Id: Ic3e0aebdb61b5c0e5fbed08656db4a1e90b67518
Diffstat (limited to 'includes/changes')
-rw-r--r--includes/changes/RecentChange.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php
index e2b8fac32438..8ea5b5e9ceb5 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -1319,6 +1319,45 @@ class RecentChange implements Taggable {
}
/**
+ * Get the extra URL that is given as part of the notification to RCFeed consumers.
+ *
+ * This is mainly to facilitate patrolling or other content review.
+ *
+ * @since 1.40
+ * @return string|null URL
+ */
+ public function getNotifyUrl() {
+ $services = MediaWikiServices::getInstance();
+ $mainConfig = $services->getMainConfig();
+ $useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
+ $useNPPatrol = $mainConfig->get( MainConfigNames::UseNPPatrol );
+ $localInterwikis = $mainConfig->get( MainConfigNames::LocalInterwikis );
+ $canonicalServer = $mainConfig->get( MainConfigNames::CanonicalServer );
+ $script = $mainConfig->get( MainConfigNames::Script );
+
+ $type = $this->getAttribute( 'rc_type' );
+ if ( $type == RC_LOG ) {
+ $url = null;
+ } else {
+ $url = $canonicalServer . $script;
+ if ( $type == RC_NEW ) {
+ $query = '?oldid=' . $this->getAttribute( 'rc_this_oldid' );
+ } else {
+ $query = '?diff=' . $this->getAttribute( 'rc_this_oldid' )
+ . '&oldid=' . $this->getAttribute( 'rc_last_oldid' );
+ }
+ if ( $useRCPatrol || ( $this->getAttribute( 'rc_type' ) == RC_NEW && $useNPPatrol ) ) {
+ $query .= '&rcid=' . $this->getAttribute( 'rc_id' );
+ }
+
+ ( new HookRunner( $services->getHookContainer() ) )->onIRCLineURL( $url, $query, $this );
+ $url .= $query;
+ }
+
+ return $url;
+ }
+
+ /**
* Parses and returns the rc_params attribute
*
* @since 1.26