Tweichart has uploaded a new change for review.
https://gerrit.wikimedia.org/r/218302
Change subject: small changes for shoutbox mentions
......................................................................
small changes for shoutbox mentions
* if a user mentions himself don't trigger the notification
* also there's no need to trigger the watched article notification on new sb
entry if the user just mentions himself
* if others are mentioned too, the notification will be triggered as before
Change-Id: I9fa9933e6cf3f8ba7fb0e9ba9e47a2e1589d561d
---
M Notifications/Notifications.class.php
M ShoutBox/ShoutBox.class.php
2 files changed, 22 insertions(+), 1 deletion(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/02/218302/1
diff --git a/Notifications/Notifications.class.php
b/Notifications/Notifications.class.php
index fc13b3a..7afa9b4 100644
--- a/Notifications/Notifications.class.php
+++ b/Notifications/Notifications.class.php
@@ -376,8 +376,25 @@
public function onBSShoutBoxAfterInsertShout( $iArticleId, $iUserId,
$sNick, $sMessage, $sTimestamp ) {
wfProfileIn( 'BS::'.__METHOD__ );
global $wgUser; // TODO SW: use user id
- if ( $wgUser->isAllowed( 'bot' ) ) return true;
+ if ( $wgUser->isAllowed( 'bot' ) ) {
+ return true;
+ }
+ #check if users are mentioned in post
+ $oShoutbox = BsExtensionManager::getExtension( "ShoutBox" );
+ $aUsers = $oShoutbox::getUsersMentioned( $sMessage );
+ $bNotify = false;
+ #if there is any user in the post mentioned that is not the
poster himself
+ #trigger the watched article notification
+ foreach ( $aUsers as $oUser ) {
+ if ( $oUser->getId() !== $iUserId ) {
+ $bNotify = true;
+ break;
+ }
+ }
+ if ( $bNotify === false ) {
+ return true;
+ }
EchoEvent::create( array(
'type' => 'bs-shoutbox',
'title' => Title::newFromID( $iArticleId ),
diff --git a/ShoutBox/ShoutBox.class.php b/ShoutBox/ShoutBox.class.php
index b3c5489..663d6b6 100644
--- a/ShoutBox/ShoutBox.class.php
+++ b/ShoutBox/ShoutBox.class.php
@@ -540,6 +540,10 @@
if ( class_exists( 'EchoEvent' ) ) {
$oCurrentUser = RequestContext::getMain()->getUser();
foreach ( $aUsers as $oUser ) {
+ #if you're mentioning yourself don't send
notification
+ if ( $oUser->getId() === $iUserId ) {
+ continue;
+ }
EchoEvent::create( array(
'type' => 'bs-shoutbox-' . $sAction,
'title' => Article::newFromID(
$iArticleId )->getTitle(),
--
To view, visit https://gerrit.wikimedia.org/r/218302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fa9933e6cf3f8ba7fb0e9ba9e47a2e1589d561d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_23
Gerrit-Owner: Tweichart <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits