onyxcord 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.devcontainer/Dockerfile +13 -0
- data/.devcontainer/devcontainer.json +29 -0
- data/.devcontainer/postcreate.sh +4 -0
- data/.github/CONTRIBUTING.md +13 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- data/.github/pull_request_template.md +37 -0
- data/.github/workflows/ci.yml +78 -0
- data/.github/workflows/codeql.yml +65 -0
- data/.github/workflows/deploy.yml +54 -0
- data/.github/workflows/release.yml +51 -0
- data/.gitignore +16 -0
- data/.markdownlint.json +4 -0
- data/.overcommit.yml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +129 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +305 -0
- data/Rakefile +17 -0
- data/bin/console +15 -0
- data/bin/setup +7 -0
- data/lib/onyxcord/allowed_mentions.rb +43 -0
- data/lib/onyxcord/api/application.rb +316 -0
- data/lib/onyxcord/api/channel.rb +700 -0
- data/lib/onyxcord/api/interaction.rb +67 -0
- data/lib/onyxcord/api/invite.rb +44 -0
- data/lib/onyxcord/api/server.rb +775 -0
- data/lib/onyxcord/api/user.rb +158 -0
- data/lib/onyxcord/api/webhook.rb +163 -0
- data/lib/onyxcord/api.rb +335 -0
- data/lib/onyxcord/await.rb +51 -0
- data/lib/onyxcord/bot.rb +1971 -0
- data/lib/onyxcord/cache.rb +326 -0
- data/lib/onyxcord/colour_rgb.rb +43 -0
- data/lib/onyxcord/commands/command_bot.rb +511 -0
- data/lib/onyxcord/commands/container.rb +112 -0
- data/lib/onyxcord/commands/events.rb +11 -0
- data/lib/onyxcord/commands/parser.rb +327 -0
- data/lib/onyxcord/commands/rate_limiter.rb +144 -0
- data/lib/onyxcord/configuration.rb +125 -0
- data/lib/onyxcord/container.rb +988 -0
- data/lib/onyxcord/data/activity.rb +271 -0
- data/lib/onyxcord/data/application.rb +341 -0
- data/lib/onyxcord/data/attachment.rb +91 -0
- data/lib/onyxcord/data/audit_logs.rb +438 -0
- data/lib/onyxcord/data/avatar_decoration.rb +26 -0
- data/lib/onyxcord/data/call.rb +22 -0
- data/lib/onyxcord/data/channel.rb +1355 -0
- data/lib/onyxcord/data/channel_tag.rb +69 -0
- data/lib/onyxcord/data/collectibles.rb +47 -0
- data/lib/onyxcord/data/component.rb +583 -0
- data/lib/onyxcord/data/embed.rb +258 -0
- data/lib/onyxcord/data/emoji.rb +123 -0
- data/lib/onyxcord/data/install_params.rb +24 -0
- data/lib/onyxcord/data/integration.rb +144 -0
- data/lib/onyxcord/data/interaction.rb +1141 -0
- data/lib/onyxcord/data/invite.rb +137 -0
- data/lib/onyxcord/data/member.rb +528 -0
- data/lib/onyxcord/data/message.rb +612 -0
- data/lib/onyxcord/data/message_activity.rb +41 -0
- data/lib/onyxcord/data/overwrite.rb +109 -0
- data/lib/onyxcord/data/poll.rb +365 -0
- data/lib/onyxcord/data/primary_server.rb +60 -0
- data/lib/onyxcord/data/profile.rb +79 -0
- data/lib/onyxcord/data/reaction.rb +64 -0
- data/lib/onyxcord/data/recipient.rb +34 -0
- data/lib/onyxcord/data/role.rb +449 -0
- data/lib/onyxcord/data/role_connection_data.rb +69 -0
- data/lib/onyxcord/data/role_subscription.rb +41 -0
- data/lib/onyxcord/data/scheduled_event.rb +513 -0
- data/lib/onyxcord/data/server.rb +1614 -0
- data/lib/onyxcord/data/server_preview.rb +68 -0
- data/lib/onyxcord/data/snapshot.rb +112 -0
- data/lib/onyxcord/data/team.rb +98 -0
- data/lib/onyxcord/data/timestamp.rb +69 -0
- data/lib/onyxcord/data/user.rb +324 -0
- data/lib/onyxcord/data/voice_region.rb +46 -0
- data/lib/onyxcord/data/voice_state.rb +41 -0
- data/lib/onyxcord/data/webhook.rb +238 -0
- data/lib/onyxcord/data.rb +57 -0
- data/lib/onyxcord/errors.rb +246 -0
- data/lib/onyxcord/event_executor.rb +80 -0
- data/lib/onyxcord/events/await.rb +48 -0
- data/lib/onyxcord/events/bans.rb +60 -0
- data/lib/onyxcord/events/channels.rb +225 -0
- data/lib/onyxcord/events/generic.rb +129 -0
- data/lib/onyxcord/events/guilds.rb +269 -0
- data/lib/onyxcord/events/integrations.rb +100 -0
- data/lib/onyxcord/events/interactions.rb +624 -0
- data/lib/onyxcord/events/invites.rb +127 -0
- data/lib/onyxcord/events/lifetime.rb +31 -0
- data/lib/onyxcord/events/members.rb +110 -0
- data/lib/onyxcord/events/message.rb +399 -0
- data/lib/onyxcord/events/polls.rb +118 -0
- data/lib/onyxcord/events/presence.rb +131 -0
- data/lib/onyxcord/events/raw.rb +74 -0
- data/lib/onyxcord/events/reactions.rb +218 -0
- data/lib/onyxcord/events/roles.rb +87 -0
- data/lib/onyxcord/events/scheduled_events.rb +171 -0
- data/lib/onyxcord/events/threads.rb +100 -0
- data/lib/onyxcord/events/typing.rb +73 -0
- data/lib/onyxcord/events/voice_server_update.rb +48 -0
- data/lib/onyxcord/events/voice_state_update.rb +106 -0
- data/lib/onyxcord/events/webhooks.rb +65 -0
- data/lib/onyxcord/gateway.rb +890 -0
- data/lib/onyxcord/id_object.rb +39 -0
- data/lib/onyxcord/light/data.rb +62 -0
- data/lib/onyxcord/light/integrations.rb +73 -0
- data/lib/onyxcord/light/light_bot.rb +58 -0
- data/lib/onyxcord/light.rb +8 -0
- data/lib/onyxcord/logger.rb +120 -0
- data/lib/onyxcord/message_components.rb +70 -0
- data/lib/onyxcord/paginator.rb +60 -0
- data/lib/onyxcord/permissions.rb +255 -0
- data/lib/onyxcord/rate_limiter/gateway.rb +42 -0
- data/lib/onyxcord/rate_limiter/rest.rb +89 -0
- data/lib/onyxcord/version.rb +7 -0
- data/lib/onyxcord/voice/encoder.rb +115 -0
- data/lib/onyxcord/voice/network.rb +380 -0
- data/lib/onyxcord/voice/opcodes.rb +29 -0
- data/lib/onyxcord/voice/sodium.rb +157 -0
- data/lib/onyxcord/voice/timer.rb +19 -0
- data/lib/onyxcord/voice/voice_bot.rb +386 -0
- data/lib/onyxcord/webhooks.rb +14 -0
- data/lib/onyxcord/websocket.rb +62 -0
- data/lib/onyxcord.rb +180 -0
- data/onyxcord-webhooks.gemspec +30 -0
- data/onyxcord.gemspec +50 -0
- metadata +421 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/events/generic'
|
|
4
|
+
require 'onyxcord/data'
|
|
5
|
+
|
|
6
|
+
module OnyxCord::Events
|
|
7
|
+
# Generic subclass for server events (create/update/delete)
|
|
8
|
+
class ServerEvent < Event
|
|
9
|
+
# @return [Server] the server in question.
|
|
10
|
+
attr_reader :server
|
|
11
|
+
|
|
12
|
+
# @!visibility private
|
|
13
|
+
def initialize(data, bot)
|
|
14
|
+
@bot = bot
|
|
15
|
+
|
|
16
|
+
init_server(data, bot)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Initializes this event with server data. Should be overwritten in case the server doesn't exist at the time
|
|
20
|
+
# of event creation (e. g. {ServerDeleteEvent})
|
|
21
|
+
def init_server(data, bot)
|
|
22
|
+
@server = bot.server(data['id'].to_i)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Generic event handler for member events
|
|
27
|
+
class ServerEventHandler < EventHandler
|
|
28
|
+
def matches?(event)
|
|
29
|
+
# Check for the proper event type
|
|
30
|
+
return false unless event.is_a? ServerEvent
|
|
31
|
+
|
|
32
|
+
[
|
|
33
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
34
|
+
a == case a
|
|
35
|
+
when String
|
|
36
|
+
e.name
|
|
37
|
+
when Integer
|
|
38
|
+
e.id
|
|
39
|
+
else
|
|
40
|
+
e
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
].reduce(true, &:&)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Server is created
|
|
48
|
+
# @see OnyxCord::EventContainer#server_create
|
|
49
|
+
class ServerCreateEvent < ServerEvent; end
|
|
50
|
+
|
|
51
|
+
# Event handler for {ServerCreateEvent}
|
|
52
|
+
class ServerCreateEventHandler < ServerEventHandler; end
|
|
53
|
+
|
|
54
|
+
# Server is updated (e.g. name changed)
|
|
55
|
+
# @see OnyxCord::EventContainer#server_update
|
|
56
|
+
class ServerUpdateEvent < ServerEvent; end
|
|
57
|
+
|
|
58
|
+
# Event handler for {ServerUpdateEvent}
|
|
59
|
+
class ServerUpdateEventHandler < ServerEventHandler; end
|
|
60
|
+
|
|
61
|
+
# Server is deleted, the server was left because the bot was kicked, or the
|
|
62
|
+
# bot made itself leave the server.
|
|
63
|
+
# @see OnyxCord::EventContainer#server_delete
|
|
64
|
+
class ServerDeleteEvent < ServerEvent
|
|
65
|
+
# @return [Integer] The ID of the server that was left.
|
|
66
|
+
attr_reader :server
|
|
67
|
+
|
|
68
|
+
# @!visibility private
|
|
69
|
+
# @note Override init_server to account for the deleted server
|
|
70
|
+
def init_server(data, _bot)
|
|
71
|
+
@server = data['id'].to_i
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Event handler for {ServerDeleteEvent}
|
|
76
|
+
class ServerDeleteEventHandler < ServerEventHandler; end
|
|
77
|
+
|
|
78
|
+
# Emoji is created/deleted/updated
|
|
79
|
+
class ServerEmojiChangeEvent < ServerEvent
|
|
80
|
+
# @return [Server] the server in question.
|
|
81
|
+
attr_reader :server
|
|
82
|
+
|
|
83
|
+
# @return [Array<Emoji>] array of emojis.
|
|
84
|
+
attr_reader :emoji
|
|
85
|
+
|
|
86
|
+
# @!visibility private
|
|
87
|
+
def initialize(server, data, bot)
|
|
88
|
+
@bot = bot
|
|
89
|
+
@server = server
|
|
90
|
+
process_emoji(data)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @!visibility private
|
|
94
|
+
def process_emoji(data)
|
|
95
|
+
@emoji = data['emojis'].map do |e|
|
|
96
|
+
@server.emoji[e['id']]
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Generic event helper for when an emoji is either created or deleted
|
|
102
|
+
class ServerEmojiCDEvent < ServerEvent
|
|
103
|
+
# @return [Server] the server in question.
|
|
104
|
+
attr_reader :server
|
|
105
|
+
|
|
106
|
+
# @return [Emoji] the emoji data.
|
|
107
|
+
attr_reader :emoji
|
|
108
|
+
|
|
109
|
+
# @!visibility private
|
|
110
|
+
def initialize(server, emoji, bot)
|
|
111
|
+
@bot = bot
|
|
112
|
+
@emoji = emoji
|
|
113
|
+
@server = server
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Emoji is created
|
|
118
|
+
class ServerEmojiCreateEvent < ServerEmojiCDEvent; end
|
|
119
|
+
|
|
120
|
+
# Emoji is deleted
|
|
121
|
+
class ServerEmojiDeleteEvent < ServerEmojiCDEvent; end
|
|
122
|
+
|
|
123
|
+
# Emoji is updated
|
|
124
|
+
class ServerEmojiUpdateEvent < ServerEvent
|
|
125
|
+
# @return [Server] the server in question.
|
|
126
|
+
attr_reader :server
|
|
127
|
+
|
|
128
|
+
# @return [Emoji, nil] the emoji data before the event.
|
|
129
|
+
attr_reader :old_emoji
|
|
130
|
+
|
|
131
|
+
# @return [Emoji, nil] the updated emoji data.
|
|
132
|
+
attr_reader :emoji
|
|
133
|
+
|
|
134
|
+
# @!visibility private
|
|
135
|
+
def initialize(server, old_emoji, emoji, bot)
|
|
136
|
+
@bot = bot
|
|
137
|
+
@old_emoji = old_emoji
|
|
138
|
+
@emoji = emoji
|
|
139
|
+
@server = server
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Event handler for {ServerEmojiChangeEvent}
|
|
144
|
+
class ServerEmojiChangeEventHandler < ServerEventHandler; end
|
|
145
|
+
|
|
146
|
+
# Generic handler for emoji create and delete
|
|
147
|
+
class ServerEmojiCDEventHandler < ServerEventHandler
|
|
148
|
+
def matches?(event)
|
|
149
|
+
# Check for the proper event type
|
|
150
|
+
return false unless event.is_a? ServerEmojiCDEvent
|
|
151
|
+
|
|
152
|
+
[
|
|
153
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
154
|
+
a == case a
|
|
155
|
+
when String
|
|
156
|
+
e.name
|
|
157
|
+
when Integer
|
|
158
|
+
e.id
|
|
159
|
+
else
|
|
160
|
+
e
|
|
161
|
+
end
|
|
162
|
+
end,
|
|
163
|
+
matches_all(@attributes[:id], event.emoji.id) { |a, e| a.resolve_id == e.resolve_id },
|
|
164
|
+
matches_all(@attributes[:name], event.emoji.name) { |a, e| a == e }
|
|
165
|
+
].reduce(true, &:&)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Event handler for {ServerEmojiCreateEvent}
|
|
170
|
+
class ServerEmojiCreateEventHandler < ServerEmojiCDEventHandler; end
|
|
171
|
+
|
|
172
|
+
# Event handler for {ServerEmojiDeleteEvent}
|
|
173
|
+
class ServerEmojiDeleteEventHandler < ServerEmojiCDEventHandler; end
|
|
174
|
+
|
|
175
|
+
# Event handler for {ServerEmojiUpdateEvent}
|
|
176
|
+
class ServerEmojiUpdateEventHandler < EventHandler
|
|
177
|
+
def matches?(event)
|
|
178
|
+
# Check for the proper event type
|
|
179
|
+
return false unless event.is_a? ServerEmojiUpdateEvent
|
|
180
|
+
|
|
181
|
+
[
|
|
182
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
183
|
+
a == case a
|
|
184
|
+
when String
|
|
185
|
+
e.name
|
|
186
|
+
when Integer
|
|
187
|
+
e.id
|
|
188
|
+
else
|
|
189
|
+
e
|
|
190
|
+
end
|
|
191
|
+
end,
|
|
192
|
+
matches_all(@attributes[:id], event.old_emoji.id) { |a, e| a.resolve_id == e.resolve_id },
|
|
193
|
+
matches_all(@attributes[:old_name], event.old_emoji.name) { |a, e| a == e },
|
|
194
|
+
matches_all(@attributes[:name], event.emoji.name) { |a, e| a == e }
|
|
195
|
+
].reduce(true, &:&)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Raised whenever an audit log entry is created.
|
|
200
|
+
class AuditLogEntryCreateEvent < Event
|
|
201
|
+
# @return [Server] the server of the audit log event.
|
|
202
|
+
attr_reader :server
|
|
203
|
+
|
|
204
|
+
# @return [AuditLogs::Entry] the entry of the audit log event.
|
|
205
|
+
attr_reader :entry
|
|
206
|
+
|
|
207
|
+
# @return [Integer] the raw action type of the audit log entry.
|
|
208
|
+
attr_reader :action
|
|
209
|
+
|
|
210
|
+
# @return [Integer] the ID of the user or bot that made the entry.
|
|
211
|
+
attr_reader :user_id
|
|
212
|
+
|
|
213
|
+
# @return [Integer, nil] the ID of the affected webhook, user, etc.
|
|
214
|
+
attr_reader :target_id
|
|
215
|
+
|
|
216
|
+
# @!visibility private
|
|
217
|
+
def initialize(data, bot)
|
|
218
|
+
@bot = bot
|
|
219
|
+
@action = data['action_type']
|
|
220
|
+
@user_id = data['user_id']&.to_i
|
|
221
|
+
@target_id = data['target_id']&.to_i
|
|
222
|
+
@server = bot.server(data['guild_id'].to_i)
|
|
223
|
+
@entry = OnyxCord::AuditLogs::Entry.new(nil, @server, @bot, data)
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Event handler for GUILD_AUDIT_LOG_ENTRY_CREATE events.
|
|
228
|
+
class AuditLogEntryCreateEventHandler < EventHandler
|
|
229
|
+
# @!visibility private
|
|
230
|
+
def matches?(event)
|
|
231
|
+
# Check for the proper event type.
|
|
232
|
+
return false unless event.is_a?(AuditLogEntryCreateEvent)
|
|
233
|
+
|
|
234
|
+
[
|
|
235
|
+
matches_all(@attributes[:action], event) do |a, e|
|
|
236
|
+
case a
|
|
237
|
+
when Numeric
|
|
238
|
+
a == e.action
|
|
239
|
+
when String, Symbol
|
|
240
|
+
a.to_sym == e.entry.action
|
|
241
|
+
end
|
|
242
|
+
end,
|
|
243
|
+
|
|
244
|
+
matches_all(@attributes[:reason], event.entry) do |a, e|
|
|
245
|
+
if e.reason
|
|
246
|
+
case a
|
|
247
|
+
when String
|
|
248
|
+
a == e.reason
|
|
249
|
+
when Regexp
|
|
250
|
+
a.match?(e.reason)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end,
|
|
254
|
+
|
|
255
|
+
matches_all(@attributes[:user], event.user_id) do |a, e|
|
|
256
|
+
a&.resolve_id == e&.resolve_id
|
|
257
|
+
end,
|
|
258
|
+
|
|
259
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
260
|
+
a&.resolve_id == e&.resolve_id
|
|
261
|
+
end,
|
|
262
|
+
|
|
263
|
+
matches_all(@attributes[:target], event.target_id) do |a, e|
|
|
264
|
+
a&.resolve_id == e&.resolve_id
|
|
265
|
+
end
|
|
266
|
+
].reduce(true, &:&)
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/data'
|
|
4
|
+
require 'onyxcord/events/generic'
|
|
5
|
+
|
|
6
|
+
module OnyxCord::Events
|
|
7
|
+
# Generic superclass for integration events.
|
|
8
|
+
class IntegrationEvent < Event
|
|
9
|
+
# @return [Server] the server associated with the event.
|
|
10
|
+
attr_reader :server
|
|
11
|
+
|
|
12
|
+
# @return [Integration] the integration associated with the event.
|
|
13
|
+
attr_reader :integration
|
|
14
|
+
|
|
15
|
+
# @!visibility private
|
|
16
|
+
def initialize(data, bot)
|
|
17
|
+
@bot = bot
|
|
18
|
+
@server = bot.server(data['guild_id'].to_i)
|
|
19
|
+
@integration = OnyxCord::Integration.new(data, @bot, @server)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Raised whenever an integration is created.
|
|
24
|
+
class IntegrationCreateEvent < IntegrationEvent; end
|
|
25
|
+
|
|
26
|
+
# Raised whenever an integration is updated.
|
|
27
|
+
class IntegrationUpdateEvent < IntegrationEvent; end
|
|
28
|
+
|
|
29
|
+
# Raised whenever an integration is deleted.
|
|
30
|
+
class IntegrationDeleteEvent < Event
|
|
31
|
+
# @return [Server] the server associated with the event.
|
|
32
|
+
attr_reader :server
|
|
33
|
+
|
|
34
|
+
# @return [Integer] the ID of the integration that was removed.
|
|
35
|
+
attr_reader :integration_id
|
|
36
|
+
|
|
37
|
+
# @return [Integer, nil] the ID of the application that was removed.
|
|
38
|
+
attr_reader :application_id
|
|
39
|
+
|
|
40
|
+
# @!visibility private
|
|
41
|
+
def initialize(data, bot)
|
|
42
|
+
@bot = bot
|
|
43
|
+
@server = bot.server(data['guild_id'].to_i)
|
|
44
|
+
@integration_id = data['id'].to_i
|
|
45
|
+
@application_id = data['application_id']&.to_i
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Generic event handler for integration events.
|
|
50
|
+
class IntegrationEventHandler < EventHandler
|
|
51
|
+
# @!visibility private
|
|
52
|
+
def matches?(event)
|
|
53
|
+
# Check for the proper event type.
|
|
54
|
+
return false unless event.is_a?(IntegrationEvent)
|
|
55
|
+
|
|
56
|
+
[
|
|
57
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
58
|
+
a&.resolve_id == e&.resolve_id
|
|
59
|
+
end,
|
|
60
|
+
|
|
61
|
+
matches_all(@attributes[:id], event.integration) do |a, e|
|
|
62
|
+
a&.resolve_id == e&.resolve_id
|
|
63
|
+
end,
|
|
64
|
+
|
|
65
|
+
matches_all(@attributes[:application], event.integration) do |a, e|
|
|
66
|
+
a&.resolve_id == e.application&.resolve_id
|
|
67
|
+
end
|
|
68
|
+
].reduce(true, &:&)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Event handler for INTEGRATION_CREATE events.
|
|
73
|
+
class IntegrationCreateEventHandler < IntegrationEventHandler; end
|
|
74
|
+
|
|
75
|
+
# Event handler for INTEGRATION_UPDATE events.
|
|
76
|
+
class IntegrationUpdateEventHandler < IntegrationEventHandler; end
|
|
77
|
+
|
|
78
|
+
# Event handler for INTEGRATION_DELETE events.
|
|
79
|
+
class IntegrationDeleteEventHandler < EventHandler
|
|
80
|
+
# @!visibility private
|
|
81
|
+
def matches?(event)
|
|
82
|
+
# Check for the proper event type.
|
|
83
|
+
return false unless event.is_a?(IntegrationDeleteEvent)
|
|
84
|
+
|
|
85
|
+
[
|
|
86
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
87
|
+
a&.resolve_id == e&.resolve_id
|
|
88
|
+
end,
|
|
89
|
+
|
|
90
|
+
matches_all(@attributes[:id], event.integration_id) do |a, e|
|
|
91
|
+
a&.resolve_id == e&.resolve_id
|
|
92
|
+
end,
|
|
93
|
+
|
|
94
|
+
matches_all(@attributes[:application], event.application_id) do |a, e|
|
|
95
|
+
a&.resolve_id == e&.resolve_id
|
|
96
|
+
end
|
|
97
|
+
].reduce(true, &:&)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|