kanal-plugins-user_system 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 224bf63f0573197c1906ae9cfbd203b3bfd2c978912b1e54b3d7a6bcf69f5256
4
- data.tar.gz: 140e802ccbbdff1741797bd598e40f41a7577bd3817fc9a96402bcbf9e423f3f
3
+ metadata.gz: 0f7c84fbbba995954788ddad3408e4db13073831f9c8e0350898d0280e1b394c
4
+ data.tar.gz: 8302c8a1a1fbb51ed2800dbbb41d52af9330e461ff8fc270e5b014fcb28f50ef
5
5
  SHA512:
6
- metadata.gz: a7120a03627e13ab8e2230b6dd6e40058925882b5bdc038569546d501f2f5c39fd3da8c26f765ba4b738eb51fe6ae5951b254a409c48182c375292bfcb2fa2a3
7
- data.tar.gz: 147f98f6e3358f0f3997a62f7e61a58ade941a65879523c66f873d646690fdbdf1f3811236508f9faaa7d3b44f2e6b0261ee299f853a4f242a0906ef72298956
6
+ metadata.gz: ac6957526d879c8f8974fc1269a6677b4a26e2a418c9edb1cbc4cd326d03d717886364044edbb22a9fb7e6027c6baa581f472be502550255d65e9c8139d5871f
7
+ data.tar.gz: bd74983833ede706717fee5ec15886542703ea38673a1b4537a07d0eb5955b9f753d0374ab0989555cdcffb1f80b5e900e1d16e99e8407f905f1c3c6c918d3c0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2023-04-12
4
+
5
+ - Auto creation of users. Now available for telegram
6
+
3
7
  ## [0.1.0] - 2022-11-14
4
8
 
5
9
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kanal-plugins-user_system (0.2.1)
4
+ kanal-plugins-user_system (0.3.0)
5
5
  activerecord
6
6
  sqlite3
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.0.4.2)
12
- activesupport (= 7.0.4.2)
13
- activerecord (7.0.4.2)
14
- activemodel (= 7.0.4.2)
15
- activesupport (= 7.0.4.2)
16
- activesupport (7.0.4.2)
11
+ activemodel (7.0.4.3)
12
+ activesupport (= 7.0.4.3)
13
+ activerecord (7.0.4.3)
14
+ activemodel (= 7.0.4.3)
15
+ activesupport (= 7.0.4.3)
16
+ activesupport (7.0.4.3)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
@@ -21,7 +21,7 @@ GEM
21
21
  ast (2.4.2)
22
22
  backport (1.2.0)
23
23
  benchmark (0.2.1)
24
- concurrent-ruby (1.2.0)
24
+ concurrent-ruby (1.2.2)
25
25
  diff-lcs (1.5.0)
26
26
  docile (1.4.0)
27
27
  e2mmap (0.1.0)
@@ -29,24 +29,23 @@ GEM
29
29
  concurrent-ruby (~> 1.0)
30
30
  jaro_winkler (1.5.4)
31
31
  json (2.6.3)
32
- kanal (0.3.0)
33
- kanal-plugins-active_record (0.2.0)
32
+ kanal (0.4.3)
33
+ kanal-plugins-active_record (0.2.1)
34
34
  activerecord
35
- kanal
36
35
  kramdown (2.4.0)
37
36
  rexml
38
37
  kramdown-parser-gfm (1.1.0)
39
38
  kramdown (~> 2.0)
40
- minitest (5.17.0)
41
- nokogiri (1.14.0-x86_64-darwin)
39
+ minitest (5.18.0)
40
+ nokogiri (1.14.2-x86_64-linux)
42
41
  racc (~> 1.4)
43
42
  parallel (1.22.1)
44
- parser (3.2.0.0)
43
+ parser (3.2.2.0)
45
44
  ast (~> 2.4.1)
46
45
  racc (1.6.2)
47
46
  rainbow (3.1.1)
48
47
  rake (13.0.6)
49
- regexp_parser (2.6.2)
48
+ regexp_parser (2.7.0)
50
49
  reverse_markdown (2.1.1)
51
50
  nokogiri
52
51
  rexml (3.2.5)
@@ -54,30 +53,30 @@ GEM
54
53
  rspec-core (~> 3.12.0)
55
54
  rspec-expectations (~> 3.12.0)
