-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Georg Ehrke <[email protected]>
- Loading branch information
1 parent
d1b03f5
commit ab8cdbc
Showing
39 changed files
with
4,006 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
use OCA\UserStatus\AppInfo\Application; | ||
|
||
/** @var Application $app */ | ||
$app = \OC::$server->query(Application::class); | ||
$app->registerCapabilities(); | ||
$app->registerEvents(); |
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,21 @@ | ||
<?xml version="1.0"?> | ||
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> | ||
<id>user_status</id> | ||
<name>User Status</name> | ||
<summary>User Status</summary> | ||
<description><![CDATA[User Status]]></description> | ||
<version>0.0.2</version> | ||
<licence>agpl</licence> | ||
<author mail="[email protected]" >Georg Ehrke</author> | ||
<namespace>UserStatus</namespace> | ||
<default_enable/> | ||
<category>social</category> | ||
<bugs>https://github.com/nextcloud/server</bugs> | ||
<dependencies> | ||
<nextcloud min-version="20" max-version="20"/> | ||
</dependencies> | ||
<background-jobs> | ||
<job>OCA\UserStatus\BackgroundJob\ClearOldStatusesBackgroundJob</job> | ||
</background-jobs> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
return [ | ||
'ocs' => [ | ||
// Routes for querying statuses | ||
['name' => 'Statuses#findAll', 'url' => '/api/v1/statuses', 'verb' => 'GET'], | ||
['name' => 'Statuses#find', 'url' => '/api/v1/statuses/{userId}', 'verb' => 'GET'], | ||
// Routes for manipulating your own status | ||
['name' => 'UserStatus#getStatus', 'url' => '/api/v1/user_status', 'verb' => 'GET'], | ||
['name' => 'UserStatus#setStatus', 'url' => '/api/v1/user_status/status', 'verb' => 'PUT'], | ||
['name' => 'UserStatus#setPredefinedMessage', 'url' => '/api/v1/user_status/message/predefined', 'verb' => 'PUT'], | ||
['name' => 'UserStatus#setCustomMessage', 'url' => '/api/v1/user_status/message/custom', 'verb' => 'PUT'], | ||
['name' => 'UserStatus#clearStatus', 'url' => '/api/v1/user_status', 'verb' => 'DELETE'], | ||
// Routes for listing default routes | ||
['name' => 'PredefinedStatus#findAll', 'url' => '/api/v1/predefined_statuses', 'verb' => 'GET'] | ||
], | ||
]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OCA\UserStatus\AppInfo; | ||
|
||
use OCA\UserStatus\Capabilities; | ||
use OCA\UserStatus\Listener\UserDeletedListener; | ||
use OCA\UserStatus\Listener\UserLiveStatusListener; | ||
use OCP\AppFramework\App; | ||
use OCP\EventDispatcher\IEventDispatcher; | ||
use OCP\User\Events\UserDeletedEvent; | ||
use OCP\User\Events\UserLiveStatusEvent; | ||
|
||
/** | ||
* Class Application | ||
* | ||
* @package OCA\UserStatus\AppInfo | ||
*/ | ||
class Application extends App { | ||
|
||
/** @var string */ | ||
public const APP_ID = 'user_status'; | ||
|
||
/** | ||
* Application constructor. | ||
* | ||
* @param array $urlParams | ||
*/ | ||
public function __construct(array $urlParams = []) { | ||
parent::__construct(self::APP_ID, $urlParams); | ||
} | ||
|
||
/** | ||
* Registers capabilities that will be exposed | ||
* via the OCS API endpoint | ||
*/ | ||
public function registerCapabilities(): void { | ||
$this->getContainer() | ||
->registerCapability(Capabilities::class); | ||
} | ||
|
||
/** | ||
* Registers a listener for the user-delete event | ||
* to automatically delete a user's status on | ||
* account deletion | ||
*/ | ||
public function registerEvents(): void { | ||
/** @var IEventDispatcher $dispatcher */ | ||
$dispatcher = $this->getContainer() | ||
->query(IEventDispatcher::class); | ||
|
||
$dispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class); | ||
$dispatcher->addServiceListener(UserLiveStatusEvent::class, UserLiveStatusListener::class); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OCA\UserStatus\BackgroundJob; | ||
|
||
use OCA\UserStatus\Db\UserStatusMapper; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\BackgroundJob\TimedJob; | ||
|
||
/** | ||
* Class ClearOldStatusesBackgroundJob | ||
* | ||
* @package OCA\UserStatus\BackgroundJob | ||
*/ | ||
class ClearOldStatusesBackgroundJob extends TimedJob { | ||
|
||
/** @var UserStatusMapper */ | ||
private $mapper; | ||
|
||
/** | ||
* ClearOldStatusesBackgroundJob constructor. | ||
* | ||
* @param ITimeFactory $time | ||
* @param UserStatusMapper $mapper | ||
*/ | ||
public function __construct(ITimeFactory $time, | ||
UserStatusMapper $mapper) { | ||
parent::__construct($time); | ||
$this->mapper = $mapper; | ||
|
||
// Run every 15 minutes | ||
$this->setInterval(60 * 15); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function run($argument) { | ||
$this->mapper->clearOlderThan($this->time->getTime()); | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
namespace OCA\UserStatus; | ||
|
||
use OCA\UserStatus\Service\EmojiService; | ||
use OCP\Capabilities\ICapability; | ||
|
||
/** | ||
* Class Capabilities | ||
* | ||
* @package OCA\UserStatus | ||
*/ | ||
class Capabilities implements ICapability { | ||
|
||
/** @var EmojiService */ | ||
private $emojiService; | ||
|
||
/** | ||
* Capabilities constructor. | ||
* | ||
* @param EmojiService $emojiService | ||
*/ | ||
public function __construct(EmojiService $emojiService) { | ||
$this->emojiService = $emojiService; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCapabilities() { | ||
return [ | ||
'user_status' => [ | ||
'enabled' => true, | ||
'supports_emoji' => $this->emojiService->doesPlatformSupportEmoji(), | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.