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
diff options
context:
space:
mode:
authorsualko <klaus@jsxc.org>2021-05-28 19:33:04 +0300
committersualko <klaus@jsxc.org>2021-05-28 19:33:04 +0300
commitd5f5ec7187a5ba47511421e13fe0ab54f712b5d6 (patch)
tree00013367fc3016749edc2a6b83bbd55c718ce8dc
parente35670038f5985aa3155fb97a29d4d7cfee60583 (diff)
fix: multiple DI issues
-rw-r--r--lib/AppInfo/Application.php95
-rw-r--r--lib/DbLock.php8
2 files changed, 27 insertions, 76 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 64c09d4..10358b1 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -30,6 +30,7 @@ use OCA\OJSXC\Hooks;
use OCA\OJSXC\UserManagerUserProvider;
use OCA\OJSXC\ContactsStoreUserProvider;
use OCA\OJSXC\Config;
+use OCA\OJSXC\IUserProvider;
use OCP\IContainer;
use OCP\IRequest;
use OCP\IUserBackend;
@@ -73,40 +74,17 @@ class Application extends App
$c->query('AppName'),
$c->query('Request'),
$c->query('UserId'),
- $c->query('StanzaMapper'),
- $c->query('IQHandler'),
- $c->query('MessageHandler'),
- $c->query('Host'),
+ $c->query(StanzaMapper::class),
+ $c->query(IQ::class),
+ $c->query(Message::class),
$this->getLock(),
- $c->query(\OCP\ILogger::class),
- $c->query('PresenceHandler'),
- $c->query('PresenceMapper'),
+ $c->query(Presence::class),
+ $c->query(PresenceMapper::class),
file_get_contents("php://input"),
self::$config['polling']['sleep_time'],
self::$config['polling']['max_cycles'],
- $c->query('NewContentContainer'),
- $c->query('StanzaLogger')
- );
- });
-
- $container->registerService('SettingsController', function (IContainer $c) {
- return new SettingsController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('Config'),
- $c->query(\OCP\IUserManager::class),
- \OC::$server->getUserSession()
- );
- });
-
- $container->registerService('ExternalApiController', function (IContainer $c) {
- return new ExternalApiController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query(\OCP\IUserManager::class),
- $c->query(\OCP\IUserSession::class),
- $c->query(\OCP\IGroupManager::class),
- $c->query(\OCP\ILogger::class)
+ $c->query(NewContentContainer::class),
+ $c->query(StanzaLogger::class)
);
});
@@ -115,7 +93,7 @@ class Application extends App
$c->query('AppName'),
$c->query('Request'),
$c->query(\OCP\IURLGenerator::class),
- $c->query('Config'),
+ $c->query(Config::class),
$c->query(\OCP\IUserSession::class),
$c->query(\OCP\ILogger::class),
$c->query('DataRetriever'),
@@ -125,14 +103,6 @@ class Application extends App
);
});
- $container->registerService('JavascriptController', function (IContainer $c) {
- return new JavascriptController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('Config')
- );
- });
-
/**
* Middleware
*/
@@ -149,39 +119,39 @@ class Application extends App
/**
* Database Layer
*/
- $container->registerService('MessageMapper', function (IContainer $c) use ($container) {
+ $container->registerService(MessageMapper::class, function (IContainer $c) use ($container) {
return new MessageMapper(
$container->getServer()->getDatabaseConnection(),
$c->query('Host'),
- $c->query('StanzaLogger')
+ $c->query(StanzaLogger::class)
);
});
- $container->registerService('IQRosterPushMapper', function (IContainer $c) use ($container) {
+ $container->registerService(IQRosterPushMapper::class, function (IContainer $c) use ($container) {
return new IQRosterPushMapper(
$container->getServer()->getDatabaseConnection(),
$c->query('Host'),
- $c->query('StanzaLogger')
+ $c->query(StanzaLogger::class)
);
});
- $container->registerService('StanzaMapper', function (IContainer $c) use ($container) {
+ $container->registerService(StanzaMapper::class, function (IContainer $c) use ($container) {
return new StanzaMapper(
$container->getServer()->getDatabaseConnection(),
$c->query('Host'),
- $c->query('StanzaLogger')
+ $c->query(StanzaLogger::class)
);
});
- $container->registerService('PresenceMapper', function (IContainer $c) use ($container) {
+ $container->registerService(PresenceMapper::class, function (IContainer $c) use ($container) {
return new PresenceMapper(
$container->getServer()->getDatabaseConnection(),
$c->query('Host'),
$c->query('UserId'),
- $c->query('MessageMapper'),
- $c->query('NewContentContainer'),
+ $c->query(MessageMapper::class),
+ $c->query(NewContentContainer::class),
self::$config['polling']['timeout'],
- $c->query('UserProvider')
+ $c->query(IUserProvider::class)
);
});
@@ -189,13 +159,13 @@ class Application extends App
/**
* XMPP Stanza Handlers
*/
- $container->registerService('IQHandler', function (IContainer $c) {
+ $container->registerService(IQ::class, function (IContainer $c) {
return new IQ(
$c->query('UserId'),
$c->query('Host'),
$c->query(\OCP\IUserManager::class),
$c->query(\OCP\IConfig::class),
- $c->query('UserProvider')
+ $c->query(IUserProvider::class)
);
});
@@ -211,25 +181,8 @@ class Application extends App
/**
* Helpers
*/
- $container->registerService('Config', function (IContainer $c) {
- return new Config(
- $c->query('AppName'),
- $c->query(\OCP\IConfig::class)
- );
- });
-
- $container->registerService('NewContentContainer', function () {
- return new NewContentContainer();
- });
-
- $container->registerService('StanzaLogger', function (IContainer $c) {
- return new StanzaLogger(
- $c->query('\OCP\ILogger'),
- $c->query('UserId')
- );
- });
- $container->registerService('UserProvider', function (IContainer $c) {
+ $container->registerService(IUserProvider::class, function (IContainer $c) {
if (self::contactsStoreApiSupported()) {
return new ContactsStoreUserProvider(
$c->query(\OCP\Contacts\ContactsMenu\IContactsStore::class),
@@ -252,8 +205,8 @@ class Application extends App
$container->registerService('RefreshRosterCommand', function ($c) {
return new RefreshRoster(
$c->query('ServerContainer')->getUserManager(),
- $c->query('RosterPush'),
- $c->query('PresenceMapper')
+ $c->query(RosterPush::class),
+ $c->query(PresenceMapper::class)
);
});
diff --git a/lib/DbLock.php b/lib/DbLock.php
index 791c8ed..45a511c 100644
--- a/lib/DbLock.php
+++ b/lib/DbLock.php
@@ -54,10 +54,8 @@ class DbLock implements ILock
*/
public function stillLocked()
{
- $sql = "SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid`='ojsxc' AND `configkey`='longpolling'";
- $q = $this->con->prepare($sql);
- $q->execute([$this->userId]);
- $r = $q->fetch();
- return $r['configvalue'] === $this->pollingId;
+ $storedPollingId = $this->config->getUserValue($this->userId, 'ojsxc', 'longpolling');
+
+ return $storedPollingId === $this->pollingId;
}
}