56
55
  rspec-mocks (~> 3.12.0)
57
- rspec-core (3.12.0)
56
+ rspec-core (3.12.1)
58
57
  rspec-support (~> 3.12.0)
59
58
  rspec-expectations (3.12.2)
60
59
  diff-lcs (>= 1.2.0, < 2.0)
61
60
  rspec-support (~> 3.12.0)
62
- rspec-mocks (3.12.3)
61
+ rspec-mocks (3.12.5)
63
62
  diff-lcs (>= 1.2.0, < 2.0)
64
63
  rspec-support (~> 3.12.0)
65
64
  rspec-support (3.12.0)
66
- rubocop (1.44.1)
65
+ rubocop (1.49.0)
67
66
  json (~> 2.3)
68
67
  parallel (~> 1.10)
69
68
  parser (>= 3.2.0.0)
70
69
  rainbow (>= 2.2.2, < 4.0)
71
70
  regexp_parser (>= 1.8, < 3.0)
72
71
  rexml (>= 3.2.5, < 4.0)
73
- rubocop-ast (>= 1.24.1, < 2.0)
72
+ rubocop-ast (>= 1.28.0, < 2.0)
74
73
  ruby-progressbar (~> 1.7)
75
74
  unicode-display_width (>= 2.4.0, < 3.0)
76
- rubocop-ast (1.24.1)
77
- parser (>= 3.1.1.0)
75
+ rubocop-ast (1.28.0)
76
+ parser (>= 3.2.1.0)
78
77
  ruby-debug-ide (0.7.3)
79
78
  rake (>= 0.8.1)
80
- ruby-progressbar (1.11.0)
79
+ ruby-progressbar (1.13.0)
81
80
  simplecov (0.22.0)
82
81
  docile (~> 1.1)
83
82
  simplecov-html (~> 0.11)
@@ -99,9 +98,9 @@ GEM
99
98
  thor (~> 1.0)
100
99
  tilt (~> 2.0)
101
100
  yard (~> 0.9, >= 0.9.24)
102
- sqlite3 (1.6.0-x86_64-darwin)
101
+ sqlite3 (1.6.2-x86_64-linux)
103
102
  thor (1.2.1)
104
- tilt (2.0.11)
103
+ tilt (2.1.0)
105
104
  tzinfo (2.0.6)
106
105
  concurrent-ruby (~> 1.0)
107
106
  unicode-display_width (2.4.2)
@@ -110,7 +109,7 @@ GEM
110
109
  webrick (~> 1.7.0)
111
110
 
112
111
  PLATFORMS
113
- x86_64-darwin-21
112
+ x86_64-linux
114
113
 
115
114
  DEPENDENCIES
116
115
  kanal
@@ -125,4 +124,4 @@ DEPENDENCIES
125
124
  yard
126
125
 
127
126
  BUNDLED WITH
128
- 2.3.19
127
+ 2.4.5
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanal
4
+ module Plugins
5
+ module UserSystem
6
+ module Helpers
7
+ #
8
+ # Serves as a configuration storage for UserSystem plugin to allow enabling of automatic creation of users
9
+ #
10
+ class AutoCreateEnabler
11
+ attr_reader :telegram_enabled
12
+
13
+ def initialize
14
+ @telegram_enabled = false
15
+ end
16
+
17
+ def enable_telegram
18
+ @telegram_enabled = true
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanal
4
+ module Plugins
5
+ module UserSystem
6
+ module Helpers
7
+ #
8
+ # Serves as a storage of methods to enable automatic user creation used by UserSystem
9
+ #
10
+ module AutoCreator
11
+ #
12
+ # Enables automatic creation of telegram user with telegram_chat_id property during consuming of input by router
13
+ #
14
+ # @param [Kanal::Core::Core] core <description>
15
+ #
16
+ def self.enable_telegram(core)
17
+ core.hooks.attach :input_before_router do |input|
18
+ tg_chat_id = input.tg_chat_id
19
+
20
+ tg_chat_id_property = "telegram_chat_id"
21
+
22
+ return if tg_chat_id.nil?
23
+
24
+ user = KanalUser.find_all_by_property(property_name: tg_chat_id_property, property_value: tg_chat_id).first
25
+
26
+ unless user
27
+ username = input.tg_username
28
+
29
+ username ||= "TEMP_USERNAME_#{tg_chat_id}"
30
+
31
+ user = KanalUser.create(username: username)
32
+ user.create_or_update_property(tg_chat_id_property, tg_chat_id)
33
+ end
34
+
35
+ input.user = user
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "kanal/core/plugins/plugin"
4
4
  require_relative "./models/kanal_user"
