chats 0.3.2 → 0.4.1

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.
@@ -9,14 +9,17 @@ module Chats
9
9
  # needs into an EXISTING install. Nothing else: the initializer, the
10
10
  # views and the routes you already own stay untouched.
11
11
  #
12
- # Currently writes the 0.2.0 migration (message authorship). It is
13
- # written guarded, so running it against an install that already has the
14
- # columns (a fresh 0.2.0 install) is a no-op rather than an error.
12
+ # Writes every migration since 0.1.x — 0.2.0's message authorship and
13
+ # 0.4.0's message action — in that order. Each is written guarded, so
14
+ # running this against an install that already has some of the columns
15
+ # (a fresh 0.2.0 install has the author ones) is a no-op for those
16
+ # rather than an error, and re-running it skips files already copied.
17
+ # The action migration is not written at all where the column exists.
15
18
  class UpgradeGenerator < Rails::Generators::Base
16
19
  include ActiveRecord::Generators::Migration
17
20
 
18
21
  source_root File.expand_path("templates", __dir__)
19
- desc "Add the migrations a chats version bump needs (0.2.0: message authorship)"
22
+ desc "Add the migrations a chats version bump needs (0.2.0: message authorship; 0.4.0: message actions)"
20
23
 
21
24
  def self.next_migration_number(dir)
22
25
  ActiveRecord::Generators::Base.next_migration_number(dir)
@@ -27,19 +30,47 @@ module Chats
27
30
  File.join(db_migrate_path, "add_author_to_chats_messages.rb")
28
31
  end
29
32
 
33
+ # Not written when the schema already HAS the column — a fresh 0.4.0
34
+ # install, whose create migration owns it. A second migration for a
35
+ # column it didn't add is one nobody can safely roll back. Without a
36
+ # database to ask, it is written anyway; its `up` is guarded, and its
37
+ # `down` never drops the column.
38
+ def create_action_migration
39
+ if action_column_present?
40
+ say_status :skip, "chats_messages.action already exists — no migration needed", :yellow
41
+ return
42
+ end
43
+
44
+ migration_template "add_action_to_chats_messages.rb.erb",
45
+ File.join(db_migrate_path, "add_action_to_chats_messages.rb")
46
+ end
47
+
30
48
  def display_post_upgrade_message
31
49
  say "\n💬 chats upgrade migrations copied.", :green
32
50
  say "\n 1. Run 'rails db:migrate'."
33
- say " 2. New in 0.2.0 — all opt-in, nothing changes until you ask:"
51
+ say " 2. New in 0.4.0 — a message can carry one button (the `action` column):"
52
+ say " alice.message!(bob, \"Let's play!\", action: { label: \"Join my room\", url: room_path(room) })"
53
+ say " app/views/chats/slots/_composer_actions.html.erb # your own buttons by the composer"
54
+ say " 3. New in 0.2.0 — all opt-in, nothing changes until you ask:"
34
55
  say " acts_as_messager notifications: false, blockable: false, inbox: :grouped"
35
56
  say " Chats.on(:message_created) { |message| … } # replaces config.notifier"
36
57
  say " config.messager_url / config.message_signature / config.inbox_scope"
37
58
  say " chat_locked? / chat_locked_notice on your chat subjects"
38
- say " 3. See the CHANGELOG for the full list.\n", :green
59
+ say " 4. See the CHANGELOG for the full list.\n", :green
39
60
  end
40
61
 
41
62
  private
42
63
 
64
+ def action_column_present?
65
+ ActiveRecord::Base.connection_pool.with_connection do |connection|
66
+ connection.column_exists?(:chats_messages, :action)
67
+ end
68
+ rescue ActiveRecord::ActiveRecordError
69
+ # No database configured, not created yet, or no chats tables: there
70
+ # is nothing to ask, so write the (guarded) migration.
71
+ false
72
+ end
73
+
43
74
  def migration_version
44
75
  "[#{ActiveRecord::VERSION::STRING.to_f}]"
45
76
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rameerez
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-09-17 00:00:00.000000000 Z
10
+ date: 2026-10-17 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord
@@ -145,6 +145,7 @@ files:
145
145
  - app/views/chats/conversations/index.html.erb
146
146
  - app/views/chats/conversations/refresh.turbo_stream.erb
147
147
  - app/views/chats/conversations/show.html.erb
148
+ - app/views/chats/messages/_action.html.erb
148
149
  - app/views/chats/messages/_composer.html.erb
149
150
  - app/views/chats/messages/_message.html.erb
150
151
  - app/views/chats/messages/create.turbo_stream.erb
@@ -160,10 +161,15 @@ files:
160
161
  - context7.json
161
162
  - docs/PRD.md
162
163
  - docs/campfire_review.md
164
+ - docs/screenshots/composer-actions.png
165
+ - docs/screenshots/inbox.png
166
+ - docs/screenshots/system-note-action.png
167
+ - docs/screenshots/thread-actions-phone.png
163
168
  - gemfiles/rails_7.1.gemfile
164
169
  - gemfiles/rails_7.2.gemfile
165
170
  - gemfiles/rails_8.1.gemfile
166
171
  - lib/chats.rb
172
+ - lib/chats/action.rb
167
173
  - lib/chats/broadcasts.rb
168
174
  - lib/chats/configuration.rb
169
175
  - lib/chats/engine.rb
@@ -182,6 +188,7 @@ files:
182
188
  - lib/chats/subscribers.rb
183
189
  - lib/chats/version.rb
184
190
  - lib/generators/chats/install_generator.rb
191
+ - lib/generators/chats/templates/add_action_to_chats_messages.rb.erb
185
192
  - lib/generators/chats/templates/add_author_to_chats_messages.rb.erb
186
193
  - lib/generators/chats/templates/create_chats_tables.rb.erb
187
194
  - lib/generators/chats/templates/initializer.rb