diff --git a/DiscordNotifications/DiscordNotificationsCore.php b/DiscordNotifications/DiscordNotificationsCore.php index a2e9ec0..9dd9a72 100644 --- a/DiscordNotifications/DiscordNotificationsCore.php +++ b/DiscordNotifications/DiscordNotificationsCore.php @@ -209,7 +209,7 @@ static function discord_article_moved($title, $newtitle, $user, $oldid, $newid, */ static function discord_new_user_account($user, $byEmail) { - global $wgDiscordNotificationNewUser; + global $wgDiscordNotificationNewUser, $wgDiscordShowNewUserEmail, $wgDiscordShowNewUserFullName, $wgDiscordShowNewUserIP; if (!$wgDiscordNotificationNewUser) return; $email = ""; @@ -219,12 +219,20 @@ static function discord_new_user_account($user, $byEmail) try { $realname = $user->getRealName(); } catch (Exception $e) {} try { $ipaddress = $user->getRequest()->getIP(); } catch (Exception $e) {} + $messageExtra = ""; + if ($wgDiscordShowNewUserEmail || $wgDiscordShowNewUserFullName || $wgDiscordShowNewUserIP) { + $messageExtra = "("; + if ($wgDiscordShowNewUserEmail) $messageExtra .= $email . ", "; + if ($wgDiscordShowNewUserFullName) $messageExtra .= $realname . ", "; + if ($wgDiscordShowNewUserIP) $messageExtra .= $ipaddress . ", "; + $messageExtra = substr($messageExtra, 0, -2); // Remove trailing , + $messageExtra .= ")"; + } + $message = sprintf( - "New user account %s was just created (email: %s, real name: %s, IP: %s)", + "New user account %s was just created %s", self::getDiscordUserText($user), - $email, - $realname, - $ipaddress); + $messageExtra); self::push_discord_notify($message, $user); return true; } diff --git a/DiscordNotifications/extension.json b/DiscordNotifications/extension.json index 71f9806..23c6700 100644 --- a/DiscordNotifications/extension.json +++ b/DiscordNotifications/extension.json @@ -1,6 +1,6 @@ { "name": "Discord Notifications", - "version": "1.0", + "version": "1.0.1", "author": "Aleksi Postari", "url": "https://github.com/kulttuuri/discord_mediawiki", "description": "Sends Discord notifications for selected actions that have occurred in your MediaWiki sites.", @@ -72,7 +72,10 @@ "DiscordNotificationMovedArticle": true, "DiscordNotificationEditedArticle": true, "DiscordNotificationFileUpload": true, - "DiscordIncludeDiffSize": true + "DiscordIncludeDiffSize": true, + "DiscordShowNewUserEmail": true, + "DiscordShowNewUserFullName": true, + "DiscordShowNewUserIP": true }, "manifest_version": 1 } diff --git a/README.md b/README.md index 8a78bbb..f5ddd95 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ $wgDiscordSendMethod = "curl"; ## Additional options -These options can be set after including your plugin in your localSettings.php file. +These options can be set after including your plugin in your `localSettings.php` file. ### Remove additional links from user and article pages @@ -65,6 +65,19 @@ $wgDiscordIncludeUserUrls = true; $wgDiscordIgnoreMinorEdits = false; ``` +### Disable new user extra information + +By default we show full name, email and IP address of newly created user in the notification. You can individually disable each of these using the settings below. This is helpful for example in situation where you do not want to expose this information for users in your Discord channel. + +```php +// If this is true, newly created user email address is added to notification. +$wgDiscordShowNewUserEmail = true; +// If this is true, newly created user full name is added to notification. +$wgDiscordShowNewUserFullName = true; +// If this is true, newly created user IP address is added to notification. +$wgDiscordShowNewUserIP = true; +``` + ### Show edit size By default we show size of the edit. You can hide this information with the setting below.