5
+ require_relative "helpers/auto_creator"
6
+ require_relative "helpers/auto_create_enabler"
5
7
 
6
8
  module Kanal
7
9
  module Plugins
@@ -10,6 +12,14 @@ module Kanal
10
12
  # registration and removal system
11
13
  class UserSystemPlugin < Kanal::Core::Plugins::Plugin
12
14
  include Models
15
+ include Helpers
16
+
17
+ attr_reader :auto_create
18
+
19
+ def initialize
20
+ super
21
+ @auto_create = AutoCreateEnabler.new
22
+ end
13
23
 
14
24
  def name
15
25
  :user_system
@@ -31,6 +41,8 @@ module Kanal
31
41
 
32
42
  setup_user_storage core
33
43
  setup_user_state core
44
+
45
+ AutoCreator.enable_telegram(core) if @auto_create.telegram_enabled
34
46
  end
35
47
 
36
48
  def setup_user_state(core)
@@ -3,7 +3,7 @@
3
3
  module Kanal
4
4
  module Plugins
5
5
  module UserSystem
6
- VERSION = "0.2.1"
6
+ VERSION = "0.3.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanal-plugins-user_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - idchlife
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-29 00:00:00.000000000 Z
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -56,9 +56,10 @@ files:
56
56
  - LICENSE.txt
57
57
  - README.md
58
58
  - Rakefile
59
- - kanal-plugins-user_system.gemspec
60
59
  - lib/kanal/plugins/user_system.rb
61
60
  - lib/kanal/plugins/user_system/database/database_connection.rb
61
+ - lib/kanal/plugins/user_system/helpers/auto_create_enabler.rb
62
+ - lib/kanal/plugins/user_system/helpers/auto_creator.rb
62
63
  - lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
63
64
  - lib/kanal/plugins/user_system/migrations/20221124150000_create_base_models.rb
64
65
  - lib/kanal/plugins/user_system/models/kanal_user.rb
@@ -74,7 +75,7 @@ metadata:
74
75
  homepage_uri: https://github.com/idchlife/kanal-plugins-user_system
75
76
  source_code_uri: https://github.com/idchlife/kanal-plugins-user_system
76
77
  changelog_uri: https://github.com/idchlife/kanal-plugins-user_system
77
- post_install_message:
78
+ post_install_message:
78
79
  rdoc_options: []
79
80
  require_paths:
80
81
  - lib
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubygems_version: 3.1.6
93
- signing_key:
94
+ signing_key:
94
95
  specification_version: 4
95
96
  summary: User system plugin for kanal library, provides users, user properties, etc
96
97
  test_files: []
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/kanal/plugins/user_system/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "kanal-plugins-user_system"
7
- spec.version = Kanal::Plugins::UserSystem::VERSION
8
- spec.authors = ["idchlife"]
9
- spec.email = ["idchlife@gmail.com"]
10
-
11
- spec.summary = "User system plugin for kanal library, provides users, user properties, etc"
12
- spec.description = "Library that provides user feature, with saving users and their properties"
13
- spec.homepage = "https://github.com/idchlife/kanal-plugins-user_system"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.6"
16
-
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/idchlife/kanal-plugins-user_system"
21
- spec.metadata["changelog_uri"] = "https://github.com/idchlife/kanal-plugins-user_system"
22
-
23
- spec.add_dependency "activerecord"
24
- # spec.add_dependency "kanal"
25
- spec.add_dependency "sqlite3"
26
-
27
- # Specify which files should be added to the gem when it is released.
28
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
- spec.files = Dir.chdir(__dir__) do
30
- `git ls-files -z`.split("\x0").reject do |f|
31
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
32
- end
33
- end
34
- spec.bindir = "exe"
35
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
- spec.require_paths = ["lib"]
37
-
38
- # Uncomment to register a new dependency of your gem
39
- # spec.add_dependency "example-gem", "~> 1.0"
40
-
41
- # For more information and examples about making a new gem, check out our
42
- # guide at: https://bundler.io/guides/creating_gem.html
43
- end