-
Notifications
You must be signed in to change notification settings - Fork 260
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: Hamza Mahjoubi <[email protected]>
- Loading branch information
Showing
3 changed files
with
93 additions
and
2 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
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 |
---|---|---|
|
@@ -49,10 +49,11 @@ public function findAll(string $userId): array { | |
|
||
/** | ||
* @param string | ||
* @return Snippet[] | ||
*/ | ||
public function findAllSharedWithMe(string $userId): array { | ||
Check failure on line 54 in lib/Service/SnippetService.php GitHub Actions / static-psalm-analysis dev-masterInvalidDocblock
|
||
$groups = $this->groupManager->getUserGroupIds($userId); | ||
return $this->snippetShareMapper->findSharedWithMe($userId, $groups); | ||
return $this->snippetMapper->findSharedWithMe($userId, $groups); | ||
} | ||
/** | ||
* @param int $snippetId | ||
|
@@ -103,7 +104,13 @@ public function delete(int $snippetId, string $userId): void { | |
$this->snippetMapper->delete($snippet); | ||
} | ||
|
||
//TODO: run owner check on controller level | ||
|
||
/** | ||
* @param int $snippetId | ||
* @param string $shareWith | ||
* @throws DoesNotExistException | ||
* @throws NotPermittedException | ||
*/ | ||
public function share(int $snippetId, string $shareWith): void { | ||
|
||
$sharee = $this->userManager->get($shareWith); | ||
|
@@ -120,6 +127,12 @@ public function share(int $snippetId, string $shareWith): void { | |
$this->snippetShareMapper->insert($share); | ||
} | ||
|
||
/** | ||
* @param int $snippetId | ||
* @param string $groupId | ||
* @throws DoesNotExistException | ||
* @throws NotPermittedException | ||
*/ | ||
public function shareWithGroup(int $snippetId, string $groupId): void { | ||
if (!$this->groupManager->groupExists($groupId)) { | ||
throw new DoesNotExistException('Group does not exist'); | ||
|
@@ -134,6 +147,11 @@ public function shareWithGroup(int $snippetId, string $groupId): void { | |
$this->snippetShareMapper->insert($share); | ||
} | ||
|
||
/** | ||
* @param int $snippetId | ||
* @param string $shareWith | ||
* @throws DoesNotExistException | ||
*/ | ||
public function unshare(int $snippetId, string $shareWith): void { | ||
$share = $this->snippetShareMapper->find($snippetId, $shareWith); | ||
$this->snippetShareMapper->delete($share); | ||
|