ishapi 0.1.8.291 → 0.1.8.293

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: 43ce4a2424f89a52445feed0a9eb1ec84c960aed3820bf98e1acd8338337a67a
4
- data.tar.gz: a85fa506200f1e92aaf39eb333556aefe621f1420773ade7a519278aa78d7202
3
+ metadata.gz: 1d72a1d1df005b55a8b87d8cf9a0393e1672559758bfbc807812820ceddd08fb
4
+ data.tar.gz: 6aef010b6fa8cd4c32d163350f4252664d152f20ac3940cb88817ad59728fe9d
5
5
  SHA512:
6
- metadata.gz: 808696b157e630761b8405a82ccb98006b1078a1199a1653fba6f7920e1ce4f1a6a09c423db19417eb920d39605fef6d8df383ee4e71c0e75f85189d62b083b1
7
- data.tar.gz: 578585f583cc1a941675d278b281f67cbe6c0344baa6861a627197e9712c92b68f0a3e6c136cc7dbb91d4ed6f214e5b0cf51f6507a8e1889ecf15ba0ed50c101
6
+ metadata.gz: 43271cdf8278e92cd4a821c1a1e18a828e59fb1bd8573e3142dd4dc096c71d9fd089d3379484323a710e44efbfc84d21fc6dffa160cb705f10da459ddf9d2f34
7
+ data.tar.gz: 8a8e0b3e38ba4d58140be181e83e302324a9fbe731d2dec9edc8edb21e5459949e0208b4b835e85b6a74e9b0477218e2be6914b2c8972bd6e7adbbed4d46d4bb
@@ -116,5 +116,26 @@ class ::Ishapi::ApplicationController < ActionController::Base
116
116
  @current_ability ||= Ishapi::Ability.new( @current_profile )
117
117
  end
118
118
 
119
+ def flash_alert what
120
+ flash[:alert] ||= []
121
+ if String == what.class
122
+ str = what
123
+ else
124
+ str = "Cannot create/update #{what.class.name}: #{what.errors.full_messages.join(', ')} ."
125
+ end
126
+ flash[:alert] << str
127
+ end
128
+
129
+ def flash_notice what
130
+ flash[:notice] ||= []
131
+ if String == what.class
132
+ str = what
133
+ else
134
+ str = "Created/updated #{what.class.name} ."
135
+ end
136
+ flash[:notice] << str
137
+ end
138
+
139
+
119
140
  end
120
141
 
@@ -20,9 +20,15 @@ module ::Ishapi
20
20
  template_id: params[:template_id],
21
21
  campaign_id: params[:campaign_id],
22
22
  })
23
- @unsubscribe.update_attributes({
23
+ flag = @unsubscribe.update_attributes({
24
24
  unsubscribed_at: Time.now,
25
25
  })
26
+ if flag
27
+ flash_notice "You have been unsubscribed."
28
+ else
29
+ flash_alert "We're sorry, but something went wrong. Please try again later."
30
+ end
31
+
26
32
  end
27
33
  end
28
34
 
@@ -44,6 +44,28 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
44
44
  end
45
45
  end
46
46
 
47
+ ## From: https://stackoverflow.com/questions/24672834/how-do-i-remove-emoji-from-string/24673322
48
+ def strip_emoji(text)
49
+ text = text.force_encoding('utf-8').encode
50
+ clean = ""
51
+
52
+ # symbols & pics
53
+ regex = /[\u{1f300}-\u{1f5ff}]/
54
+ clean = text.gsub regex, ""
55
+
56
+ # enclosed chars
57
+ regex = /[\u{2500}-\u{2BEF}]/ # I changed this to exclude chinese char
58
+ clean = clean.gsub regex, ""
59
+
60
+ # emoticons
61
+ regex = /[\u{1f600}-\u{1f64f}]/
62
+ clean = clean.gsub regex, ""
63
+
64
+ #dingbats
65
+ regex = /[\u{2702}-\u{27b0}]/
66
+ clean = clean.gsub regex, ""
67
+ end
68
+
47
69
  def perform id
48
70
  stub = ::Office::EmailMessageStub.find id
49
71
  if !Rails.env.test?
@@ -69,6 +91,10 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
69
91
  the_mail.to = [ 'NO-RECIPIENT' ]
70
92
  end
71
93
 
94
+
95
+ subject = strip_emoji the_mail.subject
96
+ subject ||= '(wco no subject)'
97
+
72
98
  @message = ::Office::EmailMessage.where( message_id: message_id ).first
73
99
  @message ||= ::Office::EmailMessage.new
74
100
  @message.assign_attributes({
@@ -80,7 +106,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
80
106
  object_key: stub.object_key,
81
107
  # object_path: stub.object_path,
82
108
 
83
- subject: the_mail.subject || '(wco no subject)',
109
+ subject: subject,
84
110
  date: the_mail.date,
85
111
 
86
112
  from: the_mail.from ? the_mail.from[0] : "nobody@unknown.domain",
@@ -139,7 +165,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
139
165
  in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
140
166
  if !in_reply_to_msg
141
167
  conv = ::Office::EmailConversation.find_or_create_by({
142
- subject: the_mail.subject,
168
+ subject: @message.subject,
143
169
  })
144
170
  in_reply_to_msg = ::Office::EmailMessage.find_or_create_by({
145
171
  message_id: in_reply_to_id,
@@ -149,7 +175,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
149
175
  conv = in_reply_to_msg.email_conversation
150
176
  else
151
177
  conv = ::Office::EmailConversation.find_or_create_by({
152
- subject: the_mail.subject,
178
+ subject: @message.subject,
153
179
  })
154
180
  end
155
181
  @message.update_attributes({ email_conversation_id: conv.id })
@@ -1,2 +1,5 @@
1
1
 
2
- Thanks! You have been unsubscribed.
2
+ = flash[:notice]
3
+ = flash[:alert]
4
+
5
+ -# Thanks! You have been unsubscribed.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.291
4
+ version: 0.1.8.293
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-24 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails