This commit is contained in:
sualko 2021-05-28 18:33:04 +02:00
Родитель e35670038f
Коммит d5f5ec7187
2 изменённых файлов: 27 добавлений и 76 удалений

Просмотреть файл

@ -30,6 +30,7 @@ use OCA\OJSXC\Hooks;
use OCA\OJSXC\UserManagerUserProvider; use OCA\OJSXC\UserManagerUserProvider;
use OCA\OJSXC\ContactsStoreUserProvider; use OCA\OJSXC\ContactsStoreUserProvider;
use OCA\OJSXC\Config; use OCA\OJSXC\Config;
use OCA\OJSXC\IUserProvider;
use OCP\IContainer; use OCP\IContainer;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserBackend; use OCP\IUserBackend;
@ -73,40 +74,17 @@ class Application extends App
$c->query('AppName'), $c->query('AppName'),
$c->query('Request'), $c->query('Request'),
$c->query('UserId'), $c->query('UserId'),
$c->query('StanzaMapper'), $c->query(StanzaMapper::class),
$c->query('IQHandler'), $c->query(IQ::class),
$c->query('MessageHandler'), $c->query(Message::class),
$c->query('Host'),
$this->getLock(), $this->getLock(),
$c->query(\OCP\ILogger::class), $c->query(Presence::class),
$c->query('PresenceHandler'), $c->query(PresenceMapper::class),
$c->query('PresenceMapper'),
file_get_contents("php://input"), file_get_contents("php://input"),
self::$config['polling']['sleep_time'], self::$config['polling']['sleep_time'],
self::$config['polling']['max_cycles'], self::$config['polling']['max_cycles'],
$c->query('NewContentContainer'), $c->query(NewContentContainer::class),
$c->query('StanzaLogger') $c->query(StanzaLogger::class)
);
});
$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)
); );
}); });
@ -115,7 +93,7 @@ class Application extends App
$c->query('AppName'), $c->query('AppName'),
$c->query('Request'), $c->query('Request'),
$c->query(\OCP\IURLGenerator::class), $c->query(\OCP\IURLGenerator::class),
$c->query('Config'), $c->query(Config::class),
$c->query(\OCP\IUserSession::class), $c->query(\OCP\IUserSession::class),
$c->query(\OCP\ILogger::class), $c->query(\OCP\ILogger::class),
$c->query('DataRetriever'), $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 * Middleware
*/ */
@ -149,39 +119,39 @@ class Application extends App
/** /**
* Database Layer * Database Layer
*/ */
$container->registerService('MessageMapper', function (IContainer $c) use ($container) { $container->registerService(MessageMapper::class, function (IContainer $c) use ($container) {
return new MessageMapper( return new MessageMapper(
$container->getServer()->getDatabaseConnection(), $container->getServer()->getDatabaseConnection(),
$c->query('Host'), $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( return new IQRosterPushMapper(
$container->getServer()->getDatabaseConnection(), $container->getServer()->getDatabaseConnection(),
$c->query('Host'), $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( return new StanzaMapper(
$container->getServer()->getDatabaseConnection(), $container->getServer()->getDatabaseConnection(),
$c->query('Host'), $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( return new PresenceMapper(
$container->getServer()->getDatabaseConnection(), $container->getServer()->getDatabaseConnection(),
$c->query('Host'), $c->query('Host'),
$c->query('UserId'), $c->query('UserId'),
$c->query('MessageMapper'), $c->query(MessageMapper::class),
$c->query('NewContentContainer'), $c->query(NewContentContainer::class),
self::$config['polling']['timeout'], self::$config['polling']['timeout'],
$c->query('UserProvider') $c->query(IUserProvider::class)
); );
}); });
@ -189,13 +159,13 @@ class Application extends App
/** /**
* XMPP Stanza Handlers * XMPP Stanza Handlers
*/ */
$container->registerService('IQHandler', function (IContainer $c) { $container->registerService(IQ::class, function (IContainer $c) {
return new IQ( return new IQ(
$c->query('UserId'), $c->query('UserId'),
$c->query('Host'), $c->query('Host'),
$c->query(\OCP\IUserManager::class), $c->query(\OCP\IUserManager::class),
$c->query(\OCP\IConfig::class), $c->query(\OCP\IConfig::class),
$c->query('UserProvider') $c->query(IUserProvider::class)
); );
}); });
@ -211,25 +181,8 @@ class Application extends App
/** /**
* Helpers * Helpers
*/ */
$container->registerService('Config', function (IContainer $c) {
return new Config(
$c->query('AppName'),
$c->query(\OCP\IConfig::class)
);
});
$container->registerService('NewContentContainer', function () { $container->registerService(IUserProvider::class, function (IContainer $c) {
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) {
if (self::contactsStoreApiSupported()) { if (self::contactsStoreApiSupported()) {
return new ContactsStoreUserProvider( return new ContactsStoreUserProvider(
$c->query(\OCP\Contacts\ContactsMenu\IContactsStore::class), $c->query(\OCP\Contacts\ContactsMenu\IContactsStore::class),
@ -252,8 +205,8 @@ class Application extends App
$container->registerService('RefreshRosterCommand', function ($c) { $container->registerService('RefreshRosterCommand', function ($c) {
return new RefreshRoster( return new RefreshRoster(
$c->query('ServerContainer')->getUserManager(), $c->query('ServerContainer')->getUserManager(),
$c->query('RosterPush'), $c->query(RosterPush::class),
$c->query('PresenceMapper') $c->query(PresenceMapper::class)
); );
}); });

Просмотреть файл

@ -54,10 +54,8 @@ class DbLock implements ILock
*/ */
public function stillLocked() public function stillLocked()
{ {
$sql = "SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid`='ojsxc' AND `configkey`='longpolling'"; $storedPollingId = $this->config->getUserValue($this->userId, 'ojsxc', 'longpolling');
$q = $this->con->prepare($sql);
$q->execute([$this->userId]); return $storedPollingId === $this->pollingId;
$r = $q->fetch();
return $r['configvalue'] === $this->pollingId;
} }
} }