Use a different object type for all the notifications

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-11-21 17:02:57 +01:00
Родитель b8a583d754
Коммит 92a1af6596
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
6 изменённых файлов: 28 добавлений и 15 удалений

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

@ -97,10 +97,16 @@ class Notifier {
public function removePendingNotificationsForRoom($roomId) {
$notification = $this->notificationManager->createNotification();
$notification
->setApp('spreed')
->setObject('room', $roomId);
// @todo this should be in the Notifications\Hooks
$notification->setApp('spreed');
$notification->setObject('chat', $roomId);
$this->notificationManager->markProcessed($notification);
$notification->setObject('room', $roomId);
$this->notificationManager->markProcessed($notification);
$notification->setObject('call', $roomId);
$this->notificationManager->markProcessed($notification);
}
@ -120,8 +126,7 @@ class Notifier {
$notification
->setApp('spreed')
->setObject('room', $roomId)
->setSubject('mention')
->setObject('chat', $roomId)
->setUser($userId);
$this->notificationManager->markProcessed($notification);
@ -162,7 +167,7 @@ class Notifier {
$notification = $this->notificationManager->createNotification();
$notification
->setApp('spreed')
->setObject('room', $comment->getObjectId())
->setObject('chat', $comment->getObjectId())
->setUser($mentionedUserId)
->setSubject('mention', [
'userType' => $comment->getActorType(),

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

@ -157,7 +157,9 @@ class PageController extends Controller {
try {
$notification->setApp('spreed')
->setUser($this->userId)
->setObject('room', (string) $room->getId());
->setObject('room', $room->getId());
$this->notificationManager->markProcessed($notification);
$notification->setObject('call', $room->getId());
$this->notificationManager->markProcessed($notification);
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'spreed']);

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

@ -109,10 +109,12 @@ class Hooks {
$notification = $this->notificationManager->createNotification();
$dateTime = new \DateTime();
try {
// Remove all old notifications for this room
$notification->setApp('spreed')
->setObject('room', $room->getId());
$this->notificationManager->markProcessed($notification);
// Remove all old notifications for this room
$notification->setObject('call', $room->getId());
$this->notificationManager->markProcessed($notification);
$notification->setSubject('call', [

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

@ -114,7 +114,7 @@ class Notifier implements INotifier {
* @throws \InvalidArgumentException
*/
protected function parseMention(INotification $notification, Room $room, IL10N $l) {
if ($notification->getObjectType() !== 'room') {
if ($notification->getObjectType() !== 'chat') {
throw new \InvalidArgumentException('Unknown object type');
}
@ -340,7 +340,7 @@ class Notifier implements INotifier {
* @throws \InvalidArgumentException
*/
protected function parseCall(INotification $notification, Room $room, IL10N $l) {
if ($notification->getObjectType() !== 'room') {
if ($notification->getObjectType() !== 'call') {
throw new \InvalidArgumentException('Unknown object type');
}

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

@ -103,7 +103,7 @@ class NotifierTest extends \Test\TestCase {
$notification->expects($this->once())
->method('setObject')
->with('room', $comment->getObjectId())
->with('chat', $comment->getObjectId())
->willReturnSelf();
$notification->expects($this->once())
@ -450,12 +450,16 @@ class NotifierTest extends \Test\TestCase {
->with('spreed')
->willReturnSelf();
$notification->expects($this->once())
$notification->expects($this->exactly(3))
->method('setObject')
->with('room', 'testChatId')
->withConsecutive(
['chat', 'testChatId'],
['room', 'testChatId'],
['call', 'testChatId']
)
->willReturnSelf();
$this->notificationManager->expects($this->once())
$this->notificationManager->expects($this->exactly(3))
->method('markProcessed')
->with($notification);

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

@ -459,7 +459,7 @@ class NotifierTest extends \Test\TestCase {
->willReturn($subjectParameters);
$notification->expects($this->once())
->method('getObjectType')
->willReturn('room');
->willReturn('chat');
$notification->expects($this->once())
->method('getMessage')
->willReturn('message');