Skip to content

Commit

Permalink
- Added three new configuration options $wgDiscordShowNewUserEmail, $…
Browse files Browse the repository at this point in the history
…wgDiscordShowNewUserFullName and $wgDiscordShowNewUserIP for disabling certain information sent for new user.

- Updated README file to reflect these additions.
  • Loading branch information
kulttuuri committed Dec 6, 2016
1 parent 171ac32 commit 6e4a576
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
18 changes: 13 additions & 5 deletions DiscordNotifications/DiscordNotificationsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions DiscordNotifications/extension.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -72,7 +72,10 @@
"DiscordNotificationMovedArticle": true,
"DiscordNotificationEditedArticle": true,
"DiscordNotificationFileUpload": true,
"DiscordIncludeDiffSize": true
"DiscordIncludeDiffSize": true,
"DiscordShowNewUserEmail": true,
"DiscordShowNewUserFullName": true,
"DiscordShowNewUserIP": true
},
"manifest_version": 1
}
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit 6e4a576

Please sign in to comment.