adjust approve/reject to multiple settings in backend

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Julien Veyssier 2021-03-16 17:00:25 +01:00
Родитель 9c16da1b18
Коммит c68548813d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4141FEE162030638
3 изменённых файлов: 31 добавлений и 23 удалений

Просмотреть файл

@ -88,7 +88,7 @@ class ApprovalController extends Controller {
* @return DataDisplayResponse
*/
public function approve(int $fileId): DataResponse {
$this->approvalService->approve($fileId);
$this->approvalService->approve($fileId, $this->userId);
return new DataResponse(1);
}
@ -101,7 +101,7 @@ class ApprovalController extends Controller {
* @return DataDisplayResponse
*/
public function reject(int $fileId): DataResponse {
$this->approvalService->reject($fileId);
$this->approvalService->reject($fileId, $this->userId);
return new DataResponse(1);
}
}

Просмотреть файл

@ -97,35 +97,41 @@ class ApprovalService {
/**
* @param int $fileId
* @return void
* @return bool success
*/
public function approve(int $fileId): void {
$tagApprovedId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_approved', '0');
$this->tagObjectMapper->assignTags($fileId, 'files', $tagApprovedId);
$tagPendingId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_pending', '0');
try {
if ($this->tagObjectMapper->haveTag($fileId, 'files', $tagPendingId)) {
$this->tagObjectMapper->unassignTags($fileId, 'files', $tagPendingId);
public function approve(int $fileId, ?string $userId): bool {
$settings = $this->settingService->getSettings();
foreach ($settings as $id => $setting) {
try {
if ($this->tagObjectMapper->haveTag($fileId, 'files', $setting['tagPending'])
&& in_array($userId, $setting['users'])) {
$this->tagObjectMapper->assignTags($fileId, 'files', $setting['tagApproved']);
$this->tagObjectMapper->unassignTags($fileId, 'files', $setting['tagPending']);
return true;
}
} catch (TagNotFoundException $e) {
}
} catch (TagNotFoundException $e) {
}
return false;
}
/**
* @param int $fileId
* @return void
* @return bool success
*/
public function reject(int $fileId): void {
$tagRejectedId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_rejected', '0');
$this->tagObjectMapper->assignTags($fileId, 'files', $tagRejectedId);
$tagPendingId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_pending', '0');
try {
if ($this->tagObjectMapper->haveTag($fileId, 'files', $tagPendingId)) {
$this->tagObjectMapper->unassignTags($fileId, 'files', $tagPendingId);
public function reject(int $fileId, ?string $userId): bool {
$settings = $this->settingService->getSettings();
foreach ($settings as $id => $setting) {
try {
if ($this->tagObjectMapper->haveTag($fileId, 'files', $setting['tagPending'])
&& in_array($userId, $setting['users'])) {
$this->tagObjectMapper->assignTags($fileId, 'files', $setting['tagRejected']);
$this->tagObjectMapper->unassignTags($fileId, 'files', $setting['tagPending']);
return true;
}
} catch (TagNotFoundException $e) {
}
} catch (TagNotFoundException $e) {
}
return false;
}
}

Просмотреть файл

@ -144,7 +144,9 @@ export default {
methods: {
update(key, value) {
this.$emit('input', { ...this.value, [key]: value })
if (value) {
this.$emit('input', { ...this.value, [key]: value })
}
},
asyncFind(query) {
this.query = query