loco-rails 4.0.0 → 6.0.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 +4 -4
- data/app/channels/loco/notification_center_channel.rb +17 -41
- data/app/controllers/loco/notification_center_controller.rb +6 -31
- data/app/jobs/loco/sender_job.rb +1 -1
- data/app/models/loco/notification.rb +31 -30
- data/app/services/loco/notification/fetcher.rb +12 -25
- data/lib/generators/loco/file_injector/templates/connection.rb +1 -0
- data/lib/loco/broadcaster.rb +34 -82
- data/lib/loco/emitter.rb +11 -6
- data/lib/loco/hub.rb +33 -40
- data/lib/loco/permissions_presenter.rb +27 -0
- data/lib/loco/{engine.rb → rails/engine.rb} +0 -0
- data/lib/loco/sender.rb +43 -26
- data/lib/loco/version.rb +1 -1
- data/lib/loco/ws_connection_checker.rb +16 -0
- data/lib/loco/ws_connection_finder.rb +30 -0
- data/lib/loco/ws_connection_identifier.rb +15 -0
- data/lib/loco/ws_connection_manager.rb +20 -74
- data/lib/loco/ws_connection_storage.rb +57 -17
- data/lib/loco-rails.rb +5 -2
- metadata +69 -44
- data/app/jobs/loco/uuid_job.rb +0 -51
- data/lib/loco/ws_connected_resources_manager.rb +0 -64
data/app/jobs/loco/uuid_job.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Loco
|
4
|
-
class UuidJob < ActiveJob::Base
|
5
|
-
queue_as :loco
|
6
|
-
|
7
|
-
def perform(serialized_resource, uuid, action)
|
8
|
-
ws_conn_manager = init_ws_conn_manager serialized_resource
|
9
|
-
return unless ws_conn_manager
|
10
|
-
|
11
|
-
case action
|
12
|
-
when 'add'
|
13
|
-
add ws_conn_manager, uuid
|
14
|
-
when 'del'
|
15
|
-
del ws_conn_manager, uuid
|
16
|
-
when 'update'
|
17
|
-
update ws_conn_manager, uuid
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def add(ws_conn_manager, uuid)
|
24
|
-
ws_conn_manager.add uuid
|
25
|
-
WsConnectedResourcesManager.add ws_conn_manager.identifier
|
26
|
-
end
|
27
|
-
|
28
|
-
def del(ws_conn_manager, uuid)
|
29
|
-
ws_conn_manager.del uuid
|
30
|
-
return if ws_conn_manager.connected_uuids.any?
|
31
|
-
|
32
|
-
WsConnectedResourcesManager.del ws_conn_manager.identifier
|
33
|
-
end
|
34
|
-
|
35
|
-
def update(ws_conn_manager, uuid)
|
36
|
-
ws_conn_manager.update uuid
|
37
|
-
WsConnectedResourcesManager.add ws_conn_manager.identifier
|
38
|
-
end
|
39
|
-
|
40
|
-
def deserialize_resource(hash)
|
41
|
-
hash['class'].constantize.find_by id: hash['id']
|
42
|
-
end
|
43
|
-
|
44
|
-
def init_ws_conn_manager(serialized_resource)
|
45
|
-
resource = deserialize_resource serialized_resource
|
46
|
-
return unless resource
|
47
|
-
|
48
|
-
WsConnectionManager.new resource
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Loco
|
4
|
-
class WsConnectedResourcesManager
|
5
|
-
def initialize(resources)
|
6
|
-
@resources = resources
|
7
|
-
@connected_resources = nil
|
8
|
-
end
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def identifiers
|
12
|
-
val = WsConnectionStorage.current.get key
|
13
|
-
return [] if val.blank?
|
14
|
-
|
15
|
-
JSON.parse val
|
16
|
-
end
|
17
|
-
|
18
|
-
def add(identifier)
|
19
|
-
ids = identifiers
|
20
|
-
return if ids.include? identifier
|
21
|
-
|
22
|
-
ids << identifier
|
23
|
-
WsConnectionStorage.current.set key, ids.to_json
|
24
|
-
end
|
25
|
-
|
26
|
-
def del(identifier)
|
27
|
-
ids = identifiers
|
28
|
-
return unless ids.include? identifier
|
29
|
-
|
30
|
-
ids.delete identifier
|
31
|
-
WsConnectionStorage.current.set key, ids.to_json
|
32
|
-
end
|
33
|
-
|
34
|
-
def key
|
35
|
-
'loco:conn_ids'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def connected_resources
|
40
|
-
return @connected_resources if @connected_resources
|
41
|
-
|
42
|
-
@resources.each do |resource|
|
43
|
-
next if WsConnectionManager.new(resource).connected_uuids.empty?
|
44
|
-
|
45
|
-
add resource
|
46
|
-
end
|
47
|
-
@connected_resources || []
|
48
|
-
end
|
49
|
-
|
50
|
-
def connected?(resource)
|
51
|
-
connected_resources.map do |res|
|
52
|
-
WsConnectionManager.new(res).identifier
|
53
|
-
end.include? WsConnectionManager.new(resource).identifier
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def add(resource)
|
59
|
-
@connected_resources ||= []
|
60
|
-
@connected_resources << resource
|
61
|
-
@connected_resources.uniq!
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|