Skip to content

Commit

Permalink
Add user-status app
Browse files Browse the repository at this point in the history
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
  • Loading branch information
georgehrke committed Jul 30, 2020
1 parent 7e28286 commit 4711dde
Show file tree
Hide file tree
Showing 74 changed files with 6,028 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
!/apps/updatenotification
!/apps/theming
!/apps/twofactor_backupcodes
!/apps/user_status
!/apps/workflowengine
/apps/files_external/3rdparty/irodsphp/PHPUnitTest
/apps/files_external/3rdparty/irodsphp/web
Expand Down
1 change: 1 addition & 0 deletions COPYING-README
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Licensing of components:
* User: AGPL
* XML/RPC: MIT / PHP
* Elementary filetype icons: GPL v3+
* Material UI icons: APACHE LICENSE, VERSION 2.0
All unmodified files from these and other sources retain their original copyright
and license notices: see the relevant individual files.

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ clean:
rm -rf apps/systemtags/js/systemtags.*
rm -rf apps/twofactor_backupcodes/js
rm -rf apps/updatenotification/js/updatenotification.*
rm -rf apps/user_status/js/
rm -rf apps/workflowengine/js/
rm -rf core/js/dist

Expand All @@ -57,5 +58,6 @@ clean-git: clean
git checkout -- apps/systemtags/js/systemtags.*
git checkout -- apps/twofactor_backupcodes/js
git checkout -- apps/updatenotification/js/updatenotification.*
git checkout -- apps/user_status/js/
git checkout -- apps/workflowengine/js/
git checkout -- core/js/dist
31 changes: 31 additions & 0 deletions apps/user_status/appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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="oc.list@georgehrke.com" >Georg Ehrke</author>
<namespace>UserStatus</namespace>
<default_enable/>
<category>social</category>
<bugs>https://github.com/nextcloud/server</bugs>
<navigations>
<navigation>
<id>user_status-menuitem</id>
<name>User status</name>
<route />
<order>1</order>
<icon>info.svg</icon>
<type>settings</type>
</navigation>
</navigations>
<dependencies>
<nextcloud min-version="20" max-version="20"/>
</dependencies>
<background-jobs>
<job>OCA\UserStatus\BackgroundJob\ClearOldStatusesBackgroundJob</job>
</background-jobs>
</info>
43 changes: 43 additions & 0 deletions apps/user_status/appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2020, Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @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#clearMessage', 'url' => '/api/v1/user_status/message', 'verb' => 'DELETE'],
// Routes for listing default routes
['name' => 'PredefinedStatus#findAll', 'url' => '/api/v1/predefined_statuses/', 'verb' => 'GET']
],
'routes' => [
['name' => 'Heartbeat#heartbeat', 'url' => '/heartbeat', 'verb' => 'PUT'],
],
];
37 changes: 37 additions & 0 deletions apps/user_status/css/user-status-menu.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @copyright Copyright (c) 2020 Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

.icon-user-status-away {
@include icon-color('user-status-away', 'user_status', '#F4A331', 1);
}

.icon-user-status-dnd {
@include icon-color('user-status-dnd', 'user_status', '#ED484C', 1);
}

.icon-user-status-invisible {
@include icon-color('user-status-invisible', 'user_status', '#000000', 1);
}

.icon-user-status-online {
@include icon-color('user-status-online', 'user_status', '#49B382', 2);
}
1 change: 1 addition & 0 deletions apps/user_status/img/app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/user_status/img/user-status-away.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/user_status/img/user-status-dnd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/user_status/img/user-status-invisible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/user_status/img/user-status-online.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/user_status/js/user-status-menu.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/user_status/js/user-status-menu.js.map

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions apps/user_status/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2020, Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @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\BeforeTemplateRenderedListener;
use OCA\UserStatus\Listener\UserDeletedListener;
use OCA\UserStatus\Listener\UserLiveStatusListener;
use OCA\UserStatus\Service\JSDataService;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\IInitialStateService;
use OCP\User\Events\UserDeletedEvent;
use OCP\User\Events\UserLiveStatusEvent;

/**
* Class Application
*
* @package OCA\UserStatus\AppInfo
*/
class Application extends App implements IBootstrap {

/** @var string */
public const APP_ID = 'user_status';

/**
* Application constructor.
*
* @param array $urlParams
*/
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}

/**
* @inheritDoc
*/
public function register(IRegistrationContext $context): void {
// Register OCS Capabilities
$context->registerCapability(Capabilities::class);

// Register Event Listeners
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
$context->registerEventListener(UserLiveStatusEvent::class, UserLiveStatusListener::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
}

/**
* @inheritDoc
*/
public function boot(IBootContext $context): void {
$appContainer = $context->getAppContainer();

/** @var IInitialStateService $initialState */
$initialState = $appContainer->query(IInitialStateService::class);
$initialState->provideLazyInitialState(self::APP_ID, 'status', static function () use ($appContainer) {
/** @var JSDataService $data */
$data = $appContainer->query(JSDataService::class);
return $data;
});
}
}
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 <oc.list@georgehrke.com>
*
* @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());
}
}
60 changes: 60 additions & 0 deletions apps/user_status/lib/Capabilities.php
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 <oc.list@georgehrke.com>
*
* @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(),
],
];
}
}
Loading

0 comments on commit 4711dde

Please sign in to comment.