зеркало из https://github.com/nextcloud/spreed.git
Use a different object type for all the notifications
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
b8a583d754
Коммит
92a1af6596
|
@ -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');
|
||||
|
|
Загрузка…
Ссылка в новой задаче