Browse Source

Merge pull request #10731 from nextcloud/techdebt/noid/room-modified-events

Document and type PHP events
pull/10754/head
Joas Schilling 2 years ago
committed by GitHub
parent
commit
2d44c5992f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 317
      docs/events.md
  2. 23
      lib/Chat/ChatManager.php
  3. 1
      lib/Chat/Command/Executor.php
  4. 4
      lib/Chat/MessageParser.php
  5. 3
      lib/Config.php
  6. 1
      lib/Controller/RoomController.php
  7. 13
      lib/Controller/SignalingController.php
  8. 65
      lib/Events/AAttendeeRemovedEvent.php
  9. 58
      lib/Events/ABeforeJoinedRoomEvent.php
  10. 42
      lib/Events/ACallEndedForEveryoneEvent.php
  11. 51
      lib/Events/ALobbyModifiedEvent.php
  12. 53
      lib/Events/AMessageSentEvent.php
  13. 71
      lib/Events/AParticipantModifiedEvent.php
  14. 76
      lib/Events/ARoomModifiedEvent.php
  15. 45
      lib/Events/ASessionLeftRoomEvent.php
  16. 60
      lib/Events/ASystemMessageSentEvent.php
  17. 3
      lib/Events/AddEmailEvent.php
  18. 3
      lib/Events/AddParticipantsEvent.php
  19. 3
      lib/Events/AlreadySharedEvent.php
  20. 27
      lib/Events/AttendeeRemovedEvent.php
  21. 30
      lib/Events/AttendeesAddedEvent.php
  22. 5
      lib/Events/AttendeesEvent.php
  23. 27
      lib/Events/BeforeAttendeeRemovedEvent.php
  24. 27
      lib/Events/BeforeAttendeesAddedEvent.php
  25. 27
      lib/Events/BeforeCallEndedForEveryoneEvent.php
  26. 27
      lib/Events/BeforeChatMessageSentEvent.php
  27. 43
      lib/Events/BeforeDuplicateShareSentEvent.php
  28. 41
      lib/Events/BeforeEmailInvitationSentEvent.php
  29. 27
      lib/Events/BeforeGuestJoinedRoomEvent.php
  30. 27
      lib/Events/BeforeGuestsCleanedUpEvent.php
  31. 27
      lib/Events/BeforeLobbyModifiedEvent.php
  32. 27
      lib/Events/BeforeParticipantModifiedEvent.php
  33. 2
      lib/Events/BeforeRoomModifiedEvent.php
  34. 27
      lib/Events/BeforeSessionLeftRoomEvent.php
  35. 51
      lib/Events/BeforeSignalingResponseSentEvent.php
  36. 27
      lib/Events/BeforeSignalingRoomPropertiesSentEvent.php
  37. 27
      lib/Events/BeforeSystemMessageSentEvent.php
  38. 51
      lib/Events/BeforeTurnServersGetEvent.php
  39. 46
      lib/Events/BeforeUserJoinedRoomEvent.php
  40. 57
      lib/Events/CallEndedForEveryoneEvent.php
  41. 49
      lib/Events/CallNotificationSendEvent.php
  42. 3
      lib/Events/ChatEvent.php
  43. 3
      lib/Events/ChatMessageEvent.php
  44. 27
      lib/Events/ChatMessageSentEvent.php
  45. 3
      lib/Events/ChatParticipantEvent.php
  46. 3
      lib/Events/CommandEvent.php
  47. 3
      lib/Events/CreateRoomTokenEvent.php
  48. 3
      lib/Events/DuplicatedParticipantEvent.php
  49. 41
      lib/Events/EmailInvitationSentEvent.php
  50. 3
      lib/Events/EndCallForEveryoneEvent.php
  51. 3
      lib/Events/GetTurnServersEvent.php
  52. 40
      lib/Events/GuestJoinedRoomEvent.php
  53. 27
      lib/Events/GuestsCleanedUpEvent.php
  54. 3
      lib/Events/JoinRoomGuestEvent.php
  55. 3
      lib/Events/JoinRoomUserEvent.php
  56. 27
      lib/Events/LobbyModifiedEvent.php
  57. 36
      lib/Events/MessageParseEvent.php
  58. 3
      lib/Events/ModifyEveryoneEvent.php
  59. 3
      lib/Events/ModifyLobbyEvent.php
  60. 3
      lib/Events/ModifyParticipantEvent.php
  61. 3
      lib/Events/ModifyRoomEvent.php
  62. 3
      lib/Events/ParticipantEvent.php
  63. 27
      lib/Events/ParticipantModifiedEvent.php
  64. 3
      lib/Events/RemoveParticipantEvent.php
  65. 3
      lib/Events/RemoveUserEvent.php
  66. 27
      lib/Events/RoomCreatedEvent.php
  67. 3
      lib/Events/RoomEvent.php
  68. 2
      lib/Events/RoomModifiedEvent.php
  69. 59
      lib/Events/RoomPasswordVerifyEvent.php
  70. 3
      lib/Events/SendCallNotificationEvent.php
  71. 27
      lib/Events/SessionLeftRoomEvent.php
  72. 3
      lib/Events/SignalingEvent.php
  73. 3
      lib/Events/SignalingRoomPropertiesEvent.php
  74. 3
      lib/Events/SilentModifyParticipantEvent.php
  75. 27
      lib/Events/SystemMessageSentEvent.php
  76. 27
      lib/Events/SystemMessagesMultipleSentEvent.php
  77. 3
      lib/Events/UserEvent.php
  78. 46
      lib/Events/UserJoinedRoomEvent.php
  79. 3
      lib/Events/VerifyRoomPasswordEvent.php
  80. 19
      lib/GuestManager.php
  81. 4
      lib/Manager.php
  82. 66
      lib/Room.php
  83. 161
      lib/Service/ParticipantService.php
  84. 95
      lib/Service/RoomService.php
  85. 4
      lib/Share/RoomShareProvider.php
  86. 68
      tests/php/EventDocumentationTest.php

317
docs/events.md

