thecore_backend_commons 3.0.8 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e88ce308362a3dccf66cc9ce56df99da608158d565060684fc05524c0705283
|
4
|
+
data.tar.gz: 8cc50c5d4bbb96a91845c5e0bcbad89e8a95a2b8b92d8ac11c619edd938c0940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ccf60a71b1429ab76212652728b9c4d37a7848ad30ad1bc4f3e50a247d1fffbf72fe78a8defa494b197ec956afe5eac7f57b6ff49421f0a0bc5be34ec5ad121
|
7
|
+
data.tar.gz: 82aa8fadc449b354fde1330b242ee516bf9416b0e3690a20fe3a0b3b52faa55562d8c749b81f72027dc925cf1c0c2b0f3909140c099003c1512c0c883ad6728e
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ActivityLogChannel < ApplicationCable::Channel
|
2
|
+
def subscribed
|
3
|
+
stream_from "messages"
|
4
|
+
end
|
5
|
+
|
6
|
+
def unsubscribed
|
7
|
+
# Any cleanup needed when channel is unsubscribed
|
8
|
+
end
|
9
|
+
|
10
|
+
# https://cableready.stimulusreflex.com/troubleshooting/#verify-actioncable
|
11
|
+
|
12
|
+
def receive(data)
|
13
|
+
puts data["message"]
|
14
|
+
ActionCable.server.broadcast("messages", "ActionCable is connected")
|
15
|
+
end
|
16
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
Rails.application.configure do
|
2
|
+
|
2
3
|
config.after_initialize do
|
3
4
|
Integer.send(:include, FixnumConcern)
|
4
5
|
String.send(:include, StringConcern)
|
6
|
+
ApplicationCable::Connection.send(:include, CableConnectionConcern)
|
7
|
+
ApplicationRecord.send(:include, ApplicationRecordConcern)
|
5
8
|
end
|
6
9
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ApplicationRecordConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
after_commit :message_ok
|
7
|
+
|
8
|
+
after_rollback :message_ko
|
9
|
+
|
10
|
+
def message_ok
|
11
|
+
ActionCable.server.broadcast("messages", { topic: :record, action: detect_action, success: true, record: self})
|
12
|
+
end
|
13
|
+
|
14
|
+
def message_ko
|
15
|
+
ActionCable.server.broadcast("messages", { topic: :record, action: detect_action, success: false, record: self})
|
16
|
+
end
|
17
|
+
|
18
|
+
def detect_action
|
19
|
+
return :create if transaction_include_any_action?([:create])
|
20
|
+
return :update if transaction_include_any_action?([:update])
|
21
|
+
:destroy
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module CableConnectionConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
identified_by :current_user
|
7
|
+
|
8
|
+
def connect
|
9
|
+
self.current_user = find_verified_user
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def find_verified_user # this checks whether a user is authenticated with devise
|
15
|
+
if verified_user = env['warden'].user
|
16
|
+
verified_user
|
17
|
+
else
|
18
|
+
reject_unauthorized_connection
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_backend_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_auth_commons
|
@@ -146,10 +146,13 @@ extra_rdoc_files: []
|
|
146
146
|
files:
|
147
147
|
- README.md
|
148
148
|
- Rakefile
|
149
|
+
- app/channels/activity_log_channel.rb
|
149
150
|
- config/initializers/abilities.rb
|
150
151
|
- config/initializers/add_to_db_migrations.rb
|
151
152
|
- config/initializers/after_initialize.rb
|
152
153
|
- config/initializers/application_config.rb
|
154
|
+
- config/initializers/concern_application_record.rb
|
155
|
+
- config/initializers/concern_cable_connection.rb
|
153
156
|
- config/initializers/concern_integer.rb
|
154
157
|
- config/initializers/concern_string.rb
|
155
158
|
- config/initializers/extension_nil.rb
|