Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/build/lib
diff options
context:
space:
mode:
Diffstat (limited to 'build/lib')
-rw-r--r--build/lib/Controller/SettingsController.php4
-rw-r--r--build/lib/Settings/Personal.php6
-rw-r--r--build/lib/command/serversharing.php76
-rw-r--r--build/lib/db/stanza.php25
-rw-r--r--build/lib/db/stanzamapper.php2
-rw-r--r--build/lib/hooks.php1
-rw-r--r--build/lib/stanzahandlers/message.php3
7 files changed, 104 insertions, 13 deletions
diff --git a/build/lib/Controller/SettingsController.php b/build/lib/Controller/SettingsController.php
index dc67a32..47fe9dd 100644
--- a/build/lib/Controller/SettingsController.php
+++ b/build/lib/Controller/SettingsController.php
@@ -301,6 +301,10 @@ class SettingsController extends Controller
if (is_array($options)) {
foreach ($options as $prop => $value) {
+ if (!is_array($value) && !is_object($value)) {
+ continue;
+ }
+
if ($prop !== 'xmpp' || $data ['xmpp'] ['overwrite']) {
foreach ($value as $key => $v) {
if ($v !== '' && $key !== 'url') {
diff --git a/build/lib/Settings/Personal.php b/build/lib/Settings/Personal.php
index 4485b4f..2855bfc 100644
--- a/build/lib/Settings/Personal.php
+++ b/build/lib/Settings/Personal.php
@@ -35,7 +35,7 @@ class Personal implements ISettings
if (is_array($options)) {
$loginFormEnable = null;
- if (is_array($options['loginForm']) && isset($options['loginForm']['enable'])) {
+ if (isset($options['loginForm']) && is_array($options['loginForm']) && isset($options['loginForm']['enable'])) {
$loginFormEnable = $options['loginForm']['enable'];
}
@@ -47,7 +47,7 @@ class Personal implements ISettings
$parameters['loginForm'] = 'default';
}
- if (is_array($options['xmpp'])) {
+ if (isset($options['xmpp']) && is_array($options['xmpp'])) {
if (!empty($options['xmpp']['username'])) {
$node = $options['xmpp']['username'];
$parameters['xmppUsername'] = $options['xmpp']['username'];
@@ -68,7 +68,7 @@ class Personal implements ISettings
$xmppOverwrite = $this->config->getAppValue('ojsxc', 'xmppOverwrite');
$parameters['xmppUrl'] = $this->config->getAppValue('ojsxc', 'boshUrl');
- $parameters['externalConnectable'] = Application::getServerType() !== Application.INTERNAL;
+ $parameters['externalConnectable'] = Application::getServerType() !== Application::INTERNAL;
$parameters['allowToOverwriteXMPPConfig'] = $xmppOverwrite === 'true';
$parameters['jid'] = $node . '@' . $domain;
diff --git a/build/lib/command/serversharing.php b/build/lib/command/serversharing.php
new file mode 100644
index 0000000..eb6189b
--- /dev/null
+++ b/build/lib/command/serversharing.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace OCA\OJSXC\Command;
+
+use OCA\OJSXC\AppInfo\Application;
+use OCP\IConfig;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class serversharing extends Command
+{
+
+ /**
+ * @var IConfig
+ */
+ private $config;
+
+ public function __construct(
+ IConfig $config
+ ) {
+ parent::__construct();
+ $this->config = $config;
+ }
+
+ protected function configure()
+ {
+ $this->setName('ojsxc:server_sharing');
+ $this->setDescription('Use the Server Sharing settings https://github.com/jsxc/jsxc/wiki/Restrict-chatting-(Nextcloud-internal)');
+ $this->addOption('enable');
+ $this->addOption('disable');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ if (\OCP\Util::getVersion()[0] < 13) {
+ $output->write('This feature is only supported in Nextcloud 13 or later.', true);
+ return;
+ }
+
+ if (Application::getServerType() !== 'internal') {
+ $output->write('This feature is only supported using the internal backend.', true);
+ return;
+ }
+
+ $enable = $input->getOption('enable');
+ $disable = $input->getOption('disable');
+
+ if (!$enable && !$disable) {
+ if ($this->config->getAppValue('ojsxc', 'use_server_sharing_settings', 'no') === 'yes') {
+ $state = 'enabled';
+ } else {
+ $state = 'disabled';
+ }
+ $output->write('This feature is currently ' . $state, true);
+ return;
+ }
+
+ if ($enable === $disable) {
+ // if both enable and disable passed or none option
+ $output->write('Please provide only --enable or --disable', true);
+ return;
+ }
+
+
+ if ($enable) {
+ $this->config->setAppValue('ojsxc', 'use_server_sharing_settings', 'yes');
+ $output->write('Successfully enabled.', true);
+ }
+
+ if ($disable) {
+ $this->config->setAppValue('ojsxc', 'use_server_sharing_settings', 'no');
+ $output->write('Successfully disabled.', true);
+ }
+ }
+}
diff --git a/build/lib/db/stanza.php b/build/lib/db/stanza.php
index 6ef2f8e..76d586c 100644
--- a/build/lib/db/stanza.php
+++ b/build/lib/db/stanza.php
@@ -25,23 +25,33 @@ class Stanza extends Entity implements XmlSerializable
}
/**
- * @var string $to
+ * @var string $to The sanitized userId of the recipient of this stanza.
*/
public $to;
/**
- * @var string $to
+ * @var string $from The sanitized userId of the sender of this stanza.
*/
public $from;
/**
+ * @var string $to The userId (as stored in NC) of the recipient of this stanza.
+ */
+ public $unSanitizedTo;
+
+ /**
+ * @var string $from The userId (as stored in NC) of the sender of this stanza.
+ */
+ public $unSanitizedFrom;
+
+ /**
* @var string $stanza
*/
public $stanza;
- public function getTo()
+ public function getUnSanitizedTo()
{
- return $this->to;
+ return $this->unSanitizedTo;
}
/**
@@ -59,6 +69,7 @@ class Stanza extends Entity implements XmlSerializable
$userId = $userId[0];
}
+ $this->unSanitizedTo = $userId;
$this->to = Application::sanitizeUserId($userId);
if (!is_null($host_and_or_resource)) {
$this->to .= '@' . $host_and_or_resource;
@@ -79,15 +90,17 @@ class Stanza extends Entity implements XmlSerializable
$host_and_or_resource = $userId[1];
$userId = $userId[0];
}
+
+ $this->unSanitizedFrom = $userId;
$this->from = Application::sanitizeUserId($userId);
if (!is_null($host_and_or_resource)) {
$this->from .= '@' . $host_and_or_resource;
}
}
- public function getFrom()
+ public function getUnSanitizedFrom()
{
- return $this->from;
+ return $this->unSanitizedFrom;
}
public function xmlSerialize(Writer $writer)
diff --git a/build/lib/db/stanzamapper.php b/build/lib/db/stanzamapper.php
index f84a020..28b56f8 100644
--- a/build/lib/db/stanzamapper.php
+++ b/build/lib/db/stanzamapper.php
@@ -52,7 +52,7 @@ class StanzaMapper extends Mapper
$sql = "INSERT INTO `*PREFIX*ojsxc_stanzas` (`to`, `from`, `stanza`) VALUES(?,?,?)";
$q = $this->db->prepare($sql);
- $q->execute([$entity->getTo(), $entity->getFrom(), $xml]);
+ $q->execute([$entity->getUnSanitizedTo(), $entity->getUnSanitizedFrom(), $xml]);
}
diff --git a/build/lib/hooks.php b/build/lib/hooks.php
index 1b7db59..9e875c7 100644
--- a/build/lib/hooks.php
+++ b/build/lib/hooks.php
@@ -2,7 +2,6 @@
namespace OCA\OJSXC;
-use function foo\func;
use OCA\OJSXC\AppInfo\Application;
use OCA\OJSXC\Db\PresenceMapper;
use OCA\OJSXC\Db\StanzaMapper;
diff --git a/build/lib/stanzahandlers/message.php b/build/lib/stanzahandlers/message.php
index dac030f..42d41c9 100644
--- a/build/lib/stanzahandlers/message.php
+++ b/build/lib/stanzahandlers/message.php
@@ -67,11 +67,10 @@ class Message extends StanzaHandler
*/
public function handle(array $stanza)
{
+ // Parse the username from the XML stanza to a NC userid
$to = $this->getAttribute($stanza, 'to');
$pos = strrpos($to, '@');
-
$this->to = substr($to, 0, $pos);
-
$this->to = Application::convertToRealUID(Application::deSanitize($this->to));
if (!$this->userProvider->hasUserByUID($this->to)) {