@ -1,209 +1,458 @@
# PHP Events
Explanations:
* `Event class`: is the PHP class of the event object that is passed by the event
* `Event name`: refers to the PHP constant that contains the full name for the event. You should always use the constants instead of copying the value to avoid problems in the future. Most events have a `Before` and `After` event name. They behave the same and reflect if the event is triggered before or after the action described.
See the general [Nextcloud Developers - Events](https://docs.nextcloud.com/server/latest/developer_manual/basics/events.html) documentation for information how to listen to the events.
## Conversation related events
### Get conversations list
### Conversation list fetched
* Before event: `OCA\Talk\Events\BeforeRoomsFetchEvent`
* After event: *Not available*
* Since: 18.0.0
### Conversation created
* Before event: *Not available*
* After event: `OCA\Talk\Events\RoomCreatedEvent`
* Since: 18.0.0
### Conversation deleted
* Before event: `OCA\Talk\Events\BeforeRoomDeletedEvent`
* After event: `OCA\Talk\Events\RoomDeletedEvent`
* Since: 18.0.0
### Conversation modified
* Before event: `OCA\Talk\Events\BeforeRoomModifiedEvent`
* After event: `OCA\Talk\Events\RoomModifiedEvent`
* Since: 18.0.0
### Lobby modified
* Before event: `OCA\Talk\Events\BeforeLobbyModifiedEvent`
* After event: `OCA\Talk\Events\LobbyModifiedEvent`
* Since: 18.0.0
### Call ended for everyone
* Before event: `OCA\Talk\Events\BeforeCallEndedForEveryoneEvent`
* After event: `OCA\Talk\Events\CallEndedForEveryoneEvent`
* Since: 18.0.0
### Conversation password verify
Allows to verify a password and set a redirect URL for the invalid case
* Event: `OCA\Talk\Events\RoomPasswordVerifyEvent`
* Since: 18.0.0
### Deprecated events
These events were not using the typed-event mechanism and are therefore deprecated and will be removed in a future version.
#### Get conversations list
* Event class: `OCA\Talk\Events\UserEvent`
* Event name: `OCA\Talk\Controller\RoomController::EVENT_BEFORE_ROOMS_GET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomsFetchEvent` instead
* Removed: 19.0.0
### Create conversation
#### Create conversation
* Event class: `OCA\Talk\Events\RoomEvent`
* Event name: `OCA\Talk\Room::EVENT_AFTER_ROOM_CREATE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\RoomCreatedEvent` instead
* Removed: 19.0.0
### Create token for conversation
#### Create token for conversation
* Event class: `OCA\Talk\Events\CreateRoomTokenEvent`
* Event name: `OCA\Talk\Manager::EVENT_TOKEN_GENERATE`
* Since: 8.0.0
* Removed: 11.0.0
### Set name
#### Set name
* Event class: `OCA\Talk\Events\ModifyRoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_NAME_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_NAME_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Set password
#### Set password
* Event class: `OCA\Talk\Events\ModifyRoomEvent`
- No old value is provided
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_PASSWORD_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_PASSWORD_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Set type
#### Set type
* Event class: `OCA\Talk\Events\ModifyRoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_TYPE_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_TYPE_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Set read-only
#### Set read-only
* Event class: `OCA\Talk\Events\ModifyRoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_READONLY_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_READONLY_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Set listable
#### Set listable
* Event class: `OCA\Talk\Events\ModifyRoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_LISTABLE_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_LISTABLE_SET`
* Since: 11.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Set lobby
#### Set lobby
* Event class: `OCA\Talk\Events\ModifyLobbyEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_LOBBY_STATE_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_LOBBY_STATE_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomModifiedEvent` and `OCA\Talk\Events\RoomModifiedEvent` instead
* Removed: 19.0.0
### Clean up guests
#### Clean up guests
* Event class: `OCA\Talk\Events\RoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_GUESTS_CLEAN`
* After event name: `OCA\Talk\Room::EVENT_AFTER_GUESTS_CLEAN`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeGuestsCleanedUpEvent` and `OCA\Talk\Events\GuestsCleanedUpEvent` instead
* Removed: 19.0.0
### Verify password
#### Verify password
* Event class: `OCA\Talk\Events\VerifyRoomPasswordEvent`
* Event name: `OCA\Talk\Room::EVENT_PASSWORD_VERIFY`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\RoomPasswordVerifyEvent` instead
* Removed: 19.0.0
### Delete conversation
#### Delete conversation
* Event class: `OCA\Talk\Events\RoomEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_ROOM_DELETE`
* After event name: `OCA\Talk\Room::EVENT_AFTER_ROOM_DELETE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeRoomDeletedEvent` and `OCA\Talk\Events\RoomDeletedEvent` instead
* Removed: 19.0.0
## Participant related events
### Add participants
### Attendees added
* Before event: `OCA\Talk\Events\BeforeAttendeesAddedEvent`
* Since: 18.0.0
* After event: `OCA\Talk\Events\AttendeesAddedEvent`
* Since: 12.0.0
### Attendees removed
* Before event: *Not available*
* After event: `OCA\Talk\Events\AttendeesRemovedEvent`
* Since: 12.0.0
### Attendee removed
* Before event: `OCA\Talk\Events\BeforeAttendeeRemovedEvent`
* After event: `OCA\Talk\Events\AttendeeRemovedEvent`
* Since: 18.0.0
### User joined a conversation
* Before event: `OCA\Talk\Events\BeforeUserJoinedRoomEvent`
* After event: `OCA\Talk\Events\UserJoinedRoomEvent`
* Since: 18.0.0
### Federated user joined a conversation
* Before event: `OCA\Talk\Events\BeforeFederatedUserJoinedRoomEvent`
* After event: `OCA\Talk\Events\FederatedUserJoinedRoomEvent`
* Since: 18.0.0
### Guest joined a conversation
* Before event: `OCA\Talk\Events\BeforeGuestJoinedRoomEvent`
* After event: `OCA\Talk\Events\GuestJoinedRoomEvent`
* Since: 18.0.0
### Email invitation send
* Before event: `OCA\Talk\Events\BeforeEmailInvitationSentEvent`
* After event: `OCA\Talk\Events\EmailInvitationSentEvent`
* Since: 18.0.0
### Session left a conversation
This is the invert action to `User joined a conversation`, `Federated user joined a conversation` and `Guest joined a conversation`
* Before event: `OCA\Talk\Events\BeforeSessionLeftRoomEvent`
* After event: `OCA\Talk\Events\SessionLeftRoomEvent`
* Since: 18.0.0
### Participant modified
* Before event: `OCA\Talk\Events\BeforeParticipantModifiedEvent`
* After event: `OCA\Talk\Events\ParticipantModifiedEvent`
* Since: 18.0.0
### Call notification send
* **internal:** This event is not part of the public API and you should not rely on it
* Event: `OCA\Talk\Events\CallNotificationSendEvent`
* Since: 18.0.0
### Guests cleaned up
Remove guests without an active session
* Before event: `OCA\Talk\Events\BeforeGuestsCleanedUpEvent`
* After event: `OCA\Talk\Events\GuestsCleanedUpEvent`
* Since: 18.0.0
### Deprecated events
These events were not using the typed-event mechanism and are therefore deprecated and will be removed in a future version.
#### Add participants
* Event class: `OCA\Talk\Events\AddParticipantsEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_USERS_ADD`
* After event name: `OCA\Talk\Room::EVENT_AFTER_USERS_ADD`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeAttendeesAddedEvent` and `OCA\Talk\Events\AttendeesAddedEvent` instead
* Removed: 19.0.0
### Add email
#### Add email
* Event class: `OCA\Talk\Events\AddEmailEvent`
* Before event name: `OCA\Talk\GuestManager::EVENT_BEFORE_EMAIL_INVITE`
* After event name: `OCA\Talk\GuestManager::EVENT_AFTER_EMAIL_INVITE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeEmailInvitationSentEvent` and `OCA\Talk\Events\EmailInvitationSentEvent` instead
* Removed: 19.0.0
### Remove participant by session
#### Guest changes name
* Event class: `OCA\Talk\Events\RemoveParticipantEvent`
* Event class: `OCA\Talk\Events\ParticipantEvent`
* Event name: `OCA\Talk\GuestManager::EVENT_AFTER_NAME_UPDATE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeParticipantModifiedEvent` and `OCA\Talk\Events\ParticipantModifiedEvent` instead
* Removed: 19.0.0
### Set participant type for user
#### Set participant type for user
* Event class: `OCA\Talk\Events\ModifyParticipantEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_PARTICIPANT_TYPE_SET`
* After event name: `OCA\Talk\Room::EVENT_AFTER_PARTICIPANT_TYPE_SET`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeParticipantModifiedEvent` and `OCA\Talk\Events\ParticipantModifiedEvent` instead
* Removed: 19.0.0
### Join a conversation as user (Connect)
#### Join a conversation as user (Connect)
* Event class: `OCA\Talk\Events\JoinRoomUserEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_ROOM_CONNECT`
* After event name: `OCA\Talk\Room::EVENT_AFTER_ROOM_CONNECT`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeUserJoinedRoomEvent` and `OCA\Talk\Events\UserJoinedRoomEvent` instead
* Removed: 19.0.0
### Join a conversation as guest (Connect)
#### Join a conversation as guest (Connect)
* Event class: `OCA\Talk\Events\JoinRoomGuestEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_GUEST_CONNECT`
* After event name: `OCA\Talk\Room::EVENT_AFTER_GUEST_CONNECT`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeGuestJoinedRoomEvent` and `OCA\Talk\Events\GuestJoinedRoomEvent` instead
* Removed: 19.0.0
### Join a call
#### Join a call
* Event class: `OCA\Talk\Events\ModifyParticipantEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_SESSION_JOIN_CALL`
* After event name: `OCA\Talk\Room::EVENT_AFTER_SESSION_JOIN_CALL`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeParticipantModifiedEvent` and `OCA\Talk\Events\ParticipantModifiedEvent` instead
* Removed: 19.0.0
### Leave a call
#### Leave a call
* Event class: `OCA\Talk\Events\ModifyParticipantEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_SESSION_LEAVE_CALL`
* After event name: `OCA\Talk\Room::EVENT_AFTER_SESSION_LEAVE_CALL`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeParticipantModifiedEvent` and `OCA\Talk\Events\ParticipantModifiedEvent` instead
* Removed: 19.0.0
### Leave a conversation (Disconnect)
#### Leave a conversation (Disconnect)
* Event class: `OCA\Talk\Events\ParticipantEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_ROOM_DISCONNECT`
* After event name: `OCA\Talk\Room::EVENT_AFTER_ROOM_DISCONNECT`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeSessionLeftRoomEvent` and `OCA\Talk\Events\SessionLeftRoomEvent` instead
* Removed: 19.0.0
### Remove user
#### Remove user
* Event class: `OCA\Talk\Events\RemoveUserEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_USER_REMOVE`
* After event name: `OCA\Talk\Room::EVENT_AFTER_USER_REMOVE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeAttendeeRemovedEvent` and `OCA\Talk\Events\AttendeeRemovedEvent` instead
* Removed: 19.0.0
### Remove participant by session
#### Remove participant by session
* Event class: `OCA\Talk\Events\RemoveParticipantEvent`
* Before event name: `OCA\Talk\Room::EVENT_BEFORE_PARTICIPANT_REMOVE`
* After event name: `OCA\Talk\Room::EVENT_AFTER_PARTICIPANT_REMOVE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeAttendeeRemovedEvent` and `OCA\Talk\Events\AttendeeRemovedEvent` instead
* Removed: 19.0.0
## Chat related events
### System message
### Parse chat message
Used to parse mentions, replace parameters in messages with rich objects, transform system messages into readable and translated chat messages etc.
* Event: `OCA\Talk\Events\MessageParseEvent`
* Since: 18.0.0
### Chat message sent
* Before event: `OCA\Talk\Events\BeforeChatMessageSentEvent`
* After event: `OCA\Talk\Events\ChatMessageSentEvent`
* Since: 18.0.0
### Duplicate share sent
Sharing the same file a second time is prevented by the API. But this event is dispatched, so that the chat message can be created nevertheless.
* Before event: `OCA\Talk\Events\BeforeDuplicateShareSentEvent`
* After event: *Not available*
* Since: 18.0.0
### System message sent
`shouldSkipLastActivityUpdate` indicates whether multiple system messages are being sent.
In case you only need to be notified after the last system message was posted,
listen to the `OCA\Talk\Events\SystemMessagesMultipleSentEvent` event instead.
* Before event: `OCA\Talk\Events\BeforeSystemMessageSentEvent`
* After event: `OCA\Talk\Events\SystemMessageSentEvent`
* Final event: `OCA\Talk\Events\SystemMessagesMultipleSentEvent` - Only sent once as per above explanation
* Since: 18.0.0
### Deprecated events
These events were not using the typed-event mechanism and are therefore deprecated and will be removed in a future version.
#### System message
* Event class: `OCA\Talk\Events\ChatEvent`
* Before event name: `OCA\Talk\Chat\ChatManager::EVENT_BEFORE_SYSTEM_MESSAGE_SEND`
* After event name: `OCA\Talk\Chat\ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeSystemMessageSentEvent` and `OCA\Talk\Events\SystemMessageSentEvent` instead
* Removed: 19.0.0
### Post chat message
#### Post chat message
* Event class: `OCA\Talk\Events\ChatEvent`
* Before event name: `OCA\Talk\Chat\ChatManager::EVENT_BEFORE_MESSAGE_SEND`
* After event name: `OCA\Talk\Chat\ChatManager::EVENT_AFTER_MESSAGE_SEND`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeChatMessageSentEvent` and `OCA\Talk\Events\ChatMessageSentEvent` instead
* Removed: 19.0.0
### Parse chat message
#### Parse chat message
* Event class: `OCA\Talk\Events\ChatMessageEvent`
* Event name: `OCA\Talk\Chat\MessageParser::EVENT_MESSAGE_PARSE`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\MessageParseEvent` instead
* Removed: 19.0.0
### Command execution for apps
#### Command execution for apps
* Event class: `OCA\Talk\Events\CommandEvent`
* Event name: `OCA\Talk\Chat\Command\Executor::EVENT_APP_EXECUTE`
* Since: 8.0.0
* Deprecated: 17.0.0 - Commands are deprecated, please migrate to bots instead
## Other events
### Signaling backend
### Turn servers get
* Before event: `OCA\Talk\Events\BeforeTurnServersGetEvent`
* After event: *Not available*
* Since: 18.0.0
### Signaling room properties sent
* Before event: `OCA\Talk\Events\BeforeSignalingRoomPropertiesSentEvent`
* After event: *Not available*
* Since: 18.0.0
### Signaling response sent
* Before event: `OCA\Talk\Events\BeforeSignalingResponseSentEvent`
* After event: *Not available*
* Since: 18.0.0
### Deprecated events
These events were not using the typed-event mechanism and are therefore deprecated and will be removed in a future version.
#### Signaling backend
* Event class: `OCA\Talk\Events\SignalingEvent`
* Event name: `OCA\Talk\Controller\SignalingController::EVENT_BACKEND_SIGNALING_ROOMS`
* Since: 8.0.0
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeSignalingResponseSentEvent` instead
* Removed: 19.0.0
### Get conversation properties for signaling
#### Get conversation properties for signaling
* Event class: `OCA\Talk\Events\SignalingRoomPropertiesEvent`
* Event name: `OCA\Talk\Room::EVENT_BEFORE_SIGNALING_PROPERTIES`
* Since: 8.0.5
* Deprecated: 18.0.0 - Use `OCA\Talk\Events\BeforeSignalingRoomPropertiesSentEvent` instead
* Removed: 19.0.0
## Inbound events to invoke Talk
### Bot install
Dispatch this event in your app to install a bot on this server
* Event: `OCA\Talk\Events\BotInstallEvent`
* Since: 17.0.0
### Bot uninstall
Dispatch this event in your app to install a bot on this server
* Event: `OCA\Talk\Events\BotUninstallEvent`
* Since: 17.0.0

23
lib/Chat/ChatManager.php

@ -27,8 +27,12 @@ namespace OCA\Talk\Chat;
use DateInterval;
use OC\Memcache\ArrayCache;
use OC\Memcache\NullCache;
use OCA\Talk\Events\BeforeChatMessageSentEvent;
use OCA\Talk\Events\BeforeSystemMessageSentEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\ChatMessageSentEvent;
use OCA\Talk\Events\ChatParticipantEvent;
use OCA\Talk\Events\SystemMessageSentEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Poll;
@ -65,10 +69,15 @@ use OCP\Share\IShare;
* pending notifications are removed if the messages are deleted.
*/
class ChatManager {
/** @deprecated */
public const EVENT_BEFORE_SYSTEM_MESSAGE_SEND = self::class . '::preSendSystemMessage';
/** @deprecated */
public const EVENT_AFTER_SYSTEM_MESSAGE_SEND = self::class . '::postSendSystemMessage';
/** @deprecated */
public const EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND = self::class . '::postSendMultipleSystemMessage';
/** @deprecated */
public const EVENT_BEFORE_MESSAGE_SEND = self::class . '::preSendMessage';
/** @deprecated */
public const EVENT_AFTER_MESSAGE_SEND = self::class . '::postSendMessage';
public const MAX_CHAT_LENGTH = 32000;
@ -158,6 +167,8 @@ class ChatManager {
$this->setMessageExpiration($chat, $comment);
$event = new BeforeSystemMessageSentEvent($chat, $comment, skipLastActivityUpdate: $shouldSkipLastMessageUpdate);
$this->dispatcher->dispatchTyped($event);
$event = new ChatEvent($chat, $comment, $shouldSkipLastMessageUpdate);
$this->dispatcher->dispatch(self::EVENT_BEFORE_SYSTEM_MESSAGE_SEND, $event);
try {
@ -185,6 +196,8 @@ class ChatManager {
}
$this->dispatcher->dispatch(self::EVENT_AFTER_SYSTEM_MESSAGE_SEND, $event);
$event = new SystemMessageSentEvent($chat, $comment, skipLastActivityUpdate: $shouldSkipLastMessageUpdate);
$this->dispatcher->dispatchTyped($event);
} catch (NotFoundException $e) {
}
$this->cache->remove($chat->getToken());
@ -208,8 +221,10 @@ class ChatManager {
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($this->timeFactory->getDateTime());
$comment->setVerb(self::VERB_MESSAGE); // Has to be comment, so it counts as unread message
$comment->setVerb(self::VERB_MESSAGE); // Has to be 'comment', so it counts as unread message
$event = new BeforeSystemMessageSentEvent($chat, $comment);
$this->dispatcher->dispatchTyped($event);
$event = new ChatEvent($chat, $comment);
$this->dispatcher->dispatch(self::EVENT_BEFORE_SYSTEM_MESSAGE_SEND, $event);
try {
@ -220,6 +235,8 @@ class ChatManager {
$this->unreadCountCache->clear($chat->getId() . '-');
$this->dispatcher->dispatch(self::EVENT_AFTER_SYSTEM_MESSAGE_SEND, $event);
$event = new SystemMessageSentEvent($chat, $comment);
$this->dispatcher->dispatchTyped($event);
} catch (NotFoundException $e) {
}
$this->cache->remove($chat->getToken());
@ -258,6 +275,8 @@ class ChatManager {
}
$this->setMessageExpiration($chat, $comment);
$event = new BeforeChatMessageSentEvent($chat, $comment, $participant, $silent);
$this->dispatcher->dispatchTyped($event);
if ($participant instanceof Participant) {
$event = new ChatParticipantEvent($chat, $comment, $participant, $silent);
} else {
@ -302,6 +321,8 @@ class ChatManager {
$this->notifier->notifyOtherParticipant($chat, $comment, $alreadyNotifiedUsers, $silent);
$this->dispatcher->dispatch(self::EVENT_AFTER_MESSAGE_SEND, $event);
$event = new ChatMessageSentEvent($chat, $comment, $participant, $silent);
$this->dispatcher->dispatchTyped($event);
} catch (NotFoundException $e) {
}
$this->cache->remove($chat->getToken());

1
lib/Chat/Command/Executor.php

@ -37,6 +37,7 @@ use OCP\IL10N;
use Psr\Log\LoggerInterface;
class Executor {
/** @deprecated Commands are deprecated, please switch to Nextcloud Talk bots */
public const EVENT_APP_EXECUTE = self::class . '::execApp';
public const PLACEHOLDER_ROOM = '{ROOM}';

4
lib/Chat/MessageParser.php

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Talk\Chat;
use OCA\Talk\Events\ChatMessageEvent;
use OCA\Talk\Events\MessageParseEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\MatterbridgeManager;
use OCA\Talk\Model\Attendee;
@ -42,6 +43,7 @@ use OCP\IUserManager;
* Helper class to get a rich message from a plain text message.
*/
class MessageParser {
/** @deprecated */
public const EVENT_MESSAGE_PARSE = self::class . '::parseMessage';
protected array $guestNames = [];
@ -72,6 +74,8 @@ class MessageParser {
$event = new ChatMessageEvent($message);
$this->dispatcher->dispatch(self::EVENT_MESSAGE_PARSE, $event);
$event = new MessageParseEvent($message->getRoom(), $message);
$this->dispatcher->dispatchTyped($event);
}
protected function setActor(Message $message): void {

3
lib/Config.php

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Events\BeforeTurnServersGetEvent;
use OCA\Talk\Events\GetTurnServersEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Service\RecordingService;
@ -342,6 +343,8 @@ class Config {
if ($withEvent) {
$event = new GetTurnServersEvent($servers);
$this->dispatcher->dispatchTyped($event);
$event = new BeforeTurnServersGetEvent($event->getServers());
$this->dispatcher->dispatchTyped($event);
$servers = $event->getServers();
}

1
lib/Controller/RoomController.php

@ -91,6 +91,7 @@ use Psr\Log\LoggerInterface;
* @psalm-import-type TalkRoom from ResponseDefinitions
*/
class RoomController extends AEnvironmentAwareController {
/** @deprecated */
public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms';
protected array $commonReadMessages = [];

13
lib/Controller/SignalingController.php

@ -28,6 +28,7 @@ namespace OCA\Talk\Controller;
use GuzzleHttp\Exception\ConnectException;
use OCA\Talk\Config;
use OCA\Talk\Events\BeforeSignalingResponseSentEvent;
use OCA\Talk\Events\SignalingEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
@ -68,6 +69,7 @@ class SignalingController extends OCSController {
/** @var int */
private const PULL_MESSAGES_TIMEOUT = 30;
/** @deprecated */
public const EVENT_BACKEND_SIGNALING_ROOMS = self::class . '::signalingBackendRoom';
public function __construct(
@ -784,8 +786,13 @@ class SignalingController extends OCSController {
$permissions[] = 'control';
}
$event = new SignalingEvent($room, $participant, $action);
$this->dispatcher->dispatch(self::EVENT_BACKEND_SIGNALING_ROOMS, $event);
$legacyEvent = new SignalingEvent($room, $participant, $action);
$this->dispatcher->dispatch(self::EVENT_BACKEND_SIGNALING_ROOMS, $legacyEvent);
$event = new BeforeSignalingResponseSentEvent($room, $participant, $action);
if ($legacyEvent->getSession()) {
$event->setSession($legacyEvent->getSession());
}
$this->dispatcher->dispatchTyped($event);
$response = [
'type' => 'room',
@ -796,7 +803,7 @@ class SignalingController extends OCSController {
'permissions' => $permissions,
],
];
if ($event->getSession()) {
if ($event->getSession() !== '') {
$response['room']['session'] = $event->getSession();
}
return new DataResponse($response);

65
lib/Events/AAttendeeRemovedEvent.php

@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Session;
use OCA\Talk\Room;
abstract class AAttendeeRemovedEvent extends RoomEvent {
public const REASON_REMOVED = 'remove';
public const REASON_REMOVED_ALL = 'remove_all';
public const REASON_LEFT = 'leave';
/**
* @param self::REASON_* $reason
* @param Session[] $sessions
*/
public function __construct(
Room $room,
protected Attendee $attendee,
protected string $reason,
protected array $sessions,
) {
parent::__construct($room);
}
public function getAttendee(): Attendee {
return $this->attendee;
}
/**
* @return self::REASON_*
*/
public function getReason(): string {
return $this->reason;
}
/**
* @return Session[]
*/
public function getSessions(): array {
return $this->sessions;
}
}

58
lib/Events/ABeforeJoinedRoomEvent.php

@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Room;
abstract class ABeforeJoinedRoomEvent extends RoomEvent {
protected bool $cancelJoin = false;
public function __construct(
Room $room,
protected string $password,
protected bool $passedPasswordProtection,
) {
parent::__construct($room);
}
public function setCancelJoin(bool $cancelJoin): void {
$this->cancelJoin = $cancelJoin;
}
public function getCancelJoin(): bool {
return $this->cancelJoin;
}
public function getPassword(): string {
return $this->password;
}
public function setPassedPasswordProtection(bool $passedPasswordProtection): void {
$this->passedPasswordProtection = $passedPasswordProtection;
}
public function getPassedPasswordProtection(): bool {
return $this->passedPasswordProtection;
}
}

42
lib/Events/ACallEndedForEveryoneEvent.php

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class ACallEndedForEveryoneEvent extends ARoomModifiedEvent {
public function __construct(
Room $room,
?Participant $actor = null,
) {
parent::__construct(
$room,
self::PROPERTY_IN_CALL,
Participant::FLAG_DISCONNECTED,
null,
$actor
);
}
}

51
lib/Events/ALobbyModifiedEvent.php

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Room;
abstract class ALobbyModifiedEvent extends ARoomModifiedEvent {
public function __construct(
Room $room,
string|int $newValue,
string|int|null $oldValue,
protected ?\DateTime $lobbyTimer,
protected bool $timerReached,
) {
parent::__construct(
$room,
self::PROPERTY_LOBBY,
$newValue,
$oldValue,
);
}
public function getLobbyTimer(): ?\DateTime {
return $this->lobbyTimer;
}
public function isTimerReached(): bool {
return $this->timerReached;
}
}

53
lib/Events/AMessageSentEvent.php

@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\Comments\IComment;
abstract class AMessageSentEvent extends RoomEvent {
public function __construct(
Room $room,
protected IComment $comment,
protected ?Participant $participant = null,
protected bool $silent = false,
) {
parent::__construct(
$room,
);
}
public function getComment(): IComment {
return $this->comment;
}
public function getParticipant(): ?Participant {
return $this->participant;
}
public function isSilentMessage(): bool {
return $this->silent;
}
}

71
lib/Events/AParticipantModifiedEvent.php

@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class AParticipantModifiedEvent extends RoomEvent {
public const PROPERTY_IN_CALL = 'inCall';
public const PROPERTY_NAME = 'name';
public const PROPERTY_PERMISSIONS = 'permissions';
public const PROPERTY_TYPE = 'type';
public const DETAIL_IN_CALL_SILENT = 'silent';
public const DETAIL_IN_CALL_END_FOR_EVERYONE = 'endForEveryone';
/**
* @param self::PROPERTY_* $property
* @param array<self::DETAIL_*, bool> $details
*/
public function __construct(
Room $room,
protected Participant $participant,
protected string $property,
protected string|int $newValue,
protected string|int|null $oldValue = null,
protected array $details = [],
) {
parent::__construct($room);
}
public function getProperty(): string {
return $this->property;
}
public function getNewValue(): string|int {
return $this->newValue;
}
public function getOldValue(): string|int|null {
return $this->oldValue;
}
/**
* @param self::DETAIL_* $detail
*/
public function getDetail(string $detail): ?bool {
return $this->details[$detail] ?? null;
}
}

76
lib/Events/ARoomModifiedEvent.php

@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class ARoomModifiedEvent extends RoomEvent {
public const PROPERTY_AVATAR = 'avatar';
public const PROPERTY_BREAKOUT_ROOM_MODE = 'breakoutRoomMode';
public const PROPERTY_BREAKOUT_ROOM_STATUS = 'breakoutRoomStatus';
public const PROPERTY_CALL_PERMISSIONS = 'callPermissions';
public const PROPERTY_CALL_RECORDING = 'callRecording';
public const PROPERTY_DEFAULT_PERMISSIONS = 'defaultPermissions';
public const PROPERTY_DESCRIPTION = 'description';
public const PROPERTY_IN_CALL = 'inCall';
public const PROPERTY_LISTABLE = 'listable';
public const PROPERTY_LOBBY = 'lobby';
public const PROPERTY_MESSAGE_EXPIRATION = 'messageExpiration';
public const PROPERTY_NAME = 'name';
public const PROPERTY_PASSWORD = 'password';
public const PROPERTY_READ_ONLY = 'readOnly';
public const PROPERTY_RECORDING_CONSENT = 'recordingConsent';
public const PROPERTY_SIP_ENABLED = 'sipEnabled';
public const PROPERTY_TYPE = 'type';
/**
* @param self::PROPERTY_* $property
*/
public function __construct(
Room $room,
protected string $property,
protected string|int $newValue,
protected string|int|null $oldValue = null,
protected ?Participant $actor = null,
) {
parent::__construct($room);
}
public function getProperty(): string {
return $this->property;
}
public function getNewValue(): string|int {
return $this->newValue;
}
public function getOldValue(): string|int|null {
return $this->oldValue;
}
public function getActor(): ?Participant {
return $this->actor;
}
}

45
lib/Events/ASessionLeftRoomEvent.php

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class ASessionLeftRoomEvent extends RoomEvent {
public function __construct(
Room $room,
protected Participant $participant,
protected bool $rejoining,
) {
parent::__construct($room);
}
public function getParticipant(): Participant {
return $this->participant;
}
public function isRejoining(): bool {
return $this->rejoining;
}
}

60
lib/Events/ASystemMessageSentEvent.php

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\Comments\IComment;
abstract class ASystemMessageSentEvent extends AMessageSentEvent {
public function __construct(
Room $room,
IComment $comment,
?Participant $participant = null,
bool $silent = false,
protected bool $skipLastActivityUpdate = false,
) {
parent::__construct(
$room,
$comment,
$participant,
$silent
);
}
/**
* If multiple messages will be posted (e.g. when adding multiple users to a room)
* we can skip the last message and last activity update until the last entry
* was created and then update with those values.
* This will replace O(n) with 1 database update.
*
* A {@see SystemMessagesMultipleSentEvent} will be triggered
* as a final event when all system messages have been created.
*
* @return bool
*/
public function shouldSkipLastActivityUpdate(): bool {
return $this->skipLastActivityUpdate;
}
}

3
lib/Events/AddEmailEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
/**
* @deprecated
*/
class AddEmailEvent extends RoomEvent {
public function __construct(

3
lib/Events/AddParticipantsEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\Comments\IComment;
/**
* @deprecated
*/
class AddParticipantsEvent extends RoomEvent {
protected ?IComment $lastMessage = null;

3
lib/Events/AlreadySharedEvent.php

@ -29,6 +29,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
use OCP\Share\IShare;
/**
* @deprecated
*/
class AlreadySharedEvent extends Event {
public function __construct(
private IShare $share,

27
lib/Events/AttendeeRemovedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class AttendeeRemovedEvent extends AAttendeeRemovedEvent {
}

30
lib/Events/AttendeesAddedEvent.php

@ -2,7 +2,7 @@
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com>
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
@ -23,5 +23,33 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
use OCP\Comments\IComment;
class AttendeesAddedEvent extends AttendeesEvent {
protected ?IComment $lastMessage = null;
/**
* @param Attendee[] $attendees
*/
public function __construct(
Room $room,
array $attendees,
protected bool $skipLastMessageUpdate = false,
) {
parent::__construct($room, $attendees);
}
public function shouldSkipLastMessageUpdate(): bool {
return $this->skipLastMessageUpdate;
}
public function setLastMessage(IComment $lastMessage): void {
$this->lastMessage = $lastMessage;
}
public function getLastMessage(): ?IComment {
return $this->lastMessage;
}
}

5
lib/Events/AttendeesEvent.php

@ -26,7 +26,10 @@ namespace OCA\Talk\Events;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
class AttendeesEvent extends RoomEvent {
abstract class AttendeesEvent extends RoomEvent {
/**
* @param Attendee[] $attendees
*/
public function __construct(
Room $room,
protected array $attendees,

27
lib/Events/BeforeAttendeeRemovedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeAttendeeRemovedEvent extends AAttendeeRemovedEvent {
}

27
lib/Events/BeforeAttendeesAddedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeAttendeesAddedEvent extends AttendeesEvent {
}

27
lib/Events/BeforeCallEndedForEveryoneEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeCallEndedForEveryoneEvent extends ACallEndedForEveryoneEvent {
}

27
lib/Events/BeforeChatMessageSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeChatMessageSentEvent extends AMessageSentEvent {
}

43
lib/Events/BeforeDuplicateShareSentEvent.php

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022, Vitor Mattos <vitor@php.rio>
*
* @author Vitor Mattos <vitor@php.rio>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
use OCP\Share\IShare;
class BeforeDuplicateShareSentEvent extends Event {
public function __construct(
private IShare $share,
) {
parent::__construct();
}
public function getShare(): IShare {
return $this->share;
}
}

41
lib/Events/BeforeEmailInvitationSentEvent.php

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
class BeforeEmailInvitationSentEvent extends RoomEvent {
public function __construct(
Room $room,
protected Attendee $attendee,
) {
parent::__construct($room);
}
public function getAttendee(): Attendee {
return $this->attendee;
}
}

27
lib/Events/BeforeGuestJoinedRoomEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeGuestJoinedRoomEvent extends ABeforeJoinedRoomEvent {
}

27
lib/Events/BeforeGuestsCleanedUpEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeGuestsCleanedUpEvent extends RoomEvent {
}

27
lib/Events/BeforeLobbyModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeLobbyModifiedEvent extends ALobbyModifiedEvent {
}

27
lib/Events/BeforeParticipantModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeParticipantModifiedEvent extends AParticipantModifiedEvent {
}

2
lib/Events/BeforeRoomModifiedEvent.php

@ -23,5 +23,5 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
class BeforeRoomModifiedEvent extends ModifyRoomEvent {
class BeforeRoomModifiedEvent extends ARoomModifiedEvent {
}

27
lib/Events/BeforeSessionLeftRoomEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeSessionLeftRoomEvent extends ASessionLeftRoomEvent {
}

51
lib/Events/BeforeSignalingResponseSentEvent.php

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
class BeforeSignalingResponseSentEvent extends ParticipantEvent {
protected mixed $session = '';
public function __construct(
Room $room,
Participant $participant,
protected string $action,
) {
parent::__construct($room, $participant);
}
public function getAction(): string {
return $this->action;
}
public function setSession(mixed $session): void {
$this->session = $session;
}
public function getSession(): mixed {
return $this->session;
}
}

27
lib/Events/BeforeSignalingRoomPropertiesSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeSignalingRoomPropertiesSentEvent extends SignalingRoomPropertiesEvent {
}

27
lib/Events/BeforeSystemMessageSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeSystemMessageSentEvent extends ASystemMessageSentEvent {
}

51
lib/Events/BeforeTurnServersGetEvent.php

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joachim Bauch <mail@joachim-bauch.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
class BeforeTurnServersGetEvent extends Event {
/**
* @param list<array{schemes?: string, server: string, protocols: string, username?: string, password?: string, secret?: string}> $servers
*/
public function __construct(
protected array $servers
) {
parent::__construct();
}
/**
* @return list<array{schemes?: string, server: string, protocols: string, username?: string, password?: string, secret?: string}>
*/
public function getServers(): array {
return $this->servers;
}
/**
* @param list<array{schemes?: string, server: string, protocols: string, username?: string, password?: string, secret?: string}> $servers
*/
public function setServers(array $servers): void {
$this->servers = $servers;
}
}

46
lib/Events/BeforeUserJoinedRoomEvent.php

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\IUser;
class BeforeUserJoinedRoomEvent extends ABeforeJoinedRoomEvent {
public function __construct(
Room $room,
protected IUser $user,
string $password,
bool $passedPasswordProtection,
) {
parent::__construct($room, $password, $passedPasswordProtection);
}
public function getUser(): IUser {
return $this->user;
}
public function getPassword(): string {
return $this->password;
}
}

57
lib/Events/CallEndedForEveryoneEvent.php

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
class CallEndedForEveryoneEvent extends ACallEndedForEveryoneEvent {
public function __construct(
Room $room,
?Participant $actor = null,
/** @var string[] */
protected array $sessionIds = [],
/** @var string[] */
protected array $userIds = [],
) {
parent::__construct(
$room,
$actor
);
}
/**
* @return string[]
*/
public function getSessionIds(): array {
return $this->sessionIds;
}
/**
* @return string[]
*/
public function getUserIds(): array {
return $this->userIds;
}
}

49
lib/Events/CallNotificationSendEvent.php

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @internal This event is not part of the public API and you should not rely on it.
*/
class CallNotificationSendEvent extends RoomEvent {
public function __construct(
Room $room,
protected Participant $actor,
protected Participant $target,
) {
parent::__construct($room);
}
public function getActor(): Participant {
return $this->actor;
}
public function getTarget(): Participant {
return $this->target;
}
}

3
lib/Events/ChatEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\Comments\IComment;
/**
* @deprecated
*/
class ChatEvent extends RoomEvent {
public function __construct(
Room $room,

3
lib/Events/ChatMessageEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Model\Message;
/**
* @deprecated
*/
class ChatMessageEvent extends ChatEvent {
public function __construct(
protected Message $message,

27
lib/Events/ChatMessageSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class ChatMessageSentEvent extends AMessageSentEvent {
}

3
lib/Events/ChatParticipantEvent.php

@ -27,6 +27,9 @@ use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\Comments\IComment;
/**
* @deprecated
*/
class ChatParticipantEvent extends ChatEvent {
public function __construct(
Room $room,

3
lib/Events/CommandEvent.php

@ -27,6 +27,9 @@ use OCA\Talk\Model\Command;
use OCA\Talk\Room;
use OCP\Comments\IComment;
/**
* @deprecated
*/
class CommandEvent extends ChatEvent {
protected string $output = '';

3
lib/Events/CreateRoomTokenEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class CreateRoomTokenEvent extends Event {
protected string $token;

3
lib/Events/DuplicatedParticipantEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class DuplicatedParticipantEvent extends ParticipantEvent {
public function __construct(
Room $room,

41
lib/Events/EmailInvitationSentEvent.php

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
class EmailInvitationSentEvent extends RoomEvent {
public function __construct(
Room $room,
protected Attendee $attendee,
) {
parent::__construct($room);
}
public function getAttendee(): Attendee {
return $this->attendee;
}
}

3
lib/Events/EndCallForEveryoneEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class EndCallForEveryoneEvent extends ModifyRoomEvent {
/** @var string[] */
protected array $sessionIds = [];

3
lib/Events/GetTurnServersEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class GetTurnServersEvent extends Event {
public function __construct(

40
lib/Events/GuestJoinedRoomEvent.php

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
class GuestJoinedRoomEvent extends RoomEvent {
public function __construct(
Room $room,
protected Participant $participant,
) {
parent::__construct($room);
}
public function getParticipant(): Participant {
return $this->participant;
}
}

27
lib/Events/GuestsCleanedUpEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class GuestsCleanedUpEvent extends RoomEvent {
}

3
lib/Events/JoinRoomGuestEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
/**
* @deprecated
*/
class JoinRoomGuestEvent extends RoomEvent {
protected bool $cancelJoin;

3
lib/Events/JoinRoomUserEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\IUser;
/**
* @deprecated
*/
class JoinRoomUserEvent extends RoomEvent {
protected bool $cancelJoin;

27
lib/Events/LobbyModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class LobbyModifiedEvent extends ALobbyModifiedEvent {
}

36
lib/Events/MessageParseEvent.php

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Model\Message;
use OCA\Talk\Room;
class MessageParseEvent extends RoomEvent {
public function __construct(
Room $room,
protected Message $message,
) {
parent::__construct($room);
}
}

3
lib/Events/ModifyEveryoneEvent.php

@ -23,5 +23,8 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
/**
* @deprecated
*/
class ModifyEveryoneEvent extends ModifyParticipantEvent {
}

3
lib/Events/ModifyLobbyEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
/**
* @deprecated Use {@see BeforeLobbyModifiedEvent} and {@see LobbyModifiedEvent} instead
*/
class ModifyLobbyEvent extends ModifyRoomEvent {
public function __construct(

3
lib/Events/ModifyParticipantEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class ModifyParticipantEvent extends ParticipantEvent {
public function __construct(

3
lib/Events/ModifyRoomEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated Use {@see BeforeRoomModifiedEvent} and {@see RoomModifiedEvent} instead
*/
class ModifyRoomEvent extends RoomEvent {
public function __construct(

3
lib/Events/ParticipantEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class ParticipantEvent extends RoomEvent {

27
lib/Events/ParticipantModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class ParticipantModifiedEvent extends AParticipantModifiedEvent {
}

3
lib/Events/RemoveParticipantEvent.php

@ -27,6 +27,9 @@ use OCA\Talk\Model\Session;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class RemoveParticipantEvent extends ParticipantEvent {
public function __construct(

3
lib/Events/RemoveUserEvent.php

@ -27,6 +27,9 @@ use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\IUser;
/**
* @deprecated
*/
class RemoveUserEvent extends RemoveParticipantEvent {
public function __construct(

27
lib/Events/RoomCreatedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class RoomCreatedEvent extends RoomEvent {
}

3
lib/Events/RoomEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class RoomEvent extends Event {

2
lib/Events/RoomModifiedEvent.php

@ -23,5 +23,5 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
class RoomModifiedEvent extends ModifyRoomEvent {
class RoomModifiedEvent extends ARoomModifiedEvent {
}

59
lib/Events/RoomPasswordVerifyEvent.php

@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Room;
class RoomPasswordVerifyEvent extends RoomEvent {
protected ?bool $isPasswordValid = null;
protected string $redirectUrl = '';
public function __construct(
Room $room,
protected string $password,
) {
parent::__construct($room);
}
public function getPassword(): string {
return $this->password;
}
public function setIsPasswordValid(bool $isPasswordValid): void {
$this->isPasswordValid = $isPasswordValid;
}
public function isPasswordValid(): ?bool {
return $this->isPasswordValid;
}
public function setRedirectUrl(string $redirectUrl): void {
$this->redirectUrl = $redirectUrl;
}
public function getRedirectUrl(): string {
return $this->redirectUrl;
}
}

3
lib/Events/SendCallNotificationEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class SendCallNotificationEvent extends RoomEvent {
public function __construct(

27
lib/Events/SessionLeftRoomEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class SessionLeftRoomEvent extends ASessionLeftRoomEvent {
}

3
lib/Events/SignalingEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
/**
* @deprecated
*/
class SignalingEvent extends ParticipantEvent {
/** @var mixed */
protected $session;

3
lib/Events/SignalingRoomPropertiesEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
/**
* @deprecated
*/
class SignalingRoomPropertiesEvent extends RoomEvent {
public function __construct(

3
lib/Events/SilentModifyParticipantEvent.php

@ -23,5 +23,8 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
/**
* @deprecated
*/
class SilentModifyParticipantEvent extends ModifyParticipantEvent {
}

27
lib/Events/SystemMessageSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class SystemMessageSentEvent extends ASystemMessageSentEvent {
}

27
lib/Events/SystemMessagesMultipleSentEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class SystemMessagesMultipleSentEvent extends ASystemMessageSentEvent {
}

3
lib/Events/UserEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class UserEvent extends Event {

46
lib/Events/UserJoinedRoomEvent.php

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\IUser;
class UserJoinedRoomEvent extends RoomEvent {
public function __construct(
Room $room,
protected IUser $user,
protected Participant $participant,
) {
parent::__construct($room);
}
public function getUser(): IUser {
return $this->user;
}
public function getParticipant(): Participant {
return $this->participant;
}
}

3
lib/Events/VerifyRoomPasswordEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
/**
* @deprecated
*/
class VerifyRoomPasswordEvent extends RoomEvent {
protected ?bool $isPasswordValid = null;
protected string $redirectUrl = '';

19
lib/GuestManager.php

@ -24,7 +24,12 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Events\AddEmailEvent;
use OCA\Talk\Events\AParticipantModifiedEvent;
use OCA\Talk\Events\BeforeEmailInvitationSentEvent;
use OCA\Talk\Events\BeforeParticipantModifiedEvent;
use OCA\Talk\Events\EmailInvitationSentEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\ParticipantModifiedEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\PollService;
@ -38,8 +43,11 @@ use OCP\Mail\IMailer;
use OCP\Util;
class GuestManager {
/** @deprecated */
public const EVENT_BEFORE_EMAIL_INVITE = self::class . '::preInviteByEmail';
/** @deprecated */
public const EVENT_AFTER_EMAIL_INVITE = self::class . '::postInviteByEmail';
/** @deprecated */
public const EVENT_AFTER_NAME_UPDATE = self::class . '::updateName';
public function __construct(
@ -63,6 +71,9 @@ class GuestManager {
public function updateName(Room $room, Participant $participant, string $displayName): void {
$attendee = $participant->getAttendee();
if ($attendee->getDisplayName() !== $displayName) {
$event = new BeforeParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_NAME, $displayName);
$this->dispatcher->dispatchTyped($event);
$this->participantService->updateDisplayNameForActor(
$attendee->getActorType(),
$attendee->getActorId(),
@ -75,8 +86,12 @@ class GuestManager {
$displayName
);
$attendee->setDisplayName($displayName);
$event = new ModifyParticipantEvent($room, $participant, 'name', $displayName);
$this->dispatcher->dispatch(self::EVENT_AFTER_NAME_UPDATE, $event);
$event = new ParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_NAME, $displayName);
$this->dispatcher->dispatchTyped($event);
}
}
@ -87,6 +102,8 @@ class GuestManager {
$email = $participant->getAttendee()->getActorId();
$pin = $participant->getAttendee()->getPin();
$event = new BeforeEmailInvitationSentEvent($room, $participant->getAttendee());
$this->dispatcher->dispatchTyped($event);
$event = new AddEmailEvent($room, $email);
$this->dispatcher->dispatch(self::EVENT_BEFORE_EMAIL_INVITE, $event);
@ -156,6 +173,8 @@ class GuestManager {
$this->mailer->send($message);
$this->dispatcher->dispatch(self::EVENT_AFTER_EMAIL_INVITE, $event);
$event = new EmailInvitationSentEvent($room, $participant->getAttendee());
$this->dispatcher->dispatchTyped($event);
} catch (\Exception $e) {
}
}

4
lib/Manager.php

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Events\RoomCreatedEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
@ -53,6 +54,7 @@ use OCP\Security\ISecureRandom;
use OCP\Server;
class Manager {
/** @deprecated */
public const EVENT_TOKEN_GENERATE = self::class . '::generateNewToken';
protected ICommentsManager $commentsManager;
@ -1063,6 +1065,8 @@ class Manager {
$event = new RoomEvent($room);
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_CREATE, $event);
$event = new RoomCreatedEvent($room);
$this->dispatcher->dispatchTyped($event);
return $room;
}

66
lib/Room.php

@ -27,6 +27,8 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Events\AAttendeeRemovedEvent;
use OCA\Talk\Events\BeforeSignalingRoomPropertiesSentEvent;
use OCA\Talk\Events\SignalingRoomPropertiesEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Model\Attendee;
@ -99,68 +101,130 @@ class Room {
public const START_CALL_MODERATORS = 2;
public const START_CALL_NOONE = 3;
/** @deprecated Use {@see AAttendeeRemovedEvent::REASON_REMOVED} instead */
public const PARTICIPANT_REMOVED = 'remove';
/** @deprecated Use {@see AAttendeeRemovedEvent::REASON_REMOVED_ALL} instead */
public const PARTICIPANT_REMOVED_ALL = 'remove_all';
/** @deprecated Use {@see AAttendeeRemovedEvent::REASON_LEFT} instead */
public const PARTICIPANT_LEFT = 'leave';
/** @deprecated */
public const EVENT_AFTER_ROOM_CREATE = self::class . '::createdRoom';
/** @deprecated */
public const EVENT_BEFORE_ROOM_DELETE = self::class . '::preDeleteRoom';
/** @deprecated */
public const EVENT_AFTER_ROOM_DELETE = self::class . '::postDeleteRoom';
/** @deprecated */
public const EVENT_BEFORE_NAME_SET = self::class . '::preSetName';
/** @deprecated */
public const EVENT_AFTER_NAME_SET = self::class . '::postSetName';
/** @deprecated */
public const EVENT_BEFORE_DESCRIPTION_SET = self::class . '::preSetDescription';
/** @deprecated */
public const EVENT_AFTER_DESCRIPTION_SET = self::class . '::postSetDescription';
/** @deprecated */
public const EVENT_BEFORE_PASSWORD_SET = self::class . '::preSetPassword';
/** @deprecated */
public const EVENT_AFTER_PASSWORD_SET = self::class . '::postSetPassword';
/** @deprecated */
public const EVENT_BEFORE_TYPE_SET = self::class . '::preSetType';
/** @deprecated */
public const EVENT_AFTER_TYPE_SET = self::class . '::postSetType';
/** @deprecated */
public const EVENT_BEFORE_READONLY_SET = self::class . '::preSetReadOnly';
/** @deprecated */
public const EVENT_AFTER_READONLY_SET = self::class . '::postSetReadOnly';
/** @deprecated */
public const EVENT_BEFORE_LISTABLE_SET = self::class . '::preSetListable';
/** @deprecated */
public const EVENT_AFTER_LISTABLE_SET = self::class . '::postSetListable';
/** @deprecated */
public const EVENT_BEFORE_LOBBY_STATE_SET = self::class . '::preSetLobbyState';
/** @deprecated */
public const EVENT_AFTER_LOBBY_STATE_SET = self::class . '::postSetLobbyState';
/** @deprecated */
public const EVENT_BEFORE_END_CALL_FOR_EVERYONE = self::class . '::preEndCallForEveryone';
/** @deprecated */
public const EVENT_AFTER_END_CALL_FOR_EVERYONE = self::class . '::postEndCallForEveryone';
/** @deprecated */
public const EVENT_BEFORE_SIP_ENABLED_SET = self::class . '::preSetSIPEnabled';
/** @deprecated */
public const EVENT_AFTER_SIP_ENABLED_SET = self::class . '::postSetSIPEnabled';
/** @deprecated */
public const EVENT_BEFORE_PERMISSIONS_SET = self::class . '::preSetPermissions';
/** @deprecated */
public const EVENT_AFTER_PERMISSIONS_SET = self::class . '::postSetPermissions';
/** @deprecated */
public const EVENT_BEFORE_USERS_ADD = self::class . '::preAddUsers';
/** @deprecated */
public const EVENT_AFTER_USERS_ADD = self::class . '::postAddUsers';
/** @deprecated */
public const EVENT_BEFORE_PARTICIPANT_TYPE_SET = self::class . '::preSetParticipantType';
/** @deprecated */
public const EVENT_AFTER_PARTICIPANT_TYPE_SET = self::class . '::postSetParticipantType';
/** @deprecated */
public const EVENT_BEFORE_PARTICIPANT_PERMISSIONS_SET = self::class . '::preSetParticipantPermissions';
/** @deprecated */
public const EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET = self::class . '::postSetParticipantPermissions';
/** @deprecated */
public const EVENT_BEFORE_USER_REMOVE = self::class . '::preRemoveUser';
/** @deprecated */
public const EVENT_AFTER_USER_REMOVE = self::class . '::postRemoveUser';
/** @deprecated */
public const EVENT_BEFORE_PARTICIPANT_REMOVE = self::class . '::preRemoveBySession';
/** @deprecated */
public const EVENT_AFTER_PARTICIPANT_REMOVE = self::class . '::postRemoveBySession';
/** @deprecated */
public const EVENT_BEFORE_ROOM_CONNECT = self::class . '::preJoinRoom';
/** @deprecated */
public const EVENT_AFTER_ROOM_CONNECT = self::class . '::postJoinRoom';
/** @deprecated */
public const EVENT_BEFORE_ROOM_DISCONNECT = self::class . '::preUserDisconnectRoom';
/** @deprecated */
public const EVENT_AFTER_ROOM_DISCONNECT = self::class . '::postUserDisconnectRoom';
/** @deprecated */
public const EVENT_BEFORE_GUEST_CONNECT = self::class . '::preJoinRoomGuest';
/** @deprecated */
public const EVENT_AFTER_GUEST_CONNECT = self::class . '::postJoinRoomGuest';
/** @deprecated */
public const EVENT_PASSWORD_VERIFY = self::class . '::verifyPassword';
/** @deprecated */
public const EVENT_BEFORE_GUESTS_CLEAN = self::class . '::preCleanGuests';
/** @deprecated */
public const EVENT_AFTER_GUESTS_CLEAN = self::class . '::postCleanGuests';
/** @deprecated */
public const EVENT_BEFORE_SESSION_JOIN_CALL = self::class . '::preSessionJoinCall';
/** @deprecated */
public const EVENT_AFTER_SESSION_JOIN_CALL = self::class . '::postSessionJoinCall';
/** @deprecated */
public const EVENT_BEFORE_SESSION_UPDATE_CALL_FLAGS = self::class . '::preSessionUpdateCallFlags';
/** @deprecated */
public const EVENT_AFTER_SESSION_UPDATE_CALL_FLAGS = self::class . '::postSessionUpdateCallFlags';
/** @deprecated */
public const EVENT_BEFORE_SESSION_LEAVE_CALL = self::class . '::preSessionLeaveCall';
/** @deprecated */
public const EVENT_AFTER_SESSION_LEAVE_CALL = self::class . '::postSessionLeaveCall';
/** @deprecated */
public const EVENT_BEFORE_SIGNALING_PROPERTIES = self::class . '::beforeSignalingProperties';
/** @deprecated */
public const EVENT_BEFORE_SET_MESSAGE_EXPIRATION = self::class . '::beforeSetMessageExpiration';
/** @deprecated */
public const EVENT_AFTER_SET_MESSAGE_EXPIRATION = self::class . '::afterSetMessageExpiration';
/** @deprecated */
public const EVENT_BEFORE_SET_BREAKOUT_ROOM_MODE = self::class . '::beforeSetBreakoutRoomMode';
/** @deprecated */
public const EVENT_AFTER_SET_BREAKOUT_ROOM_MODE = self::class . '::afterSetBreakoutRoomMode';
/** @deprecated */
public const EVENT_BEFORE_SET_BREAKOUT_ROOM_STATUS = self::class . '::beforeSetBreakoutRoomStatus';
/** @deprecated */
public const EVENT_AFTER_SET_BREAKOUT_ROOM_STATUS = self::class . '::afterSetBreakoutRoomStatus';
/** @deprecated */
public const EVENT_BEFORE_SET_CALL_RECORDING = self::class . '::beforeSetCallRecording';
/** @deprecated */
public const EVENT_AFTER_SET_CALL_RECORDING = self::class . '::afterSetCallRecording';
/** @deprecated */
public const EVENT_BEFORE_AVATAR_SET = self::class . '::preSetAvatar';
/** @deprecated */
public const EVENT_AFTER_AVATAR_SET = self::class . '::postSetAvatar';
public const DESCRIPTION_MAXIMUM_LENGTH = 500;
@ -499,6 +563,8 @@ class Room {
$event = new SignalingRoomPropertiesEvent($this, $userId, $properties);
$this->dispatcher->dispatch(self::EVENT_BEFORE_SIGNALING_PROPERTIES, $event);
$event = new BeforeSignalingRoomPropertiesSentEvent($this, $userId, $event->getProperties());
$this->dispatcher->dispatchTyped($event);
return $event->getProperties();
}

161
lib/Service/ParticipantService.php

@ -29,23 +29,41 @@ use OCA\Circles\Model\Member;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\AParticipantModifiedEvent;
use OCA\Talk\Events\AttendeeRemovedEvent;
use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\BeforeAttendeeRemovedEvent;
use OCA\Talk\Events\BeforeAttendeesAddedEvent;
use OCA\Talk\Events\BeforeCallEndedForEveryoneEvent;
use OCA\Talk\Events\BeforeFederatedUserJoinedRoomEvent;
use OCA\Talk\Events\BeforeGuestJoinedRoomEvent;
use OCA\Talk\Events\BeforeGuestsCleanedUpEvent;
use OCA\Talk\Events\BeforeParticipantModifiedEvent;
use OCA\Talk\Events\BeforeSessionLeftRoomEvent;
use OCA\Talk\Events\BeforeUserJoinedRoomEvent;
use OCA\Talk\Events\CallEndedForEveryoneEvent;
use OCA\Talk\Events\CallNotificationSendEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\DuplicatedParticipantEvent;
use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\FederatedUserJoinedRoomEvent;
use OCA\Talk\Events\GuestJoinedRoomEvent;
use OCA\Talk\Events\GuestsCleanedUpEvent;
use OCA\Talk\Events\JoinRoomGuestEvent;
use OCA\Talk\Events\JoinRoomUserEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\ParticipantEvent;
use OCA\Talk\Events\ParticipantModifiedEvent;
use OCA\Talk\Events\RemoveParticipantEvent;
use OCA\Talk\Events\RemoveUserEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Events\SendCallNotificationEvent;
use OCA\Talk\Events\SessionLeftRoomEvent;
use OCA\Talk\Events\SilentModifyParticipantEvent;
use OCA\Talk\Events\SystemMessagesMultipleSentEvent;
use OCA\Talk\Events\UserJoinedRoomEvent;
use OCA\Talk\Exceptions\CannotReachRemoteException;
use OCA\Talk\Exceptions\ForbiddenException;
use OCA\Talk\Exceptions\InvalidPasswordException;
@ -117,6 +135,8 @@ class ParticipantService {
return;
}
$event = new BeforeParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_TYPE, $participantType, $oldType);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyParticipantEvent($room, $participant, 'type', $participantType, $oldType);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PARTICIPANT_TYPE_SET, $event);
@ -179,6 +199,8 @@ class ParticipantService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $event);
$event = new ParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_TYPE, $participantType, $oldType);
$this->dispatcher->dispatchTyped($event);
}
/**
@ -215,6 +237,8 @@ class ParticipantService {
return false;
}
$event = new BeforeParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_PERMISSIONS, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyParticipantEvent($room, $participant, 'permissions', $newPermissions, $oldPermissions);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PARTICIPANT_PERMISSIONS_SET, $event);
@ -225,6 +249,8 @@ class ParticipantService {
$this->attendeeMapper->update($attendee);
$this->dispatcher->dispatch(Room::EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET, $event);
$event = new ParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_PERMISSIONS, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -292,10 +318,13 @@ class ParticipantService {
* @throws UnauthorizedException
*/
public function joinRoom(RoomService $roomService, Room $room, IUser $user, string $password, bool $passedPasswordProtection = false): Participant {
$event = new JoinRoomUserEvent($room, $user, $password, $passedPasswordProtection);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_ROOM_CONNECT, $event);
$event = new BeforeUserJoinedRoomEvent($room, $user, $password, $passedPasswordProtection);
$this->dispatcher->dispatchTyped($event);
$legacyEvent = new JoinRoomUserEvent($room, $user, $password, $event->getPassedPasswordProtection());
$legacyEvent->setCancelJoin($event->getCancelJoin());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_ROOM_CONNECT, $legacyEvent);
if ($event->getCancelJoin() === true) {
if ($legacyEvent->getCancelJoin() === true) {
$this->removeUser($room, $user, Room::PARTICIPANT_LEFT);
throw new UnauthorizedException('Participant is not allowed to join');
}
@ -307,7 +336,7 @@ class ParticipantService {
$manager = Server::get(Manager::class);
$isListableByUser = $manager->isRoomListableByUser($room, $user->getUID());
if (!$isListableByUser && !$event->getPassedPasswordProtection() && !$roomService->verifyPassword($room, $password)['result']) {
if (!$isListableByUser && !$legacyEvent->getPassedPasswordProtection() && !$roomService->verifyPassword($room, $password)['result']) {
throw new InvalidPasswordException('Provided password is invalid');
}
@ -337,10 +366,13 @@ class ParticipantService {
}
$session = $this->sessionService->createSessionForAttendee($attendee);
$participant = new Participant($room, $attendee, $session);
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_CONNECT, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_CONNECT, $legacyEvent);
$event = new UserJoinedRoomEvent($room, $user, $participant);
$this->dispatcher->dispatchTyped($event);
return new Participant($room, $attendee, $session);
return $participant;
}
/**
@ -381,14 +413,17 @@ class ParticipantService {
* @throws UnauthorizedException
*/
public function joinRoomAsNewGuest(RoomService $roomService, Room $room, string $password, bool $passedPasswordProtection = false, ?Participant $previousParticipant = null): Participant {
$event = new JoinRoomGuestEvent($room, $password, $passedPasswordProtection);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_GUEST_CONNECT, $event);
$event = new BeforeGuestJoinedRoomEvent($room, $password, $passedPasswordProtection);
$this->dispatcher->dispatchTyped($event);
$legacyEvent = new JoinRoomGuestEvent($room, $password, $event->getPassedPasswordProtection());
$legacyEvent->setCancelJoin($event->getCancelJoin());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_GUEST_CONNECT, $legacyEvent);
if ($event->getCancelJoin()) {
if ($legacyEvent->getCancelJoin()) {
throw new UnauthorizedException('Participant is not allowed to join');
}
if (!$event->getPassedPasswordProtection() && !$roomService->verifyPassword($room, $password)['result']) {
if (!$legacyEvent->getPassedPasswordProtection() && !$roomService->verifyPassword($room, $password)['result']) {
throw new InvalidPasswordException();
}
@ -423,9 +458,13 @@ class ParticipantService {
$this->attendeeMapper->update($attendee);
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUEST_CONNECT, $event);
$participant = new Participant($room, $attendee, $session);
return new Participant($room, $attendee, $session);
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUEST_CONNECT, $legacyEvent);
$event = new GuestJoinedRoomEvent($room, $participant);
$this->dispatcher->dispatchTyped($event);
return $participant;
}
/**
@ -479,12 +518,18 @@ class ParticipantService {
$attendee->setPermissions(Attendee::PERMISSIONS_DEFAULT);
$attendee->setLastReadMessage($lastMessage);
$attendee->setReadPrivacy($readPrivacy);
$attendees[] = $attendee;
}
$attendeeEvent = new BeforeAttendeesAddedEvent($room, $attendees);
$this->dispatcher->dispatchTyped($attendeeEvent);
foreach ($attendees as $attendee) {
try {
$this->attendeeMapper->insert($attendee);
$attendees[] = $attendee;
if ($attendee->getActorType() === Attendee::ACTOR_FEDERATED_USERS) {
$inviteSent = $this->backendNotifier->sendRemoteShare((string) $attendee->getId(), $participant['accessToken'], $participant['actorId'], $addedBy->getDisplayName(), $addedBy->getCloudId(), 'user', $room, $this->getHighestPermissionAttendee($room));
$inviteSent = $this->backendNotifier->sendRemoteShare((string) $attendee->getId(), $attendee->getAccessToken(), $attendee->getActorId(), $addedBy->getDisplayName(), $addedBy->getCloudId(), 'user', $room, $this->getHighestPermissionAttendee($room));
if (!$inviteSent) {
$this->attendeeMapper->delete($attendee);
throw new CannotReachRemoteException();
@ -497,16 +542,17 @@ class ParticipantService {
}
}
if (!empty($attendees)) {
$attendeeEvent = new AttendeesAddedEvent($room, $attendees);
$this->dispatcher->dispatchTyped($attendeeEvent);
$attendeeEvent = new AttendeesAddedEvent($room, $attendees, true);
$this->dispatcher->dispatchTyped($attendeeEvent);
if ($attendeeEvent->getLastMessage()) {
$event->setLastMessage($attendeeEvent->getLastMessage());
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_USERS_ADD, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_USERS_ADD, $event);
$lastMessage = $event->getLastMessage();
if ($lastMessage instanceof IComment) {
$this->updateRoomLastMessage($room, $lastMessage);
}
$lastMessage = $event->getLastMessage();
if ($lastMessage instanceof IComment) {
$this->updateRoomLastMessage($room, $lastMessage);
}
}
@ -522,6 +568,8 @@ class ParticipantService {
$event = new ChatEvent($room, $message);
$this->dispatcher->dispatch(ChatManager::EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND, $event);
$event = new SystemMessagesMultipleSentEvent($room, $message);
$this->dispatcher->dispatchTyped($event);
}
public function getHighestPermissionAttendee(Room $room): ?Attendee {
@ -773,6 +821,8 @@ class ParticipantService {
}
public function leaveRoomAsSession(Room $room, Participant $participant, bool $duplicatedParticipant = false): void {
$event = new BeforeSessionLeftRoomEvent($room, $participant, $duplicatedParticipant);
$this->dispatcher->dispatchTyped($event);
if ($duplicatedParticipant) {
$event = new DuplicatedParticipantEvent($room, $participant);
} else {
@ -793,6 +843,8 @@ class ParticipantService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_DISCONNECT, $event);
$event = new SessionLeftRoomEvent($room, $participant, $duplicatedParticipant);
$this->dispatcher->dispatchTyped($event);
if ($participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED
&& empty($this->sessionMapper->findByAttendeeId($participant->getAttendee()->getId()))) {
@ -818,6 +870,9 @@ class ParticipantService {
);
}
$event = new BeforeAttendeeRemovedEvent($room, $participant->getAttendee(), $reason, $sessions);
$this->dispatcher->dispatchTyped($event);
if ($isUser) {
$user = $this->userManager->get($participant->getAttendee()->getActorId());
$event = new RemoveUserEvent($room, $participant, $user, $reason, $sessions);
@ -830,16 +885,18 @@ class ParticipantService {
$this->sessionMapper->deleteByAttendeeId($participant->getAttendee()->getId());
$this->attendeeMapper->delete($participant->getAttendee());
if (!$attendeeEventIsTriggeredAlready) {
$attendeeEvent = new AttendeesRemovedEvent($room, [$participant->getAttendee()]);
$this->dispatcher->dispatchTyped($attendeeEvent);
}
if ($isUser) {
$this->dispatcher->dispatch(Room::EVENT_AFTER_USER_REMOVE, $event);
} else {
$this->dispatcher->dispatch(Room::EVENT_AFTER_PARTICIPANT_REMOVE, $event);
}
$event = new AttendeeRemovedEvent($room, $participant->getAttendee(), $reason, $sessions);
$this->dispatcher->dispatchTyped($event);
if (!$attendeeEventIsTriggeredAlready) {
$attendeeEvent = new AttendeesRemovedEvent($room, [$participant->getAttendee()]);
$this->dispatcher->dispatchTyped($attendeeEvent);
}
if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_GROUPS) {
$this->removeGroupMembers($room, $participant, $reason);
@ -967,6 +1024,9 @@ class ParticipantService {
$reason = Room::PARTICIPANT_REMOVED;
}
$attendeeEvent = new BeforeAttendeeRemovedEvent($room, $attendee, $reason, $sessions);
$this->dispatcher->dispatchTyped($attendeeEvent);
$event = new RemoveUserEvent($room, $participant, $user, $reason, $sessions);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_USER_REMOVE, $event);
@ -976,6 +1036,9 @@ class ParticipantService {
$this->attendeeMapper->delete($attendee);
$attendeeEvent = new AttendeeRemovedEvent($room, $attendee, $reason, $sessions);
$this->dispatcher->dispatchTyped($attendeeEvent);
$attendeeEvent = new AttendeesRemovedEvent($room, [$attendee]);
$this->dispatcher->dispatchTyped($attendeeEvent);
@ -983,6 +1046,8 @@ class ParticipantService {
}
public function cleanGuestParticipants(Room $room): void {
$event = new BeforeGuestsCleanedUpEvent($room);
$this->dispatcher->dispatchTyped($event);
$event = new RoomEvent($room);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_GUESTS_CLEAN, $event);
@ -1044,9 +1109,13 @@ class ParticipantService {
$this->dispatcher->dispatchTyped($attendeeEvent);
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUESTS_CLEAN, $event);
$event = new GuestsCleanedUpEvent($room);
$this->dispatcher->dispatchTyped($event);
}
public function endCallForEveryone(Room $room, Participant $moderator): void {
$event = new BeforeCallEndedForEveryoneEvent($room, $moderator);
$this->dispatcher->dispatchTyped($event);
$event = new EndCallForEveryoneEvent($room, $moderator);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_END_CALL_FOR_EVERYONE, $event);
@ -1069,6 +1138,8 @@ class ParticipantService {
$event->setUserIds($changedUserIds);
$this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event);
$event = new CallEndedForEveryoneEvent($room, $moderator, $changedSessionIds, $changedUserIds);
$this->dispatcher->dispatchTyped($event);
}
public function changeInCall(Room $room, Participant $participant, int $flags, bool $endCallForEveryone = false, bool $silent = false): bool {
@ -1089,22 +1160,30 @@ class ParticipantService {
$flags &= ~Participant::FLAG_WITH_VIDEO;
}
$oldFlags = $session->getInCall();
$details = [];
if ($flags !== Participant::FLAG_DISCONNECTED) {
if ($silent) {
$event = new SilentModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$legacyEvent = new SilentModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$details = [AParticipantModifiedEvent::DETAIL_IN_CALL_SILENT => $silent];
} else {
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$legacyEvent = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
}
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $event);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $legacyEvent);
} else {
if ($endCallForEveryone) {
$event = new ModifyEveryoneEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$legacyEvent = new ModifyEveryoneEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$details = [AParticipantModifiedEvent::DETAIL_IN_CALL_END_FOR_EVERYONE => $endCallForEveryone];
} else {
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$legacyEvent = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
}
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_LEAVE_CALL, $event);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_LEAVE_CALL, $legacyEvent);
}
$event = new BeforeParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_IN_CALL, $flags, $oldFlags, $details);
$this->dispatcher->dispatchTyped($event);
$session->setInCall($flags);
if (!$endCallForEveryone) {
$this->sessionMapper->update($session);
@ -1117,10 +1196,12 @@ class ParticipantService {
}
if ($flags !== Participant::FLAG_DISCONNECTED) {
$this->dispatcher->dispatch(Room::EVENT_AFTER_SESSION_JOIN_CALL, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SESSION_JOIN_CALL, $legacyEvent);
} else {
$this->dispatcher->dispatch(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $legacyEvent);
}
$event = new ParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_IN_CALL, $flags, $oldFlags, $details);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -1138,11 +1219,14 @@ class ParticipantService {
}
}
$target = new Participant($room, $attendee, null);
$this->dispatcher->dispatchTyped(new SendCallNotificationEvent(
$room,
$currentParticipant,
new Participant($room, $attendee, null)
$target
));
$event = new CallNotificationSendEvent($room, $currentParticipant, $target);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -1169,6 +1253,9 @@ class ParticipantService {
$flags &= ~Participant::FLAG_WITH_VIDEO;
}
$oldFlags = $session->getInCall();
$event = new BeforeParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_IN_CALL, $flags, $oldFlags);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_UPDATE_CALL_FLAGS, $event);
@ -1176,6 +1263,8 @@ class ParticipantService {
$this->sessionMapper->update($session);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SESSION_UPDATE_CALL_FLAGS, $event);
$event = new ParticipantModifiedEvent($room, $participant, AParticipantModifiedEvent::PROPERTY_IN_CALL, $flags, $oldFlags);
$this->dispatcher->dispatchTyped($event);
}
/**

95
lib/Service/RoomService.php

@ -25,13 +25,17 @@ namespace OCA\Talk\Service;
use InvalidArgumentException;
use OCA\Talk\Config;
use OCA\Talk\Events\ARoomModifiedEvent;
use OCA\Talk\Events\BeforeLobbyModifiedEvent;
use OCA\Talk\Events\BeforeRoomDeletedEvent;
use OCA\Talk\Events\BeforeRoomModifiedEvent;
use OCA\Talk\Events\LobbyModifiedEvent;
use OCA\Talk\Events\ModifyLobbyEvent;
use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Events\RoomDeletedEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Events\RoomModifiedEvent;
use OCA\Talk\Events\RoomPasswordVerifyEvent;
use OCA\Talk\Events\VerifyRoomPasswordEvent;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
@ -185,8 +189,10 @@ class RoomService {
}
if ($level === 'default') {
$property = ARoomModifiedEvent::PROPERTY_DEFAULT_PERMISSIONS;
$oldPermissions = $room->getDefaultPermissions();
} elseif ($level === 'call') {
$property = ARoomModifiedEvent::PROPERTY_CALL_PERMISSIONS;
$oldPermissions = $room->getCallPermissions();
} else {
return false;
@ -209,6 +215,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, $property, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, $level . 'Permissions', $newPermissions, $oldPermissions);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PERMISSIONS_SET, $event);
@ -231,6 +239,8 @@ class RoomService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_PERMISSIONS_SET, $event);
$event = new RoomModifiedEvent($room, $property, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -258,6 +268,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_SIP_ENABLED, $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'sipEnabled', $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SIP_ENABLED_SET, $event);
@ -270,6 +282,8 @@ class RoomService {
$room->setSIPEnabled($newSipEnabled);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SIP_ENABLED_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_SIP_ENABLED, $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -301,7 +315,7 @@ class RoomService {
throw new InvalidArgumentException('breakout-room');
}
$event = new BeforeRoomModifiedEvent($room, 'recordingConsent', $recordingConsent, $oldRecordingConsent);
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT, $recordingConsent, $oldRecordingConsent);
$this->dispatcher->dispatchTyped($event);
$now = $this->timeFactory->getDateTime();
@ -316,7 +330,7 @@ class RoomService {
$room->setRecordingConsent($recordingConsent);
$room->setLastActivity($now);
$event = new RoomModifiedEvent($room, 'recordingConsent', $recordingConsent, $oldRecordingConsent);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT, $recordingConsent, $oldRecordingConsent);
$this->dispatcher->dispatchTyped($event);
// Update the recording consent for all rooms
@ -339,6 +353,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_NAME, $newName, $oldName);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'name', $newName, $oldName);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_NAME_SET, $event);
@ -351,6 +367,8 @@ class RoomService {
$room->setName($newName);
$this->dispatcher->dispatch(Room::EVENT_AFTER_NAME_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_NAME, $newName, $oldName);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -381,9 +399,11 @@ class RoomService {
return false;
}
$event = new ModifyLobbyEvent($room, 'lobby', $newState, $oldState, $dateTime, $timerReached);
$legacyEvent = new ModifyLobbyEvent($room, 'lobby', $newState, $oldState, $dateTime, $timerReached);
if ($dispatchEvents) {
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LOBBY_STATE_SET, $event);
$event = new BeforeLobbyModifiedEvent($room, $newState, $oldState, $dateTime, $timerReached);
$this->dispatcher->dispatchTyped($event);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LOBBY_STATE_SET, $legacyEvent);
}
$update = $this->db->getQueryBuilder();
@ -397,7 +417,9 @@ class RoomService {
$room->setLobbyTimer($dateTime);
if ($dispatchEvents) {
$this->dispatcher->dispatch(Room::EVENT_AFTER_LOBBY_STATE_SET, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_LOBBY_STATE_SET, $legacyEvent);
$event = new LobbyModifiedEvent($room, $newState, $oldState, $dateTime, $timerReached);
$this->dispatcher->dispatchTyped($event);
}
return true;
@ -408,6 +430,9 @@ class RoomService {
return false;
}
$oldAvatar = $room->getAvatar();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_AVATAR, $avatar, $oldAvatar);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'avatar', $avatar, $room->getAvatar());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_AVATAR_SET, $event);
@ -420,6 +445,8 @@ class RoomService {
$room->setAvatar($avatar);
$this->dispatcher->dispatch(Room::EVENT_AFTER_AVATAR_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_AVATAR, $avatar, $oldAvatar);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -442,6 +469,8 @@ class RoomService {
}
$oldStatus = $room->getCallRecording();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_CALL_RECORDING, $status, $oldStatus, $participant);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'callRecording', $status, $oldStatus, $participant);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_CALL_RECORDING, $event);
@ -454,6 +483,8 @@ class RoomService {
$room->setCallRecording($status);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_CALL_RECORDING, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_CALL_RECORDING, $status, $oldStatus, $participant);
$this->dispatcher->dispatchTyped($event);
}
/**
@ -497,6 +528,8 @@ class RoomService {
$oldType = $room->getType();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_TYPE, $newType, $oldType);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'type', $newType, $oldType);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_TYPE_SET, $event);
@ -518,6 +551,8 @@ class RoomService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_TYPE_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_TYPE, $newType, $oldType);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -547,6 +582,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_READ_ONLY, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'readOnly', $newState, $oldState);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_READONLY_SET, $event);
@ -559,6 +596,8 @@ class RoomService {
$room->setReadOnly($newState);
$this->dispatcher->dispatch(Room::EVENT_AFTER_READONLY_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_READ_ONLY, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -592,6 +631,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_LISTABLE, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'listable', $newState, $oldState);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LISTABLE_SET, $event);
@ -604,6 +645,8 @@ class RoomService {
$room->setListable($newState);
$this->dispatcher->dispatch(Room::EVENT_AFTER_LISTABLE_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_LISTABLE, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -643,6 +686,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_DESCRIPTION, $description, $oldDescription);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'description', $description, $oldDescription);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_DESCRIPTION_SET, $event);
@ -655,6 +700,8 @@ class RoomService {
$room->setDescription($description);
$this->dispatcher->dispatch(Room::EVENT_AFTER_DESCRIPTION_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_DESCRIPTION, $description, $oldDescription);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -680,6 +727,8 @@ class RoomService {
$hash = $password !== '' ? $this->hasher->hash($password) : '';
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_PASSWORD, $password);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'password', $password);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PASSWORD_SET, $event);
@ -692,18 +741,31 @@ class RoomService {
$room->setPassword($hash);
$this->dispatcher->dispatch(Room::EVENT_AFTER_PASSWORD_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_PASSWORD, $password);
$this->dispatcher->dispatchTyped($event);
return true;
}
/**
* @return array{result: ?bool, url: string}
*/
public function verifyPassword(Room $room, string $password): array {
$event = new VerifyRoomPasswordEvent($room, $password);
$this->dispatcher->dispatch(Room::EVENT_PASSWORD_VERIFY, $event);
$event = new RoomPasswordVerifyEvent($room, $password);
$this->dispatcher->dispatchTyped($event);
$legacyEvent = new VerifyRoomPasswordEvent($room, $password);
if ($event->isPasswordValid() !== null) {
$legacyEvent->setIsPasswordValid($event->isPasswordValid());
}
$legacyEvent->setRedirectUrl($event->getRedirectUrl());
$this->dispatcher->dispatch(Room::EVENT_PASSWORD_VERIFY, $legacyEvent);
if ($legacyEvent->isPasswordValid() !== null) {
return [
'result' => $event->isPasswordValid(),
'url' => $event->getRedirectUrl(),
'result' => $legacyEvent->isPasswordValid(),
'url' => $legacyEvent->getRedirectUrl(),
];
}
@ -721,6 +783,9 @@ class RoomService {
throw new \InvalidArgumentException('room');
}
$oldExpiration = $room->getMessageExpiration();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_MESSAGE_EXPIRATION, $seconds, $oldExpiration);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'messageExpiration', $seconds);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_MESSAGE_EXPIRATION, $event);
@ -733,6 +798,8 @@ class RoomService {
$room->setMessageExpiration($seconds);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_MESSAGE_EXPIRATION, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_MESSAGE_EXPIRATION, $seconds, $oldExpiration);
$this->dispatcher->dispatchTyped($event);
}
public function setBreakoutRoomMode(Room $room, int $mode): bool {
@ -745,6 +812,9 @@ class RoomService {
return false;
}
$oldMode = $room->getBreakoutRoomMode();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_MODE, $mode, $oldMode);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'breakoutRoomMode', $mode);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_BREAKOUT_ROOM_MODE, $event);
@ -757,6 +827,8 @@ class RoomService {
$room->setBreakoutRoomMode($mode);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_BREAKOUT_ROOM_MODE, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_MODE, $mode, $oldMode);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -771,6 +843,9 @@ class RoomService {
return false;
}
$oldStatus = $room->getBreakoutRoomStatus();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_STATUS, $status, $oldStatus);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'breakoutRoomStatus', $status);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_BREAKOUT_ROOM_STATUS, $event);
@ -783,6 +858,8 @@ class RoomService {
$room->setBreakoutRoomStatus($status);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_BREAKOUT_ROOM_STATUS, $event);
$oldStatus = $room->getBreakoutRoomStatus();
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_STATUS, $status, $oldStatus);
return true;
}

4
lib/Share/RoomShareProvider.php

@ -30,6 +30,7 @@ namespace OCA\Talk\Share;
use OC\Files\Cache\Cache;
use OCA\Talk\Events\AlreadySharedEvent;
use OCA\Talk\Events\BeforeDuplicateShareSentEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
@ -73,6 +74,7 @@ class RoomShareProvider implements IShareProvider {
public const TALK_FOLDER = '/Talk';
public const TALK_FOLDER_PLACEHOLDER = '/{TALK_PLACEHOLDER}';
/** @deprecated */
public const EVENT_SHARE_FILE_AGAIN = self::class . '::shareFileAgain';
private CappedMemoryCache $sharesByIdCache;
@ -153,6 +155,8 @@ class RoomShareProvider implements IShareProvider {
if ($existingShare->getSharedWith() === $share->getSharedWith()) {
// FIXME Should be moved away from GenericEvent as soon as OCP\Share20\IManager did move too
$this->dispatcher->dispatch(self::EVENT_SHARE_FILE_AGAIN, new AlreadySharedEvent($existingShare));
$event = new BeforeDuplicateShareSentEvent($existingShare);
$this->dispatcher->dispatchTyped($event);
throw new GenericShareException('Already shared', $this->l->t('Path is already shared with this room'), 403);
}
}

68
tests/php/EventDocumentationTest.php

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Tests\Unit;
use Test\TestCase;
class EventDocumentationTest extends TestCase {
public static function dataEventDocumentation(): array {
$dir = new \DirectoryIterator(__DIR__ . '/../../lib/Events');
$data = [];
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
$data[] = ['OCA\\Talk\\Events\\' . substr($fileinfo->getFilename(), 0, -4)];
}
}
sort($data);
return $data;
}
/**
* @dataProvider dataEventDocumentation
* @param string $eventClass
*/
public function testEventDocumentation(string $eventClass): void {
$reflectionClass = new \ReflectionClass($eventClass);
if ($reflectionClass->isAbstract()) {
self::assertTrue(true, 'Abstract event class ' . $eventClass . ' does not have to be documented');
return;
}
$classDocBlock = $reflectionClass->getDocComment();
if (is_string($classDocBlock) && str_contains($classDocBlock, '@deprecated')) {
self::assertTrue(true, 'Deprecated event ' . $eventClass . ' does not have to be documented');
return;
}
$docs = file_get_contents(__DIR__ . '/../../docs/events.md');
$eventIsDocumented = str_contains($docs, 'Before event: `' . $eventClass . '`')
|| str_contains($docs, 'After event: `' . $eventClass . '`')
|| str_contains($docs, 'Final event: `' . $eventClass . '`')
|| str_contains($docs, 'Event: `' . $eventClass . '`');
self::assertTrue($eventIsDocumented, 'Asserting that event ' . $eventClass . ' is documented');
}
}
Loading…
Cancel
Save