-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from nextcloud/fix_new_users
Update roster when creating, deleting and changing users fix jsxc/jsxc#565
- Loading branch information
Showing
15 changed files
with
435 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
* Released under the MIT license | ||
* @author Klaus Herberth <[email protected]> | ||
*/ | ||
use OCA\OJSXC\AppInfo\Application; | ||
|
||
if (!interface_exists('\OCP\Settings\ISettings')) { | ||
\OCP\App::registerAdmin ( 'ojsxc', 'settings/admin' ); | ||
} | ||
|
@@ -69,6 +71,9 @@ | |
$config->setAppValue('ojsxc', 'apiSecret', $apiSecret); | ||
} | ||
|
||
$app = new Application(); | ||
$app->getContainer()->query('UserHooks')->register(); | ||
|
||
if (!class_exists("\\Sabre\\Xml\\Version")) { | ||
require_once __DIR__ . "/../vendor/autoload.php"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use OCA\OJSXC\AppInfo\Application; | ||
|
||
$app = new Application(); | ||
|
||
/** @var Symfony\Component\Console\Application $application */ | ||
$application->add($app->getContainer()->query('RefreshRosterCommand')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace OCA\OJSXC\Command; | ||
|
||
use OCA\OJSXC\RosterPush; | ||
use OCP\IUserManager; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class RefreshRoster extends Command { | ||
|
||
/** | ||
* @var IUserManager | ||
*/ | ||
private $userManager; | ||
|
||
/** | ||
* @var RosterPush | ||
*/ | ||
private $rosterPush; | ||
|
||
public function __construct(IUserManager $userManager, | ||
RosterPush $rosterPush) { | ||
parent::__construct(); | ||
$this->userManager = $userManager; | ||
$this->rosterPush = $rosterPush; | ||
|
||
} | ||
|
||
protected function configure() { | ||
$this->setName('ojsxc:refresh-roster'); | ||
$this->setDescription('Refresh the roster of all users'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
|
||
$users = $this->userManager->search(''); | ||
|
||
foreach ($users as $user) { | ||
$this->rosterPush->createOrUpdateRosterItem($user); | ||
} | ||
|
||
$output->writeln("<info>Refreshed " . count($users) . " rosters. </info>"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace OCA\OJSXC\Db; | ||
|
||
use Sabre\Xml\Reader; | ||
use Sabre\Xml\Writer; | ||
use Sabre\Xml\XmlDeserializable; | ||
use Sabre\Xml\XmlSerializable; | ||
|
||
|
||
/** | ||
* This entity represents a roster push. | ||
* @see https://tools.ietf.org/html/rfc6121#section-2.1.6 | ||
* Class IQRosterPush | ||
* | ||
* @package OCA\OJSXC\Db | ||
* @method void setJid($jid) | ||
* @method void setName($name) | ||
* @method void setSubscription($subscription) | ||
* @method string getJid() | ||
* @method string getName() | ||
* @method string getSubscription() | ||
*/ | ||
class IQRosterPush extends Stanza implements XmlSerializable{ | ||
|
||
/** | ||
* @var string jid of the user, when inserting this into the DB, only userid | ||
* is needed. | ||
*/ | ||
public $jid; | ||
|
||
/** | ||
* @var string displayname of the user | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @var string subscription type. Both and remove are used. | ||
*/ | ||
public $subscription; | ||
|
||
public function xmlSerialize(Writer $writer) { | ||
$writer->write([ | ||
[ | ||
'name' => 'iq', | ||
'attributes' => [ | ||
'to' => $this->to, | ||
'type' => 'set', | ||
'id' => uniqid() | ||
], | ||
'value' => [[ | ||
'name' => 'query', | ||
'attributes' => [ | ||
'xmlns' => 'jabber:iq:roster', | ||
], | ||
'value' => [ | ||
"name" => "item", | ||
"attributes" => [ | ||
"jid" => $this->jid, | ||
"name" => $this->name, | ||
"subscription" => $this->subscription | ||
], | ||
"value" => '' | ||
] | ||
]] | ||
] | ||
]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace OCA\OJSXC\Db; | ||
|
||
/** | ||
* Class IQRosterPushMapper | ||
* | ||
* @package OCA\OJSXC\Db | ||
*/ | ||
class IQRosterPushMapper extends StanzaMapper { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.