1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge pull request #6802 from marc1706/ticket/17493

[ticket/17493] Drop support for jabber
This commit is contained in:
Marc Alexander
2025-04-24 19:47:48 +02:00
committed by GitHub
85 changed files with 359 additions and 3050 deletions

View File

@@ -16,7 +16,7 @@ namespace phpbb\cron\task\core;
use phpbb\config\config;
/**
* Queue cron task. Sends email and jabber messages queued by other scripts.
* Queue cron task. Sends email queued by other scripts.
*/
class queue extends \phpbb\cron\task\base
{

View File

@@ -13,10 +13,12 @@
namespace phpbb\db\migration\data\v310;
use phpbb\messenger\method\messenger_interface;
class notification_options_reconvert extends \phpbb\db\migration\migration
{
protected const NOTIFY_EMAIL = 0;
protected const NOTIFY_IM = 1;
protected const NOTIFY_BOTH = 2;
public static function depends_on()
{
return array('\phpbb\db\migration\data\v310\notifications_schema_fix');
@@ -69,12 +71,12 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
// In-board notification
$notification_methods[] = '';
if ($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
if ($row['user_notify_type'] == self::NOTIFY_EMAIL || $row['user_notify_type'] == self::NOTIFY_BOTH)
{
$notification_methods[] = 'email';
}
if ($row['user_notify_type'] == messenger_interface::NOTIFY_IM || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
if ($row['user_notify_type'] == self::NOTIFY_IM || $row['user_notify_type'] == self::NOTIFY_BOTH)
{
$notification_methods[] = 'jabber';
}

View File

@@ -0,0 +1,115 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v400;
use phpbb\db\migration\migration;
class remove_jabber extends migration
{
public static function depends_on(): array
{
return [
'\phpbb\db\migration\data\v310\notifications_use_full_name',
'\phpbb\db\migration\data\v31x\add_jabber_ssl_context_config_options',
'\phpbb\db\migration\data\v400\dev',
'\phpbb\db\migration\data\v400\add_webpush',
];
}
public function update_schema(): array
{
return [
'drop_columns' => [
$this->table_prefix . 'users' => [
'user_jabber',
],
]
];
}
public function revert_schema(): array
{
return [
'add_columns' => [
$this->table_prefix . 'users' => [
'user_jabber' => ['VCHAR_UNI', ''],
],
]
];
}
public function update_data(): array
{
return [
['config.remove', ['jab_enable']],
['config.remove', ['jab_host']],
['config.remove', ['jab_package_size']],
['config.remove', ['jab_password']],
['config.remove', ['jab_port']],
['config.remove', ['jab_use_ssl']],
['config.remove', ['jab_username']],
['config.remove', ['jab_verify_peer']],
['config.remove', ['jab_verify_peer_name']],
['config.remove', ['jab_allow_self_signed']],
['module.remove', [
'acp',
'ACP_CLIENT_COMMUNICATION',
'ACP_JABBER_SETTINGS',
]],
['permission.remove', ['a_jabber']],
['permission.remove', ['u_sendim']],
['custom', [[$this, 'move_jabber_to_email_notifications']]],
];
}
public function revert_data(): array
{
return [
['config.add', ['jab_enable', 0]],
['config.add', ['jab_host', '']],
['config.add', ['jab_package_size', 20]],
['config.add', ['jab_password', '']],
['config.add', ['jab_port', 5222]],
['config.add', ['jab_use_ssl', 0]],
['config.add', ['jab_username', '']],
['config.add', ['jab_verify_peer', 1]],
['config.add', ['jab_verify_peer_name', 1]],
['config.add', ['jab_allow_self_signed', 0]],
['module.add', [
'acp',
'ACP_CLIENT_COMMUNICATION',
[
'module_basename' => 'acp_jabber',
'module_langname' => 'ACP_JABBER_SETTINGS',
'module_mode' => 'settings',
'module_auth' => 'acl_a_jabber',
],
]],
['permission.add', ['a_jabber', true]],
['permission.add', ['u_sendim', true]],
];
}
public function move_jabber_to_email_notifications(?int $start)
{
$limit = 1000;
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . "
WHERE method = 'notification.method.jabber'";
$this->db->sql_query_limit($sql, $limit, $start ?: 0);
return $this->db->sql_affectedrows() < $limit ? true : $start + $limit;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v400;
use phpbb\db\migration\migration;
class remove_notify_type extends migration
{
public static function depends_on(): array
{
return [
'\phpbb\db\migration\data\v400\remove_jabber',
'\phpbb\db\migration\data\v400\dev',
'\phpbb\db\migration\data\v30x\release_3_0_0',
];
}
public function update_schema(): array
{
return [
'drop_columns' => [
$this->table_prefix . 'users' => [
'user_notify_type',
],
]
];
}
public function revert_schema(): array
{
return [
'add_columns' => [
$this->table_prefix . 'users' => [
'user_notify_type' => ['TINT:4', 0],
],
]
];
}
}

View File

@@ -13,8 +13,6 @@
namespace phpbb\message;
use phpbb\messenger\method\messenger_interface;
/**
* Class admin_form
* Displays a message to the user and allows him to send an email
@@ -157,7 +155,6 @@ class admin_form extends form
}
$this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name);
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
}
$this->message->set_template('contact_admin');
@@ -166,8 +163,7 @@ class admin_form extends form
$this->message->add_recipient(
$this->user->lang['ADMINISTRATOR'],
$this->config['board_contact'],
$this->config['default_lang'],
messenger_interface::NOTIFY_EMAIL
$this->config['default_lang']
);
$this->message->set_template_vars(array(

View File

@@ -26,29 +26,33 @@ class message
/** @var string */
protected $subject = '';
/** @var string */
protected $body = '';
/** @var string */
protected $template = '';
/** @var array */
protected $template_vars = array();
/** @var string */
protected $sender_ip = '';
/** @var string */
protected $sender_name = '';
/** @var string */
protected $sender_address = '';
/** @var string */
protected $sender_lang = '';
/** @var string|int */
protected $sender_id = '';
/** @var string */
protected $sender_username = '';
/** @var string */
protected $sender_jabber = '';
/** @var int */
protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL;
/** @var array */
protected $recipients;
@@ -119,9 +123,7 @@ class message
$user['username'],
$user['user_email'],
$user['user_lang'],
$user['user_notify_type'],
$user['username'],
$user['user_jabber']
$user['username']
);
}
@@ -131,20 +133,16 @@ class message
* @param string $recipient_name Displayed sender name
* @param string $recipient_address Email address
* @param string $recipient_lang
* @param int $recipient_notify_type Used notification methods (Jabber, Email, ...)
* @param string $recipient_username User Name (used for AntiAbuse header)
* @param string $recipient_jabber
* @return void
*/
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_username = '')
{
$this->recipients[] = array(
'name' => $recipient_name,
'user_email' => $recipient_address,
'lang' => $recipient_lang,
'username' => $recipient_username,
'user_jabber' => $recipient_jabber,
'notify_type' => $recipient_notify_type,
'to_name' => $recipient_name,
);
}
@@ -163,11 +161,8 @@ class message
$user->data['user_email'],
$user->lang_name,
$user->data['user_id'],
$user->data['username'],
$user->data['user_jabber']
$user->data['username']
);
$this->set_sender_notify_type($user->data['user_notify_type']);
}
/**
@@ -179,10 +174,9 @@ class message
* @param string $sender_lang
* @param int $sender_id User ID
* @param string $sender_username User Name (used for AntiAbuse header)
* @param string $sender_jabber
* @return void
*/
public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '')
public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '')
{
$this->sender_ip = $sender_ip;
$this->sender_name = $sender_name;
@@ -190,18 +184,6 @@ class message
$this->sender_lang = $sender_lang;
$this->sender_id = $sender_id;
$this->sender_username = $sender_username;
$this->sender_jabber = $sender_jabber;
}
/**
* Which notification type should be used? Jabber, Email, ...?
*
* @param int $sender_notify_type
* @return void
*/
public function set_sender_notify_type($sender_notify_type)
{
$this->sender_notify_type = $sender_notify_type;
}
/**
@@ -225,8 +207,6 @@ class message
'user_email' => $this->sender_address,
'name' => $this->sender_name,
'username' => $this->sender_username,
'user_jabber' => $this->sender_jabber,
'notify_type' => $this->sender_notify_type,
'to_name' => $this->recipients[0]['to_name'],
);
}
@@ -257,40 +237,37 @@ class message
foreach ($messenger_collection_iterator as $messenger_method)
{
$messenger_method->set_use_queue(false);
if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == $messenger_method::NOTIFY_BOTH)
$messenger_method->template($this->template, $recipient['lang']);
$messenger_method->set_addresses($recipient);
$messenger_method->reply_to($this->sender_address);
$messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name);
$messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
if ($this->sender_id)
{
$messenger_method->template($this->template, $recipient['lang']);
$messenger_method->set_addresses($recipient);
$messenger_method->reply_to($this->sender_address);
$messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name);
$messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
if ($this->sender_id)
{
$messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id);
}
if ($this->sender_username)
{
$messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username);
}
$messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT));
$messenger_method->assign_vars([
'BOARD_CONTACT' => $contact,
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT),
]);
if (count($this->template_vars))
{
$messenger_method->assign_vars($this->template_vars);
}
$messenger_method->send();
$messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id);
}
if ($this->sender_username)
{
$messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username);
}
$messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT));
$messenger_method->assign_vars([
'BOARD_CONTACT' => $contact,
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT),
]);
if (count($this->template_vars))
{
$messenger_method->assign_vars($this->template_vars);
}
$messenger_method->send();
}
}
}

View File

@@ -13,8 +13,6 @@
namespace phpbb\message;
use phpbb\messenger\method\messenger_interface;
/**
* Class topic_form
* Form used to send topics as notification emails
@@ -131,10 +129,8 @@ class topic_form extends form
$this->message->add_recipient(
$this->recipient_name,
$this->recipient_address,
$this->recipient_lang,
messenger_interface::NOTIFY_EMAIL
$this->recipient_lang
);
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
parent::submit($messenger);
}

View File

@@ -34,7 +34,7 @@ class user_form extends form
*/
protected function get_user_row($user_id)
{
$sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
$sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $user_id . '
AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';

View File

@@ -141,11 +141,6 @@ abstract class base implements messenger_interface
$this->set_use_queue();
}
/**
* {@inheritdoc}
*/
abstract public function get_id(): int;
/**
* {@inheritdoc}
*/

