nuntius 1.5.0 → 1.5.2

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: 25dbff01510e68a23dbd0bf046aefd97cae3ad2633c88bb8cd702d42639b6a50
4
- data.tar.gz: 4c87bfd9ba23075725696538ee1fb1e1d9ba0661e07704b23ac3f75fbfb2f00c
3
+ metadata.gz: e838696ffee97488fa8ba197789b8c863a662dab896cb47c836b651d61135e50
4
+ data.tar.gz: 695b8775db5700301419a9d25ab58f6752f16f1ac10451d31a4e2cb4a251a927
5
5
  SHA512:
6
- metadata.gz: 47904897c1e9c09e5a1dab2bb82a979bc312f401c7d69766947e275729a30be0cb41f923614b2c558dd24edec2daacbe5b1c4fd2a0b22173aa7a5e68feb0a9c2
7
- data.tar.gz: a307808cc8cac2b8b8077ea9c78f3da025b830367a4b5c8ebc8eaacacd0e985f4fe0e90c866e348246c02725ef0b6f5c0a9a3440a854bd07a9291e6fbe0082a3
6
+ metadata.gz: 5264de4adda58f8297b41d20bd2c3302f2022e2702e75f048f13dafed286ec7bb6c828ea59f6cf5f1d4b8106e2141d349194a67c71cd791b83f7dc65cb6a9508
7
+ data.tar.gz: 5b3076c6c0a95a17f6f6f8b4be55a822bc3d66ed4bbd308b02970c2f8103589f637468d883832b94f695ad6f626f916b4512fe8507aea492e039a7f736a08b63
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nuntius
4
4
  class SubscriberDrop < ApplicationDrop
5
- delegate :id, :first_name, :last_name, :name, :list, :metadata, :unsubscribed_at, to: :@object
5
+ delegate :id, :first_name, :last_name, :name, :list, :metadata, :email, :phone_number, :tags, :unsubscribed_at, to: :@object
6
6
 
7
7
  def subscribed?
8
8
  @object.unsubscribed_at.nil?
@@ -4,21 +4,35 @@ require "csv"
4
4
 
5
5
  module Nuntius
6
6
  class ImportSubscribersJob < ApplicationJob
7
- KNOWN_COLUMNS = %i[first_name last_name email phone_number].freeze
7
+ KNOWN_COLUMNS = %i[id first_name last_name email phone_number tags].freeze
8
8
 
9
9
  def perform(list, blob, user)
10
- csv_content = blob.download
10
+ blob.open do |io|
11
+ import(list, io, user)
12
+ end
13
+ ensure
14
+ blob.purge
15
+ end
11
16
 
17
+ def import(list, io, user)
12
18
  imported = 0
13
19
  failed = 0
14
20
 
15
- CSV.parse(csv_content, headers: true, header_converters: :symbol) do |row|
21
+ detect_column_separator(io)
22
+
23
+ CSV.parse(io, headers: true, header_converters: :symbol, converters: ->(v) { v&.strip }, col_sep: @column_separator) do |row|
16
24
  row_hash = row.to_h
17
25
  attrs = row_hash.slice(*KNOWN_COLUMNS)
18
26
  extra = row_hash.except(*KNOWN_COLUMNS).reject { |_, v| v.nil? }
19
27
  attrs[:metadata] = extra unless extra.empty?
20
28
 
21
- subscriber = list.subscribers.new(attrs)
29
+ subscriber = if attrs[:id].present?
30
+ s = list.subscribers.find_by(id: attrs[:id])
31
+ s.assign_attributes(attrs)
32
+ s
33
+ else
34
+ list.subscribers.new(attrs)
35
+ end
22
36
  if subscriber.save
23
37
  imported += 1
24
38
  else
@@ -26,11 +40,15 @@ module Nuntius
26
40
  end
27
41
  end
28
42
 
29
- Signum.success(user, text: I18n.t("nuntius.admin.lists.subscribers.import.success", imported: imported, failed: failed))
43
+ Signum.success(user, text: I18n.t("nuntius.admin.lists.subscribers.import.success", imported: imported, failed: failed)) if defined?(Signum)
30
44
  rescue CSV::MalformedCSVError => e
31
- Signum.error(user, text: I18n.t("nuntius.admin.lists.subscribers.import.invalid_csv", message: e.message))
32
- ensure
33
- blob.purge
45
+ Signum.error(user, text: I18n.t("nuntius.admin.lists.subscribers.import.invalid_csv", message: e.message)) if defined?(Signum)
46
+ end
47
+
48
+ # Detect column separator based on the first 50 bytes of the CSV, it's naive but works for most cases
49
+ def detect_column_separator(io)
50
+ @column_separator = io.read(128).include?(";") ? ";" : ","
51
+ io.rewind
34
52
  end
35
53
  end
36
54
  end
@@ -50,12 +50,12 @@
50
50
  dt.text-sm.font-semibold.leading-6.text-gray-600
51
51
  = t(".messages_sent")
52
52
  dd.order-first.text-3xl.font-semibold.tracking-tight.text-gray-900
53
- = @campaign.messages.where(status: "sent").count
53
+ = @campaign.messages.where(state: "sent").count
54
54
  .flex.flex-col.bg-gray-200.p-8
55
55
  dt.text-sm.font-semibold.leading-6.text-gray-600
56
56
  = t(".messages_not_sent")
57
57
  dd.order-first.text-3xl.font-semibold.tracking-tight.text-gray-900
58
- = @campaign.messages.where.not(status: "sent").count
58
+ = @campaign.messages.where.not(state: "sent").count
59
59
  .flex.flex-col.bg-gray-200.p-8
60
60
  dt.text-sm.font-semibold.leading-6.text-gray-600
61
61
  = t(".messages_opened")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nuntius
4
- VERSION = "1.5.0"
4
+ VERSION = "1.5.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuntius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-27 00:00:00.000000000 Z
11
+ date: 2026-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apnotic
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: csv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: fcm
57
71
  requirement: !ruby/object:Gem::Requirement