Skip to content

Commit

Permalink
Refactoring. Removed unused parts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey18106 committed Jul 20, 2023
1 parent b0f3adb commit 8bf9d4d
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 395 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<command>OCA\AppEcosystemV2\Command\Daemon\RegisterDaemon</command>
<command>OCA\AppEcosystemV2\Command\Daemon\UnregisterDaemon</command>
<command>OCA\AppEcosystemV2\Command\Daemon\ListDaemons</command>
<command>OCA\AppEcosystemV2\Command\Scopes\ListApiScopes</command>
<command>OCA\AppEcosystemV2\Command\ApiScopes\ListApiScopes</command>
</commands>
<settings>
<admin>OCA\AppEcosystemV2\Settings\Admin</admin>
Expand Down
6 changes: 3 additions & 3 deletions docs/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Authentication flow

1. ExApp sends a request to Nextcloud
2. Nextcloud passes request to AppEcosystemV2
3. AppEcosystemV2 validates request (see [authentication](#AppEcosystemV2-authentication) section)
3. AppEcosystemV2 validates request (see `authentication flow in details`_)
4. Request is accepted/rejected

.. mermaid::
Expand All @@ -37,9 +37,9 @@ Each ExApp request to secured API with AppEcosystemAuth must contain the followi
2. `EX-APP-ID` - id of the ExApp
3. `EX-APP-VERSION` - version of the ExApp
4. `NC-USER-ID` - the user under which the request is made, can be empty in case of system apps (more details in [scopes](#AppEcosystemV2-scopes) section)
5. `AE-DATA-HASH` - hash of the request body (see details in [signature](#AE-SIGNATURE) section)
5. `AE-DATA-HASH` - hash of the request body (see details in `ae_signature`_ section)
6. `AE-SIGN-TIME` - unix timestamp of the request
7. `AE-SIGNATURE` - signature of the request (see details [signature](#AE-SIGNATURE) section)
7. `AE-SIGNATURE` - signature of the request (see details `ae_signature`_ section)


AE_SIGNATURE
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Welcome to the amazing docs that we will write for AppEcosystemV2!
definitions.rst
development/index.rst
deploy/index.rst
./authentication
authentication
File renamed without changes.
19 changes: 0 additions & 19 deletions lib/Db/DaemonConfigMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,6 @@ public function findAll(int $limit = null, int $offset = null): array {
return $this->findEntities($qb);
}

/**
* @param int $id
*
* @throws DoesNotExistException
* @throws Exception
* @throws MultipleObjectsReturnedException
*
* @return DaemonConfig
*/
public function findById(int $id): DaemonConfig {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
return $this->findEntity($qb);
}

/**
* @param string $name
*
Expand Down
36 changes: 0 additions & 36 deletions lib/Db/ExAppMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,6 @@ public function findByPort(int $port): array {
return $this->findEntities($qb);
}

/**
* @param string $name
*
* @throws DoesNotExistException if not found
* @throws MultipleObjectsReturnedException if more than one result
* @throws Exception
*
* @return ExApp
*/
public function findByName(string $name): Entity {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where(
$qb->expr()->eq('name', $qb->createNamedParameter($name, IQueryBuilder::PARAM_STR))
);
return $this->findEntity($qb);
}

/**
* @throws Exception
*/
Expand All @@ -125,23 +106,6 @@ public function deleteExApp(ExApp $exApp): int {
)->executeStatement();
}

/**
* @throws Exception
*/
public function findExAppEnabled(string $appId): array {
$qb = $this->db->getQueryBuilder();
$qb->select('enabled')
->from($this->tableName)
->where(
$qb->expr()->eq('appid', $qb->createNamedParameter($appId, IQueryBuilder::PARAM_STR))
);
$result = $qb->executeQuery();
return [
'success' => $result->rowCount() === 1,
'enabled' => $result->fetchOne(),
];
}

/**
* @throws Exception
*/
Expand Down
13 changes: 0 additions & 13 deletions lib/Db/ExAppPreferenceMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, 'preferences_ex');
}

/**
* @throws Exception
* @return ExAppPreference[]
*/
public function findAll(int $limit = null, int $offset = null): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->setMaxResults($limit)
->setFirstResult($offset);
return $this->findEntities($qb);
}

/**
* @param string $userId
* @param string $appId
Expand Down
12 changes: 0 additions & 12 deletions lib/Db/ExAppScopeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, 'ex_apps_scopes');
}

/**
* @throws Exception
*/
public function findAll(int $limit = null, int $offset = null): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->setMaxResults($limit)
->setFirstResult($offset);
return $this->findEntities($qb);
}

/**
* @param string $appId
*
Expand Down
12 changes: 0 additions & 12 deletions lib/Db/ExAppUserMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, 'ex_apps_users');
}

/**
* @throws Exception
*/
public function findAll(int $limit = null, int $offset = null): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->setMaxResults($limit)
->setFirstResult($offset);
return $this->findEntities($qb);
}

/**
* @throws Exception
*/
Expand Down
75 changes: 2 additions & 73 deletions lib/Db/ExFilesActionsMenuMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, 'ex_files_actions_menu');
}

