Browse Source

Log conversation deletions in the audit.log

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/5459/head
Joas Schilling 5 years ago
parent
commit
eb77791c0a
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 1
      lib/Manager.php
  2. 24
      lib/Room.php
  3. 7
      tests/php/RoomTest.php

1
lib/Manager.php

@ -171,7 +171,6 @@ class Manager {
return new Room(
$this,
$this->db,
$this->secureRandom,
$this->dispatcher,
$this->timeFactory,
$this->hasher,

24
lib/Room.php

@ -42,8 +42,8 @@ use OCP\Comments\IComment;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\Log\Audit\CriticalActionPerformedEvent;
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
class Room {
@ -134,8 +134,6 @@ class Room {
private $manager;
/** @var IDBConnection */
private $db;
/** @var ISecureRandom */
private $secureRandom;
/** @var IEventDispatcher */
private $dispatcher;
/** @var ITimeFactory */
@ -191,7 +189,6 @@ class Room {
public function __construct(Manager $manager,
IDBConnection $db,
ISecureRandom $secureRandom,
IEventDispatcher $dispatcher,
ITimeFactory $timeFactory,
IHasher $hasher,
@ -208,16 +205,15 @@ class Room {
string $password,
int $activeGuests,
int $callFlag,
\DateTime $activeSince = null,
\DateTime $lastActivity = null,
?\DateTime $activeSince,
?\DateTime $lastActivity,
int $lastMessageId,
IComment $lastMessage = null,
\DateTime $lobbyTimer = null,
string $objectType = '',
string $objectId = '') {
?IComment $lastMessage,
?\DateTime $lobbyTimer,
string $objectType,
string $objectId) {
$this->manager = $manager;
$this->db = $db;
$this->secureRandom = $secureRandom;
$this->dispatcher = $dispatcher;
$this->timeFactory = $timeFactory;
$this->hasher = $hasher;
@ -620,6 +616,12 @@ class Room {
$query->execute();
$this->dispatcher->dispatch(self::EVENT_AFTER_ROOM_DELETE, $event);
if (class_exists(CriticalActionPerformedEvent::class)) {
$this->dispatcher->dispatchTyped(new CriticalActionPerformedEvent(
'Conversation "%s" deleted',
['name' => $this->getName()],
));
}
}
/**

7
tests/php/RoomTest.php

@ -57,7 +57,6 @@ class RoomTest extends TestCase {
$room = new Room(
$this->createMock(Manager::class),
$this->createMock(IDBConnection::class),
$this->createMock(ISecureRandom::class),
$dispatcher,
$this->createMock(ITimeFactory::class),
$this->createMock(IHasher::class),
@ -76,7 +75,11 @@ class RoomTest extends TestCase {
Participant::FLAG_DISCONNECTED,
null,
null,
0
0,
null,
null,
'',
''
);
$verificationResult = $room->verifyPassword('1234');
$this->assertSame($verificationResult, ['result' => true, 'url' => '']);

Loading…
Cancel
Save