View File

@@ -74,14 +74,6 @@ class email extends base
/** @var AbstractTransport */
protected AbstractTransport $transport;
/**
* {@inheritDoc}
*/
public function get_id(): int
{
return self::NOTIFY_EMAIL;
}
/**
* {@inheritDoc}
*/

File diff suppressed because it is too large Load Diff

View File

@@ -18,22 +18,6 @@ namespace phpbb\messenger\method;
*/
interface messenger_interface
{
/** @var int Email notify method used */
public const NOTIFY_EMAIL = 0;
/** @var int Instant messaging (Jabber) notify method used */
public const NOTIFY_IM = 1;
/** @var int Both notify methods used */
public const NOTIFY_BOTH = 2;
/**
* Get messenger method id
*
* @return int
*/
public function get_id(): int;
/**
* Check if the messenger method is enabled
*

View File

@@ -64,7 +64,7 @@ class queue
/**
* Init a queue object
*
* @param string $object Queue object type: email/jabber/etc
* @param string $object Queue object type: email/etc
* @param int $package_size Size of the messenger package to send
* @return void
*/
@@ -78,7 +78,7 @@ class queue
/**
* Put message into the messenger file queue
*
* @param string $object Queue object type: email/jabber/etc
* @param string $object Queue object type: email/etc
* @param array $message_data Message data to send
* @return void
*/

View File

@@ -708,7 +708,7 @@ class manager
*
* @param string $item_type Type identifier of the subscription
* @param int $item_id The id of the item
* @param string $method The method of the notification e.g. 'board', 'email', or 'jabber'
* @param string $method The method of the notification e.g. 'board', 'email'
* (if null a subscription will be added for all the defaults methods)
* @param bool|int $user_id The user_id to add the subscription for (bool false for current user)
*/
@@ -765,7 +765,7 @@ class manager
*
* @param string $item_type Type identifier of the subscription
* @param int $item_id The id of the item
* @param string $method The method of the notification e.g. 'board', 'email', or 'jabber'
* @param string $method The method of the notification e.g. 'board', 'email'
* @param bool|int $user_id The user_id to add the subscription for (bool false for current user)
*/
public function delete_subscription($item_type, $item_id = 0, $method = null, $user_id = false)

View File

@@ -19,14 +19,13 @@ use phpbb\user_loader;
use phpbb\config\config;
use phpbb\db\driver\driver_interface;
use phpbb\di\service_collection;
use phpbb\messenger\method\messenger_interface;
/**
* Email notification method class
* This class handles sending emails for notifications
*/
class email extends \phpbb\notification\method\messenger_base
class email extends messenger_base
{
/** @var user */
protected $user;
@@ -136,7 +135,7 @@ class email extends \phpbb\notification\method\messenger_base
$insert_buffer->flush();
$this->notify_using_messenger(messenger_interface::NOTIFY_EMAIL);
$this->notify_using_messenger('messenger.method.email');
}
/**

View File

@@ -1,104 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\notification\method;
use phpbb\notification\type\type_interface;
use phpbb\user;
use phpbb\user_loader;
use phpbb\config\config;
use phpbb\di\service_collection;
use phpbb\messenger\method\messenger_interface;
/**
* Jabber notification method class
* This class handles sending Jabber messages for notifications
*/
class jabber extends \phpbb\notification\method\messenger_base
{
/** @var user */
protected $user;
/** @var config */
protected $config;
/** @var service_collection */
protected $messenger;
/**
* Notification Method jabber Constructor
*
* @param user_loader $user_loader
* @param user $user
* @param config $config
* @param string $phpbb_root_path
* @param string $php_ext
* @param service_collection $messenger
*/
public function __construct(user_loader $user_loader, user $user, config $config, $phpbb_root_path, $php_ext, service_collection $messenger)
{
parent::__construct($messenger, $user_loader, $phpbb_root_path, $php_ext);
$this->user = $user;
$this->config = $config;
}
/**
* Get notification method name
*
* @return string
*/
public function get_type()
{
return 'notification.method.jabber';
}
/**
* Is this method available for the user?
* This is checked on the notifications options
*
* @param type_interface|null $notification_type An optional instance of a notification type. If provided, this
* method additionally checks if the type provides an email template.
* @return bool
*/
public function is_available(type_interface $notification_type = null)
{
return parent::is_available($notification_type) && $this->global_available() && !empty($this->user->data['user_jabber']);
}
/**
* Is this method available at all?
* This is checked before notifications are sent
*/
public function global_available()
{
return !(
empty($this->config['jab_enable']) ||
empty($this->config['jab_host']) ||
empty($this->config['jab_username']) ||
empty($this->config['jab_password']) ||
!@extension_loaded('xml')
);
}
public function notify()
{
if (!$this->global_available())
{
return;
}
$this->notify_using_messenger(messenger_interface::NOTIFY_IM, 'short/');
}
}

View File

@@ -18,7 +18,7 @@ use phpbb\di\service_collection;
use phpbb\user_loader;
/**
* Abstract notification method handling email and jabber notifications
* Abstract notification method handling messenger notifications
* using the phpBB messenger.
*/
abstract class messenger_base extends \phpbb\notification\method\base
@@ -67,12 +67,12 @@ abstract class messenger_base extends \phpbb\notification\method\base
/**
* Notify using phpBB messenger
*
* @param int $notify_method Notify method for messenger (e.g. \phpbb\messenger\method\messenger_interface::NOTIFY_IM)
* @param string $notify_method Notify method service for messenger (e.g. 'messenger.method.email'), empty string for all available methods
* @param string $template_dir_prefix Base directory to prepend to the email template name
*
* @return void
*/
protected function notify_using_messenger($notify_method, $template_dir_prefix = '')
protected function notify_using_messenger(string $notify_method, string $template_dir_prefix = ''): void
{
if (empty($this->queue))
{
@@ -120,7 +120,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
*/
foreach ($messenger_collection_iterator as $messenger_method)
{
if ($messenger_method->get_id() == $notify_method || $notify_method == $messenger_method::NOTIFY_BOTH)
if (empty($notify_method) || $messenger_collection_iterator->key() == $notify_method)
{
$messenger_method->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
$messenger_method->set_addresses($user);

View File

@@ -327,10 +327,7 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
/**
* URL to unsubscribe to this notification (fall back)
*
* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
* @return false
* {@inheritDoc}
*/
public function get_unsubscribe_url($method = false)
{

View File

@@ -132,7 +132,7 @@ interface type_interface
/**
* URL to unsubscribe to this notification
*
* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
* @param string|bool $method Method name to unsubscribe from (email|etc), False to unsubscribe from all notifications for this item
*/
public function get_unsubscribe_url($method);

View File

@@ -253,7 +253,6 @@ class permissions
'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'),
'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'),
'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'),
'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'),
'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'),
'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'),
@@ -317,7 +316,6 @@ class permissions
// Admin Permissions
'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'),
'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'),
'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'),
'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'),
'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'),

View File

@@ -176,7 +176,7 @@ class reset_password
}
$sql_array = [
'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,'
'SELECT' => 'user_id, username, user_permissions, user_email, user_type,'
. ' user_lang, user_inactive_reason, reset_token, reset_token_expiration',
'FROM' => [$this->users_table => 'u'],
'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" .
@@ -308,7 +308,7 @@ class reset_password
add_form_key('ucp_reset_password');
$sql_array = [
'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,'
'SELECT' => 'user_id, username, user_permissions, user_email, user_type,'
. ' user_lang, user_inactive_reason, reset_token, reset_token_expiration',
'FROM' => [$this->users_table => 'u'],
'WHERE' => 'user_id = ' . $user_id,