/**
* @throws Exception
*/
public function findAll(int $limit = null, int $offset = null): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->setMaxResults($limit)
->setFirstResult($offset);
return $this->findEntities($qb);
}

/**
* @throws Exception
*/
Expand All @@ -83,22 +71,6 @@ public function findAllEnabled(): array {
return $result->fetchAll();
}

/**
* @param string $appId
*
* @throws Exception
* @return ExFilesActionsMenu[]
*/
public function findAllByAppId(string $appId): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where(
$qb->expr()->eq('appId', $qb->createNamedParameter($appId, IQueryBuilder::PARAM_STR))
);
return $this->findEntities($qb);
}

/**
* @param string $appId
* @param string $name
Expand All @@ -109,12 +81,12 @@ public function findAllByAppId(string $appId): array {
*
* @return ExFilesActionsMenu
*/
public function findByAppIdName(string $appId, string $name): ExFilesActionsMenu {
public function findByAppidName(string $appId, string $name): ExFilesActionsMenu {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where(
$qb->expr()->eq('appId', $qb->createNamedParameter($appId, IQueryBuilder::PARAM_STR)),
$qb->expr()->eq('appid', $qb->createNamedParameter($appId, IQueryBuilder::PARAM_STR)),
$qb->expr()->eq('name', $qb->createNamedParameter($name, IQueryBuilder::PARAM_STR)),
);
return $this->findEntity($qb);
Expand All @@ -139,47 +111,4 @@ public function findByName(string $name): ExFilesActionsMenu {
);
return $this->findEntity($qb);
}

/**
* @param ExFilesActionsMenu $exFilesActionsMenu
*
* @throws Exception
*
* @return int Number of updated rows
*/
public function updateFileActionMenu(ExFilesActionsMenu $exFilesActionsMenu): int {
$qb = $this->db->getQueryBuilder();
return $qb->update($this->tableName)
->set('display_name', $qb->createNamedParameter($exFilesActionsMenu->getDisplayName(), IQueryBuilder::PARAM_STR))
->set('mime', $qb->createNamedParameter($exFilesActionsMenu->getMime(), IQueryBuilder::PARAM_STR))
->set('permissions', $qb->createNamedParameter($exFilesActionsMenu->getPermissions(), IQueryBuilder::PARAM_STR))
->set('order', $qb->createNamedParameter($exFilesActionsMenu->getOrder(), IQueryBuilder::PARAM_INT))
->set('icon', $qb->createNamedParameter($exFilesActionsMenu->getIcon() ?? '', IQueryBuilder::PARAM_STR))
->set('icon_class', $qb->createNamedParameter($exFilesActionsMenu->getIconClass(), IQueryBuilder::PARAM_STR))
->set('action_handler', $qb->createNamedParameter($exFilesActionsMenu->getActionHandler(), IQueryBuilder::PARAM_STR))
->where(
$qb->expr()->eq('appId', $qb->createNamedParameter($exFilesActionsMenu->getAppid(), IQueryBuilder::PARAM_STR)),
$qb->expr()->eq('name', $qb->createNamedParameter($exFilesActionsMenu->getName(), IQueryBuilder::PARAM_STR))
)
->executeStatement();
}

/**
* @param ExFilesActionsMenu $exFilesActionsMenu
*
* @throws Exception
*
* @return int Number of deleted rows
*/
public function deleteByAppidName(ExFilesActionsMenu $exFilesActionsMenu): int {
$qb = $this->db->getQueryBuilder();
return $qb->delete($this->tableName)
->where(
$qb->expr()->eq('appId', $qb->createNamedParameter($exFilesActionsMenu->getAppid(), IQueryBuilder::PARAM_STR))
)
->andWhere(
$qb->expr()->eq('name', $qb->createNamedParameter($exFilesActionsMenu->getName(), IQueryBuilder::PARAM_STR))
)
->executeStatement();
}
}
Loading

0 comments on commit 8bf9d4d

Please sign in to comment.