caboose-rets 0.1.180 → 0.1.181
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 +4 -4
- data/app/controllers/caboose_rets/agents_controller.rb +23 -0
- data/app/mailers/caboose_rets/rets_mailer.rb +40 -3
- data/app/models/caboose_rets/agent.rb +35 -18
- data/app/views/caboose_rets/agents/user_unsubscribe.html.erb +5 -0
- data/app/views/caboose_rets/agents/user_unsubscribe_confirm.html.erb +3 -0
- data/app/views/caboose_rets/rets_mailer/user_welcome.html.erb +20 -0
- data/lib/caboose_rets/version.rb +1 -1
- data/lib/tasks/caboose_rets.rake +3 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ceb96a622cb163188374b4aeed6b1baee791b0e767c9aea00de93dffe90b1c8c
|
4
|
+
data.tar.gz: ed302be050341854d58534b57c5a5ea8e0c58c376631444ed6d01f84225a3347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f03b3418f74afdbbcadf3f50c98a12338646014fcaacc6e9467ba46279baf55d2696a6cf78d9e321850e72d1a0b1e0217b845f8f4d93090aefdd870fce192a5
|
7
|
+
data.tar.gz: 7c382a79cac4e9cb2353d8980013eed3bf22d48f78c5f9a8f3276e755e6429cd210c9f6215ce34a8683f1edac3e2511115e44134f74b8eacae5cb9af3e6a6e23
|
@@ -23,6 +23,29 @@ module CabooseRets
|
|
23
23
|
@agent = Agent.where(:slug => params[:slug]).where("office_mls_id ILIKE ?", @site.rets_office_id).first if !params[:slug].blank?
|
24
24
|
end
|
25
25
|
|
26
|
+
# @route GET /rets-unsubscribe
|
27
|
+
def user_unsubscribe
|
28
|
+
user_id = params[:token].blank? ? nil : params[:token].strip.gsub("7b8v9j","").gsub("9b6h0c2n","")
|
29
|
+
@user = user_id ? Caboose::User.where(:id => user_id, :site_id => @site.id).first : nil
|
30
|
+
@token = params[:token]
|
31
|
+
render :file => "caboose/extras/error404", :layout => "caboose/application", :status => 404 and return if @user.nil? || @token.blank?
|
32
|
+
@page.meta_robots = "noindex, nofollow"
|
33
|
+
@page.uri = "rets-unsubscribe"
|
34
|
+
@page.seo_title = "Confirm Unsubscription | #{@site.description}"
|
35
|
+
end
|
36
|
+
|
37
|
+
# @route GET /rets-unsubscribe/confirm
|
38
|
+
def user_unsubscribe_confirm
|
39
|
+
user_id = params[:token].blank? ? nil : params[:token].strip.gsub("7b8v9j","").gsub("9b6h0c2n","")
|
40
|
+
@user = user_id ? Caboose::User.where(:id => user_id, :site_id => @site.id).first : nil
|
41
|
+
render :file => "caboose/extras/error404", :layout => "caboose/application", :status => 404 and return if @user.nil?
|
42
|
+
@page.meta_robots = "noindex, nofollow"
|
43
|
+
@page.uri = "rets-unsubscribe/confirm"
|
44
|
+
@page.seo_title = "Unsubscribed | #{@site.description}"
|
45
|
+
@user.tax_exempt = true # this means unsubscribed
|
46
|
+
@user.save
|
47
|
+
end
|
48
|
+
|
26
49
|
#=============================================================================
|
27
50
|
# Admin functions
|
28
51
|
#=============================================================================
|
@@ -1,8 +1,13 @@
|
|
1
1
|
class CabooseRets::RetsMailer < ActionMailer::Base
|
2
2
|
|
3
|
-
|
3
|
+
def from_address(site_id, from_name)
|
4
|
+
settings = Caboose::SmtpConfig.where(:site_id => site_id).first
|
5
|
+
fn = from_name.blank? ? (settings ? settings.site.description : "Caboose CMS") : from_name
|
6
|
+
fn = fn.gsub(",","").gsub("<","").gsub(">","").gsub("@","").gsub(":","").truncate(30)
|
7
|
+
return settings ? "#{fn} <#{settings.from_address}>" : "#{fn} <noreply@caboosecms.com>"
|
8
|
+
end
|
4
9
|
|
5
|
-
def new_user(agent, user
|
10
|
+
def new_user(agent, user)
|
6
11
|
@agent = agent
|
7
12
|
@user = user
|
8
13
|
@site = user.site
|
@@ -11,10 +16,42 @@ class CabooseRets::RetsMailer < ActionMailer::Base
|
|
11
16
|
mail(
|
12
17
|
:to => to_address,
|
13
18
|
:bcc => bcc_address,
|
14
|
-
:from => from_address,
|
19
|
+
:from => from_address(@site.id, nil),
|
15
20
|
:subject => "New User Registration",
|
16
21
|
:reply_to => bcc_address
|
17
22
|
)
|
18
23
|
end
|
19
24
|
|
25
|
+
def user_welcome(agent, user)
|
26
|
+
@agent = agent
|
27
|
+
@user = user
|
28
|
+
@site = user.site
|
29
|
+
to_address = user.email
|
30
|
+
reply_to = @site.contact_email.blank? ? 'noreply@caboosecms.com' : @site.contact_email
|
31
|
+
|
32
|
+
setting = Caboose::Setting.where(:site_id => @site.id, :name => "welcome_email_subject").first
|
33
|
+
subject = setting && !setting.value.blank? ? setting.value : "Welcome to #{@site.description}"
|
34
|
+
|
35
|
+
setting2 = Caboose::Setting.where(:site_id => @site.id, :name => "welcome_email_body").first
|
36
|
+
@body = setting2 && !setting2.value.blank? ? setting2.value : "We're excited to see that you've registered for #{@site.description}. As a registered user, we'll notify you when there's a price drop or pending sale on your favorite properties. We'll also notify you of new listings and similar properties you may be interested in. Your assigned REALTOR® is |agent_name| and will be in touch with you shortly. Thank you for choosing #{@site.description}!"
|
37
|
+
@body = @body.gsub("|agent_name|", "#{@agent.first_name} #{@agent.last_name}")
|
38
|
+
|
39
|
+
@color = @site.theme ? @site.theme.color_main : @site.theme_color
|
40
|
+
|
41
|
+
@url = "https://#{@site.primary_domain.domain}"
|
42
|
+
@url += "/real-estate" if @site.id == 541
|
43
|
+
|
44
|
+
@logo_url = @site.logo.url(:large)
|
45
|
+
@logo_url = "https:#{@logo_url}" if !@logo_url.include?('http')
|
46
|
+
|
47
|
+
@unsubscribe_url = "https://#{@site.primary_domain.domain}/rets-unsubscribe?token=7b8v9j#{@user.id}9b6h0c2n"
|
48
|
+
|
49
|
+
mail(
|
50
|
+
:to => to_address,
|
51
|
+
:from => from_address(@site.id, nil),
|
52
|
+
:subject => subject,
|
53
|
+
:reply_to => reply_to
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
20
57
|
end
|
@@ -40,23 +40,26 @@ class CabooseRets::Agent < ActiveRecord::Base
|
|
40
40
|
CabooseRets::RetsImporter.import_agent(self.mls_id)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
43
|
+
# Sends a SMS to the agent (using Twilio) notifying them that a new user has registered and been assigned to them
|
44
|
+
def send_text(message, site_id)
|
45
|
+
s1 = Caboose::Setting.where(:site_id => site_id, :name => "twilio_account_sid").first
|
46
|
+
account_sid = s1 ? s1.value : nil
|
47
|
+
s2 = Caboose::Setting.where(:site_id => site_id, :name => "twilio_auth_token").first
|
48
|
+
auth_token = s2 ? s2.value : nil
|
49
|
+
s3 = Caboose::Setting.where(:site_id => site_id, :name => "twilio_from_number").first
|
50
|
+
twilio_number = s3 ? s3.value : nil
|
51
|
+
send_to = self.cell_phone.blank? ? (self.direct_work_phone.blank? ? self.other_phone : self.direct_work_phone) : self.cell_phone
|
52
|
+
send_to = '205-657-0937' if Rails.env.development? # Billy's cell
|
53
|
+
if account_sid && auth_token && twilio_number && !send_to.blank? && !message.blank?
|
54
|
+
@client = Twilio::REST::Client.new account_sid, auth_token
|
55
|
+
begin
|
56
|
+
message = @client.messages.create(
|
57
|
+
body: message,
|
58
|
+
to: "+1#{send_to.gsub(/[(\- )]/, '')}",
|
59
|
+
from: "#{twilio_number}"
|
60
|
+
)
|
61
|
+
rescue
|
62
|
+
Caboose.log("invalid phone number")
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
@@ -78,7 +81,21 @@ class CabooseRets::Agent < ActiveRecord::Base
|
|
78
81
|
user.rets_agent_mls_id = agent.mls_id
|
79
82
|
last_agent_mls_id.value = agent.mls_id
|
80
83
|
user.save
|
81
|
-
|
84
|
+
|
85
|
+
s1 = Caboose::Setting.where(:site_id => user.site_id, :name => "agent_text_message").first
|
86
|
+
message = s1 ? s1.value : nil
|
87
|
+
|
88
|
+
if !message.blank?
|
89
|
+
message = message.gsub("|user_first_name|", user.first_name)
|
90
|
+
message = message.gsub("|user_last_name|", user.last_name)
|
91
|
+
message = message.gsub("|user_email|", user.email)
|
92
|
+
message = message.gsub("|user_phone|", user.phone)
|
93
|
+
agent.delay(:queue => 'rets', :priority => 0).send_text(message, user.site_id)
|
94
|
+
end
|
95
|
+
|
96
|
+
CabooseRets::RetsMailer.configure_for_site(user.site_id).new_user(agent, user).deliver_later
|
97
|
+
CabooseRets::RetsMailer.configure_for_site(user.site_id).user_welcome(agent, user).deliver_later
|
98
|
+
|
82
99
|
last_agent_mls_id.save
|
83
100
|
role = Caboose::Role.where(:name => 'RETS Visitor', :site_id => user.site_id).exists? ? Caboose::Role.where(:name => 'RETS Visitor', :site_id => user.site_id).first : Caboose::Role.create(:name => 'RETS Visitor', :site_id => user.site_id)
|
84
101
|
Caboose::RoleMembership.create(:user_id => user.id, :role_id => role.id)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<div class="constrain richtext" style="text-align:center;font-size:18px;padding-top:50px;padding-bottom:50px;">
|
2
|
+
<h4>Are you sure you want to unsubscribe?</h4>
|
3
|
+
<p>By unsubscribing, you will no longer receive email updates for saved properties or suggested listings.</p>
|
4
|
+
<p><a style="margin-top:20px;display:inline-block;" href="/rets-unsubscribe/confirm?token=<%= @token %>">Yes, unsubscribe from all property updates and suggested listings.</a></p>
|
5
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div style="text-align:center;margin-bottom:20px;padding:20px;background-color:<%= @color %>;">
|
2
|
+
<a style="display:inline-block;text-decoration:none;" href="<%= @url %>" target="_blank">
|
3
|
+
<img style="display:block;" src="<%= @logo_url %>" alt="<%= @site.description %>" width="220" />
|
4
|
+
</a>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div style="text-align:center;padding:20px;">
|
8
|
+
<div style="max-width:500px;font-size:18px;margin:0 auto;line-height:26px;">
|
9
|
+
<h2>Welcome!</h2>
|
10
|
+
<p><%== @body %></p>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div style="text-align:center;margin-top:20px;padding:20px;background-color:<%= @color %>;">
|
15
|
+
<p style="margin-top:20px;font-size:13px;">
|
16
|
+
<a style="color:#fff;text-decoration:none;font-size:13px;display:inline-block;" target="_blank" href="<%= @unsubscribe_url %>">
|
17
|
+
Unsubscribe
|
18
|
+
</a>
|
19
|
+
</p>
|
20
|
+
</div>
|
data/lib/caboose_rets/version.rb
CHANGED
data/lib/tasks/caboose_rets.rake
CHANGED
@@ -115,7 +115,7 @@ namespace :caboose_rets do
|
|
115
115
|
params = {
|
116
116
|
:search_type => 'OpenHouse',
|
117
117
|
:class => 'OpenHouse',
|
118
|
-
:query => "(
|
118
|
+
:query => "(ListingId=#{args.query})",
|
119
119
|
:limit => 1,
|
120
120
|
:timeout => -1
|
121
121
|
}
|
@@ -271,8 +271,8 @@ namespace :caboose_rets do
|
|
271
271
|
|
272
272
|
desc "update test"
|
273
273
|
task :update_test => :environment do
|
274
|
-
d = DateTime.now -
|
275
|
-
CabooseRets::RetsImporter.update_helper("
|
274
|
+
d = DateTime.now - 6.hours
|
275
|
+
CabooseRets::RetsImporter.update_helper("OpenHouse", d, false)
|
276
276
|
end
|
277
277
|
|
278
278
|
desc "Updates all the listings from MLS"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-rets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.181
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caboose-cms
|
@@ -90,6 +90,8 @@ files:
|
|
90
90
|
- app/views/caboose_rets/agents/contact.html.erb
|
91
91
|
- app/views/caboose_rets/agents/details.html.erb
|
92
92
|
- app/views/caboose_rets/agents/index.html.erb
|
93
|
+
- app/views/caboose_rets/agents/user_unsubscribe.html.erb
|
94
|
+
- app/views/caboose_rets/agents/user_unsubscribe_confirm.html.erb
|
93
95
|
- app/views/caboose_rets/media/admin_property_media.html.erb
|
94
96
|
- app/views/caboose_rets/offices/admin_edit.html.erb
|
95
97
|
- app/views/caboose_rets/offices/admin_index.html.erb
|
@@ -106,6 +108,7 @@ files:
|
|
106
108
|
- app/views/caboose_rets/properties/test_form.html.erb
|
107
109
|
- app/views/caboose_rets/rets/admin_import_form.html.erb
|
108
110
|
- app/views/caboose_rets/rets_mailer/new_user.html.erb
|
111
|
+
- app/views/caboose_rets/rets_mailer/user_welcome.html.erb
|
109
112
|
- app/views/caboose_rets/saved_properties/index.html.erb
|
110
113
|
- app/views/caboose_rets/saved_properties/rets_info.html.erb
|
111
114
|
- app/views/caboose_rets/saved_properties/user_report.html.erb
|