mirror of
https://github.com/nextcloud/tables.git
synced 2025-07-31 21:09:20 +00:00
Remove unneccessary user id
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
This commit is contained in:
@ -157,7 +157,7 @@ class LegacyRowMapper extends QBMapper {
|
||||
/**
|
||||
* @param (int|string)[][] $sortArray
|
||||
*
|
||||
* @psalm-param list<array{columnId: int, mode: 'ASC'|'DESC'}> $sortArray
|
||||
* @psalm-param list<array{columnId?: int, columnType?: string, mode?: 'ASC'|'DESC'}> $sortArray
|
||||
*/
|
||||
private function addOrderByRules(IQueryBuilder $qb, array $sortArray) {
|
||||
foreach ($sortArray as $index => $sortRule) {
|
||||
|
@ -8,15 +8,11 @@ use OCA\Tables\Db\Row2;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
final class RowDeletedEvent extends Event {
|
||||
public function __construct(protected Row2 $row, protected string $userId) {
|
||||
public function __construct(protected Row2 $row) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getRow(): Row2 {
|
||||
return $this->row;
|
||||
}
|
||||
|
||||
public function getUserId(): string {
|
||||
return $this->userId;
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,11 @@ use OCA\Tables\Db\Table;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
final class TableDeletedEvent extends Event {
|
||||
public function __construct(protected Table $table, protected string $userId) {
|
||||
public function __construct(protected Table $table) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getTable(): Table {
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
public function getUserId(): string {
|
||||
return $this->userId;
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,11 @@ use OCA\Tables\Db\View;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
final class ViewDeletedEvent extends Event {
|
||||
public function __construct(protected View $view, protected string $userId) {
|
||||
public function __construct(protected View $view) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getView(): View {
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
public function getUserId(): string {
|
||||
return $this->userId;
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,10 @@ final class WhenRowDeletedAuditLogListener implements IEventListener {
|
||||
}
|
||||
|
||||
$row = $event->getRow();
|
||||
$userId = $event->getUserId();
|
||||
$rowId = $row->getId();
|
||||
|
||||
$this->auditLogService->log("Row with ID: $rowId was deleted by user with ID: $userId", [
|
||||
$this->auditLogService->log("Row with ID: $rowId was deleted", [
|
||||
'row' => $row->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,9 @@ final class WhenTableDeletedAuditLogListener implements IEventListener {
|
||||
}
|
||||
|
||||
$table = $event->getTable();
|
||||
$userId = $event->getUserId();
|
||||
|
||||
$this->auditLogService->log("Table with ID: $table->id was deleted by user with ID: $userId", [
|
||||
$this->auditLogService->log("Table with ID: $table->id was deleted", [
|
||||
'table' => $table->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,9 @@ final class WhenViewDeletedAuditLogListener implements IEventListener {
|
||||
}
|
||||
|
||||
$view = $event->getView();
|
||||
$userId = $event->getUserId();
|
||||
|
||||
$this->auditLogService->log("View with ID: $view->id was deleted by user with ID: $userId", [
|
||||
$this->auditLogService->log("View with ID: $view->id was deleted", [
|
||||
'view' => $view->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -465,10 +465,7 @@ class RowService extends SuperService {
|
||||
try {
|
||||
$deletedRow = $this->row2Mapper->delete($item);
|
||||
|
||||
$event = new RowDeletedEvent(
|
||||
row: $item,
|
||||
userId: $userId
|
||||
);
|
||||
$event = new RowDeletedEvent(row: $item);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped($event);
|
||||
|
||||
|
@ -431,14 +431,7 @@ class TableService extends SuperService {
|
||||
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* Decouple the side logic from the core business logic
|
||||
* (logging, mail sending, etc.), called handling side effects and most of them can be done asynchronously via queue.
|
||||
*/
|
||||
$event = new TableDeletedEvent(
|
||||
table: $item,
|
||||
userId: $userId
|
||||
);
|
||||
$event = new TableDeletedEvent(table: $item);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped($event);
|
||||
|
||||
|
@ -282,10 +282,7 @@ class ViewService extends SuperService {
|
||||
try {
|
||||
$deletedView = $this->mapper->delete($view);
|
||||
|
||||
$event = new ViewDeletedEvent(
|
||||
view: $view,
|
||||
userId: $userId
|
||||
);
|
||||
$event = new ViewDeletedEvent(view: $view);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped($event);
|
||||
|
||||
@ -317,10 +314,7 @@ class ViewService extends SuperService {
|
||||
|
||||
$this->mapper->delete($view);
|
||||
|
||||
$event = new ViewDeletedEvent(
|
||||
view: $view,
|
||||
userId: $userId
|
||||
);
|
||||
$event = new ViewDeletedEvent(view: $view);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped($event);
|
||||
|
||||
|
@ -22,18 +22,16 @@ final class WhenRowDeletedAuditLogTest extends TestCase {
|
||||
public function testHandle(): void {
|
||||
$row = new Row2();
|
||||
$row->setId(1);
|
||||
$userId = 'user1';
|
||||
|
||||
$event = new RowDeletedEvent($row, $userId);
|
||||
$event = new RowDeletedEvent(row: $row);
|
||||
|
||||
$this->auditLogService
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with(
|
||||
$this->equalTo("Row with ID: {$row->getId()} was deleted by user with ID: $userId"),
|
||||
$this->equalTo("Row with ID: {$row->getId()} was deleted"),
|
||||
$this->equalTo([
|
||||
'row' => $row->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -22,18 +22,16 @@ final class WhenTableDeletedAuditLogTest extends TestCase {
|
||||
public function testHandle(): void {
|
||||
$table = new Table();
|
||||
$table->id = 1;
|
||||
$userId = 'user1';
|
||||
|
||||
$event = new TableDeletedEvent($table, $userId);
|
||||
$event = new TableDeletedEvent($table);
|
||||
|
||||
$this->auditLogService
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with(
|
||||
$this->equalTo("Table with ID: {$table->id} was deleted by user with ID: $userId"),
|
||||
$this->equalTo("Table with ID: {$table->id} was deleted"),
|
||||
$this->equalTo([
|
||||
'table' => $table->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -22,18 +22,16 @@ final class WhenViewDeletedAuditLogTest extends TestCase {
|
||||
public function testHandle(): void {
|
||||
$view = new View();
|
||||
$view->id = 1;
|
||||
$userId = 'user1';
|
||||
|
||||
$event = new ViewDeletedEvent($view, $userId);
|
||||
$event = new ViewDeletedEvent(view: $view);
|
||||
|
||||
$this->auditLogService
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with(
|
||||
$this->equalTo("View with ID: {$view->id} was deleted by user with ID: $userId"),
|
||||
$this->equalTo("View with ID: {$view->id} was deleted"),
|
||||
$this->equalTo([
|
||||
'view' => $view->jsonSerialize(),
|
||||
'userId' => $userId,
|
||||
])
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user