ish_models 0.0.33.303 → 3.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gameui/asset3d.rb +0 -2
- data/lib/iro/{alert.rb-bk → option_watch.rb} +1 -1
- data/lib/ish/user_profile.rb +24 -21
- data/lib/ish_models.rb +6 -1
- data/lib/office/email_conversation.rb +50 -34
- data/lib/office/email_message.rb +16 -53
- data/lib/office/emailtag.rb +27 -0
- data/lib/office/emailtag_email_conversation.rb +10 -0
- data/lib/wco/appliance.rb +19 -10
- data/lib/wco/appliance_tmpl.rb +25 -5
- data/lib/wco/dns_domain.rb +23 -0
- data/lib/wco/email_conversation_lead.rb +10 -0
- data/lib/wco/leadset.rb +10 -1
- data/lib/wco/serverhost.rb +72 -32
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c1a22259e454aa8350407614eb6da60e10cc87fd5b7a349655e8d4fea281632
|
4
|
+
data.tar.gz: 9898d3663b786e614852aaf8be16a4fb1daa3aa5130b1139642550d6aeb8232c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40579c613c11cdd8db789db9dd0804d1b1ee3e40f46f8abd1cd83b8ada329a99cc35cf330eb44aff2e63274861b815b6e45f560f2ae2e595feafc299dac46a6b
|
7
|
+
data.tar.gz: 55a7d4590ac60a32fcbfc7aa9002b4d46ecb59fbfddeaa38caf5131281ea8407cd9ff2a3070e019716e8fcd0502327dcc41d69a6886d1d4cf9f1325a40fa6de4
|
data/lib/gameui/asset3d.rb
CHANGED
@@ -8,8 +8,6 @@ class ::Gameui::Asset3d
|
|
8
8
|
include Mongoid::Paperclip
|
9
9
|
include Ish::Utils
|
10
10
|
|
11
|
-
field :filename
|
12
|
-
|
13
11
|
belongs_to :marker, class_name: 'Gameui::Marker', optional: true
|
14
12
|
belongs_to :invoice, class_name: 'Ish::Invoice', optional: true
|
15
13
|
belongs_to :email_message, class_name: 'Office::EmailMessage', optional: true, inverse_of: :asset3ds
|
data/lib/ish/user_profile.rb
CHANGED
@@ -28,23 +28,24 @@ class Ish::UserProfile
|
|
28
28
|
|
29
29
|
field :scratchpad, default: ''
|
30
30
|
|
31
|
-
field :fb_access_token
|
32
|
-
field :fb_long_access_token
|
33
|
-
field :fb_expires_in
|
34
|
-
|
35
31
|
field :lang, default: 'en'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
|
33
|
+
field :leadset_id, type: Integer ## old sql
|
34
|
+
belongs_to :leadset, class_name: '::Wco::Leadset'
|
35
|
+
|
36
|
+
##
|
37
|
+
## PiousboxCRM, Email:
|
38
|
+
##
|
39
|
+
# has_many :lead_ties, class_name: '::Wco::EmailConversationLead' ## need to name it better.
|
40
|
+
|
41
|
+
##
|
42
|
+
## wco hosting:
|
43
|
+
##
|
44
|
+
|
45
|
+
## 2023-08-21 _vp_ @TODO: change:
|
46
|
+
# def next_serverhost
|
47
|
+
# ::Wco::Serverhost.where({ leadset_id: leadset_id }).first
|
43
48
|
# end
|
44
|
-
# @TODO: change _vp_ 2023-08-21
|
45
|
-
def next_serverhost
|
46
|
-
Wco::Serverhost.where({ leadset_id: leadset_id }).first
|
47
|
-
end
|
48
49
|
|
49
50
|
ROLE_GUY = :guy
|
50
51
|
ROLE_MANAGER = :manager
|
@@ -69,6 +70,7 @@ class Ish::UserProfile
|
|
69
70
|
has_and_belongs_to_many :friends, :class_name => '::Ish::UserProfile', inverse_of: :friendeds
|
70
71
|
has_and_belongs_to_many :friendeds, :class_name => '::Ish::UserProfile', inverse_of: :friends
|
71
72
|
|
73
|
+
|
72
74
|
def sudoer?
|
73
75
|
%w( piousbox@gmail.com victor@wasya.co ).include?( self.email )
|
74
76
|
end
|
@@ -77,15 +79,15 @@ class Ish::UserProfile
|
|
77
79
|
out = self.all
|
78
80
|
[['', nil]] + out.map { |item| [ item.email, item.id ] }
|
79
81
|
end
|
80
|
-
def self.list_lg
|
81
|
-
|
82
|
-
|
83
|
-
end
|
82
|
+
# def self.list_lg
|
83
|
+
# out = self.all
|
84
|
+
# [['', nil]] + out.map { |item| [ "#{item.email} :: #{item.name}", item.id ] }
|
85
|
+
# end
|
84
86
|
|
85
87
|
field :n_unlocks, type: Integer, default: 0
|
86
88
|
|
87
89
|
has_many :payments, :class_name => '::Ish::Payment'
|
88
|
-
has_many :subscriptions, class_name: 'Wco::Subscription', inverse_of: :profile
|
90
|
+
has_many :subscriptions, class_name: '::Wco::Subscription', inverse_of: :profile
|
89
91
|
|
90
92
|
def has_premium_purchase item
|
91
93
|
payments.confirmed.where( item: item ).exists?
|
@@ -143,4 +145,5 @@ class Ish::UserProfile
|
|
143
145
|
|
144
146
|
end
|
145
147
|
|
146
|
-
Profile
|
148
|
+
Profile = Ish::UserProfile
|
149
|
+
Wco::Lead = Ish::UserProfile
|
data/lib/ish_models.rb
CHANGED
@@ -40,7 +40,7 @@ require 'gameui/asset3d'
|
|
40
40
|
require 'gameui/map'
|
41
41
|
require 'gameui/marker'
|
42
42
|
|
43
|
-
|
43
|
+
require 'iro/option_watch'
|
44
44
|
|
45
45
|
require 'ish/cache_key'
|
46
46
|
require 'ish/crawler'
|
@@ -76,6 +76,8 @@ require 'office/email_conversation_tag'
|
|
76
76
|
require 'office/email_filter'
|
77
77
|
require 'office/email_message'
|
78
78
|
require 'office/email_message_stub'
|
79
|
+
require 'office/emailtag'
|
80
|
+
require 'office/emailtag_email_conversation'
|
79
81
|
require 'office/lead_action'
|
80
82
|
require 'office/lead_action_template'
|
81
83
|
require 'office/obfuscated_redirect'
|
@@ -84,6 +86,8 @@ require 'office/scheduled_email_action'
|
|
84
86
|
|
85
87
|
require 'wco/appliance'
|
86
88
|
require 'wco/appliance_tmpl'
|
89
|
+
require 'wco/dns_domain'
|
90
|
+
require 'wco/email_conversation_lead'
|
87
91
|
require 'wco/leadset'
|
88
92
|
require 'wco/price'
|
89
93
|
require 'wco/product'
|
@@ -93,3 +97,4 @@ require 'wco/subscription'
|
|
93
97
|
|
94
98
|
|
95
99
|
|
100
|
+
|
@@ -20,62 +20,78 @@ class Office::EmailConversation
|
|
20
20
|
|
21
21
|
field :preview, default: ''
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# @deprecated, @TODO: remove
|
24
|
+
has_many :lead_ties, class_name: 'Office::EmailConversationLead'
|
25
|
+
has_many :wco_lead_ties, class_name: '::Wco::EmailConversationLead'
|
26
|
+
|
27
|
+
|
28
28
|
def leads
|
29
29
|
Lead.find( lead_ties.map( &:lead_id ) )
|
30
30
|
end
|
31
31
|
|
32
32
|
has_many :email_messages, class_name: 'Office::EmailMessage'
|
33
33
|
has_many :email_conversation_tags, class_name: 'Office::EmailConversationTag'
|
34
|
-
|
35
|
-
def wp_term_ids ## @TODO: remove _vp_ 2023-09-23
|
36
|
-
email_conversation_tags.map( &:wp_term_id )
|
37
|
-
end
|
34
|
+
has_many :emailtag_ties, class_name: 'Office::EmailtagEmailConversation'
|
38
35
|
|
39
36
|
def tags
|
40
|
-
|
37
|
+
Emailtag.find( emailtag_ties.map &:emailtag_id )
|
41
38
|
end
|
42
39
|
|
43
|
-
## Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? _vp_ 2023-03-07
|
40
|
+
# ## Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? _vp_ 2023-03-07
|
41
|
+
# def add_tag which
|
42
|
+
# tag = WpTag.iso_get which
|
43
|
+
# # puts!( tag.slug, "Adding tag" ) if DEBUG
|
44
|
+
# Office::EmailConversationTag.find_or_create_by!({
|
45
|
+
# email_conversation_id: id,
|
46
|
+
# wp_term_id: tag.id,
|
47
|
+
# })
|
48
|
+
# end
|
44
49
|
def add_tag which
|
45
|
-
|
46
|
-
# puts!( tag.slug, "Adding tag" ) if DEBUG
|
47
|
-
Office::EmailConversationTag.find_or_create_by!({
|
48
|
-
email_conversation_id: id,
|
49
|
-
wp_term_id: tag.id,
|
50
|
-
})
|
50
|
+
::EmailtagTie.create!({ emailtag: which, email_conversation: self })
|
51
51
|
end
|
52
52
|
|
53
|
+
# def remove_tag which
|
54
|
+
# tag = WpTag.iso_get which
|
55
|
+
# # puts!( tag.slug, "Removing tag" ) if DEBUG
|
56
|
+
# Office::EmailConversationTag.where({
|
57
|
+
# email_conversation_id: id,
|
58
|
+
# wp_term_id: tag.id,
|
59
|
+
# }).first&.delete
|
60
|
+
# end
|
53
61
|
def remove_tag which
|
54
|
-
|
55
|
-
# puts!( tag.slug, "Removing tag" ) if DEBUG
|
56
|
-
Office::EmailConversationTag.where({
|
57
|
-
email_conversation_id: id,
|
58
|
-
wp_term_id: tag.id,
|
59
|
-
}).first&.delete
|
62
|
+
::EmailtagTie.find_by({ emailtag: which, email_conversation: self }).delete
|
60
63
|
end
|
61
|
-
## @deprecated, do not use. _vp_ 2023-10-29
|
62
64
|
def rmtag which; remove_tag which; end
|
63
65
|
|
66
|
+
# def in_emailtag? which
|
67
|
+
# tag = WpTag.iso_get( which )
|
68
|
+
# email_conversation_tags.where({ wp_term_id: tag.id }).present?
|
69
|
+
# end
|
64
70
|
def in_emailtag? which
|
65
|
-
|
66
|
-
|
71
|
+
if which.class == String
|
72
|
+
which = Office::Emailtag.find_by({ slug: which })
|
73
|
+
end
|
74
|
+
!!::EmailtagTie.where({ emailtag: which, email_conversation: self }).first
|
67
75
|
end
|
68
76
|
|
69
|
-
def self.in_emailtag which
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
# def self.in_emailtag which
|
78
|
+
# tag = WpTag.iso_get( which )
|
79
|
+
# email_conversation_tags = Office::EmailConversationTag.where({ wp_term_id: tag.id })
|
80
|
+
# where({ :id.in => email_conversation_tags.map(&:email_conversation_id) })
|
81
|
+
# end
|
82
|
+
def self.in_emailtag which, page: 1, per: 25
|
83
|
+
conv_ids = ::EmailtagTie.find_by({ emailtag: which }).map( &:email_conversation_id )
|
84
|
+
Conv.where({ id: conv_ids }).order_by({ updated_at: :desc }).page( page ).per( per )
|
73
85
|
end
|
74
86
|
|
75
|
-
def self.not_in_emailtag which
|
76
|
-
|
77
|
-
|
78
|
-
|
87
|
+
# def self.not_in_emailtag which
|
88
|
+
# tag = WpTag.iso_get( which )
|
89
|
+
# email_conversation_tags = Office::EmailConversationTag.where({ wp_term_id: tag.id })
|
90
|
+
# where({ :id.nin => email_conversation_tags.map(&:email_conversation_id) })
|
91
|
+
# end
|
92
|
+
def self.not_in_emailtag which, page: 1, per: 25
|
93
|
+
conv_ids = ::EmailtagTie.find_by({ emailtag: which }).map( &:email_conversation_id )
|
94
|
+
Conv.where({ :id.nin => conv_ids }).order_by({ updated_at: :desc }).page( page ).per( per )
|
79
95
|
end
|
80
96
|
|
81
97
|
|
data/lib/office/email_message.rb
CHANGED
@@ -135,13 +135,23 @@ class Office::EmailMessage
|
|
135
135
|
# "text/calendar; charset=utf-8; method=REQUEST"
|
136
136
|
def churn_subpart part
|
137
137
|
if part.content_disposition&.include?('attachment')
|
138
|
-
|
138
|
+
## @TODO: attachments !
|
139
|
+
;
|
139
140
|
else
|
140
|
-
if part.content_type.include?("multipart")
|
141
|
+
if part.content_type.include?("multipart/related") ||
|
142
|
+
part.content_type.include?("multipart/alternative")
|
143
|
+
|
141
144
|
part.parts.each do |subpart|
|
142
145
|
churn_subpart( subpart )
|
143
146
|
end
|
144
147
|
else
|
148
|
+
# attachment = Office::EmailAttachment.new({
|
149
|
+
# content: part.decoded,
|
150
|
+
# content_type: part.content_type,
|
151
|
+
# email_message: self,
|
152
|
+
# })
|
153
|
+
# attachment.save
|
154
|
+
|
145
155
|
if part.content_type.include?('text/html')
|
146
156
|
self.part_html = part.decoded
|
147
157
|
|
@@ -149,19 +159,15 @@ class Office::EmailMessage
|
|
149
159
|
self.part_txt = part.decoded
|
150
160
|
|
151
161
|
elsif part.content_type.include?("text/calendar")
|
152
|
-
|
153
|
-
|
162
|
+
;
|
154
163
|
elsif part.content_type.include?("application/pdf")
|
155
|
-
|
156
|
-
|
164
|
+
;
|
157
165
|
elsif part.content_type.include?("image/jpeg")
|
158
|
-
|
159
|
-
|
166
|
+
;
|
160
167
|
elsif part.content_type.include?("image/png")
|
161
|
-
|
168
|
+
;
|
162
169
|
|
163
170
|
else
|
164
|
-
save_attachment( part, filename: 'subpart-unspecified' )
|
165
171
|
self.logs.push "444 No action for a part with content_type #{part.content_type}"
|
166
172
|
|
167
173
|
end
|
@@ -169,49 +175,6 @@ class Office::EmailMessage
|
|
169
175
|
end
|
170
176
|
end
|
171
177
|
|
172
|
-
def save_attachment att, filename: "no-filename-specified"
|
173
|
-
content_type = att.content_type.split(';')[0]
|
174
|
-
if content_type.include? 'image'
|
175
|
-
photo = Photo.new({
|
176
|
-
content_type: content_type,
|
177
|
-
email_message_id: @message.id,
|
178
|
-
image_data: att.body.encoded,
|
179
|
-
original_filename: att.content_type_parameters[:name],
|
180
|
-
})
|
181
|
-
photo.decode_base64_image
|
182
|
-
photo.save
|
183
|
-
else
|
184
|
-
|
185
|
-
filename = CGI.escape( att.filename || filename )
|
186
|
-
attachment = Office::EmailAttachment.new({
|
187
|
-
content: att.body.decoded,
|
188
|
-
content_type: att.content_type,
|
189
|
-
email_message: @message,
|
190
|
-
filename: filename,
|
191
|
-
})
|
192
|
-
begin
|
193
|
-
attachment.save
|
194
|
-
rescue Encoding::UndefinedConversionError
|
195
|
-
@message.logs.push "Could not save an attachment"
|
196
|
-
@message.save
|
197
|
-
end
|
198
|
-
|
199
|
-
sio = StringIO.new att.body.decoded
|
200
|
-
File.open("/tmp/#{filename}", 'w:UTF-8:ASCII-8BIT') do |f|
|
201
|
-
f.puts(sio.read)
|
202
|
-
end
|
203
|
-
asset3d = ::Gameui::Asset3d.new({
|
204
|
-
email_message: @message,
|
205
|
-
filename: filename,
|
206
|
-
object: File.open("/tmp/#{filename}"),
|
207
|
-
})
|
208
|
-
if !asset3d.save
|
209
|
-
@message.logs.push "Could not save an asset3d"
|
210
|
-
@message.save
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
end
|
215
178
|
|
216
179
|
def body_sanitized
|
217
180
|
ActionView::Base.full_sanitizer.sanitize( part_html||'' ).squish
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
class Office::Emailtag
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
# field :name
|
7
|
+
# validates :name, presence: true
|
8
|
+
|
9
|
+
field :slug
|
10
|
+
validates :slug, presence: true
|
11
|
+
|
12
|
+
INBOX = 'inbox'
|
13
|
+
TRASH = 'trash'
|
14
|
+
EMAILTAGS = [ INBOX, TRASH ]
|
15
|
+
|
16
|
+
def self.inbox
|
17
|
+
Office::Emailtag.find_by({ slug: INBOX })
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.trash
|
21
|
+
Office::Emailtag.find_by({ slug: TRASH })
|
22
|
+
end
|
23
|
+
|
24
|
+
has_many :emailtag_ties, class_name: 'Office::EmailtagEmailConversation'
|
25
|
+
|
26
|
+
end
|
27
|
+
Tag = Office::Emailtag
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
class Office::EmailtagEmailConversation
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
belongs_to :emailtag, class_name: 'Office::Emailtag'
|
7
|
+
belongs_to :email_conversation, class_name: 'Office::EmailConversation'
|
8
|
+
|
9
|
+
end
|
10
|
+
EmailtagTie = Office::EmailtagEmailConversation
|
data/lib/wco/appliance.rb
CHANGED
@@ -3,24 +3,29 @@ class Wco::Appliance
|
|
3
3
|
include Mongoid::Document
|
4
4
|
include Mongoid::Timestamps
|
5
5
|
|
6
|
+
field :kind
|
7
|
+
validates :kind, presence: true
|
8
|
+
|
9
|
+
field :environment
|
10
|
+
|
6
11
|
field :name
|
7
12
|
validates :name, uniqueness: { scope: :leadset_id }, presence: true
|
8
13
|
|
9
|
-
field :
|
14
|
+
# field :service_name
|
15
|
+
def service_name
|
16
|
+
# "#{@appliance[:kind]}_#{@appliance[:environment]}_#{@appliance[:name]}"
|
17
|
+
"#{kind}_#{environment}_#{name}"
|
18
|
+
end
|
10
19
|
|
11
|
-
field :service_name
|
12
|
-
field :environment
|
13
20
|
|
14
21
|
field :subdomain
|
15
22
|
field :domain
|
16
|
-
def
|
23
|
+
def origin
|
17
24
|
"#{subdomain}.#{domain}"
|
18
25
|
end
|
19
26
|
|
20
|
-
field :leadset_id
|
21
|
-
|
22
|
-
Leadset.find leadset_id
|
23
|
-
end
|
27
|
+
field :leadset_id # old sql
|
28
|
+
belongs_to :leadset, class_name: 'Wco::Leadset', inverse_of: :appliances
|
24
29
|
|
25
30
|
belongs_to :appliance_tmpl, class_name: 'Wco::ApplianceTmpl'
|
26
31
|
def tmpl
|
@@ -28,16 +33,20 @@ class Wco::Appliance
|
|
28
33
|
end
|
29
34
|
|
30
35
|
belongs_to :serverhost, class_name: 'Wco::Serverhost'
|
31
|
-
belongs_to :wco_leadset, class_name: 'Wco::Leadset', inverse_of: :appliances
|
32
36
|
|
33
|
-
|
37
|
+
|
34
38
|
field :port
|
35
39
|
|
36
40
|
STATE_PENDING = 'state-pending'
|
37
41
|
STATE_LIVE = 'state-live'
|
38
42
|
STATE_TERM = 'state-term'
|
43
|
+
STATES = %w| state-pending state-live state-term |
|
39
44
|
field :state, default: STATE_PENDING
|
40
45
|
|
46
|
+
def route53_zone
|
47
|
+
Wco::DnsDomain.find_by({ name: domain })[0].route53_zone
|
48
|
+
end
|
49
|
+
|
41
50
|
end
|
42
51
|
|
43
52
|
|
data/lib/wco/appliance_tmpl.rb
CHANGED
@@ -18,13 +18,33 @@ class Wco::ApplianceTmpl
|
|
18
18
|
field :volume_zip
|
19
19
|
validates :volume_zip, presence: true
|
20
20
|
|
21
|
-
|
21
|
+
## Only underscores! These become variable names.
|
22
|
+
# KIND_CRM = 'kind_crm'
|
23
|
+
# KIND_DRUPAL = 'kind_drupal'
|
24
|
+
# KIND_HELLOWORLD = 'kind_helloworld'
|
25
|
+
# KIND_IROWOR = 'kind_irowor'
|
26
|
+
# KIND_JENKINS = 'kind_jenkins'
|
27
|
+
# KIND_MATOMO = 'kind_matomo'
|
28
|
+
# KIND_MOODLE = 'kind_moodle'
|
29
|
+
# KIND_PRESTASHOP = 'kind_prestashop'
|
30
|
+
# KIND_SMT = 'kind_smt'
|
31
|
+
# KIND_WORDPRESS = 'kind_wordpress'
|
32
|
+
|
33
|
+
## 2023-12-08 :: These names are impossible to change already.
|
34
|
+
KIND_CRM = 'crm'
|
22
35
|
KIND_DRUPAL = 'drupal'
|
23
36
|
KIND_HELLOWORLD = 'helloworld'
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
KIND_IROWOR = 'irowor'
|
38
|
+
KIND_JENKINS = 'jenkins'
|
39
|
+
KIND_MATOMO = 'matomo'
|
40
|
+
KIND_MOODLE = 'moodle'
|
41
|
+
KIND_PRESTASHOP = 'prestashop'
|
42
|
+
KIND_SMT = 'smt'
|
43
|
+
KIND_WORDPRESS = 'wordpress'
|
44
|
+
|
45
|
+
KINDS = [ KIND_CRM, KIND_DRUPAL, KIND_HELLOWORLD, KIND_IROWOR,
|
46
|
+
KIND_JENKINS, KIND_MATOMO, KIND_MOODLE, KIND_PRESTASHOP, KIND_SMT,
|
47
|
+
KIND_WORDPRESS ]
|
28
48
|
|
29
49
|
has_many :appliances, class_name: 'Wco::Appliance'
|
30
50
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
class Wco::DnsDomain
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
field :name
|
7
|
+
validates :name, uniqueness: true
|
8
|
+
|
9
|
+
## orbital.city : Z0145070C3DD1OJWHTXJ
|
10
|
+
## oquaney-splicing.com : Z060228025Y0JHUA35GN5
|
11
|
+
field :route53_zone
|
12
|
+
validates :route53_zone, presence: true
|
13
|
+
|
14
|
+
STATE_ACTIVE = 'active'
|
15
|
+
STATE_INACTIVE = 'inactive'
|
16
|
+
STATES = [ 'active', 'inactive' ]
|
17
|
+
field :state, default: STATE_ACTIVE
|
18
|
+
|
19
|
+
def self.list
|
20
|
+
[[nil,nil]] + all.where({ state: STATE_ACTIVE }).map { |i| [i.name, i.name ] }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/wco/leadset.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
|
2
|
+
##
|
3
|
+
## 2023-11-30 _vp_ For use in hosting!
|
4
|
+
## 2023-11-30 _vp_ For future use in email!
|
5
|
+
##
|
2
6
|
class Wco::Leadset
|
3
7
|
include Mongoid::Document
|
4
8
|
include Mongoid::Timestamps
|
5
9
|
|
6
10
|
field :name
|
7
11
|
|
8
|
-
field :
|
12
|
+
field :company_url
|
13
|
+
validates :company_url, presence: true, uniqueness: true
|
14
|
+
|
15
|
+
has_many :wco_leads, class_name: 'Ish::UserProfile'
|
16
|
+
|
17
|
+
# field :domains, type: :string, default: 'orbital.city'
|
9
18
|
|
10
19
|
has_many :serverhosts, class_name: 'Wco::Serverhost', inverse_of: :wco_leadset
|
11
20
|
def next_serverhost
|
data/lib/wco/serverhost.rb
CHANGED
@@ -16,50 +16,54 @@ class Wco::Serverhost
|
|
16
16
|
|
17
17
|
field :next_port, type: :integer, default: 8000
|
18
18
|
|
19
|
+
field :nginx_root, default: '/opt/nginx'
|
20
|
+
field :public_ip
|
21
|
+
|
19
22
|
## net-ssh, sshkit
|
20
23
|
field :ssh_host
|
21
24
|
# field :ssh_username
|
22
25
|
# field :ssh_key
|
23
|
-
field :nginx_root, default: '/opt/nginx'
|
24
26
|
|
25
27
|
has_many :appliances, class_name: 'Wco::Appliance'
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# `;
|
34
|
-
# puts! out, 'out'
|
35
|
-
# end
|
29
|
+
def add_nginx_site app
|
30
|
+
ac = ActionController::Base.new
|
31
|
+
ac.instance_variable_set( :@app, app )
|
32
|
+
rendered_str = ac.render_to_string("scripts/nginx_site.conf")
|
33
|
+
puts '+++ add_nginx_site rendered_str:'
|
34
|
+
print rendered_str
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
file = Tempfile.new('prefix')
|
37
|
+
file.write rendered_str
|
38
|
+
file.close
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
cmd = "scp #{file.path} #{ssh_host}:/etc/nginx/sites-available/#{app.service_name}.conf "
|
41
|
+
puts! cmd, 'cmd'
|
42
|
+
`#{cmd}`
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
cmd = "ssh #{ssh_host} 'ln -s /etc/nginx/sites-available/#{app.service_name}.conf /etc/nginx/sites-enabled/#{app.service_name}.conf ' "
|
45
|
+
puts! cmd, 'cmd'
|
46
|
+
`#{cmd}`
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
cmd = "ssh #{ssh_host} 'nginx -s reload ' "
|
49
|
+
puts! cmd, 'cmd'
|
50
|
+
`#{cmd}`
|
49
51
|
|
50
|
-
|
52
|
+
cmd = "ssh #{ssh_host} 'certbot run -d #{app.origin} --nginx -n ' "
|
53
|
+
puts! cmd, 'cmd'
|
54
|
+
`#{cmd}`
|
51
55
|
|
52
56
|
end
|
53
57
|
|
54
58
|
WORKDIR = "/opt/projects/docker"
|
55
59
|
|
56
|
-
def add_docker_service app
|
60
|
+
def add_docker_service app
|
57
61
|
puts! app, '#add_docker_service'
|
58
62
|
|
59
63
|
ac = ActionController::Base.new
|
60
64
|
ac.instance_variable_set( :@app, app )
|
61
65
|
ac.instance_variable_set( :@workdir, WORKDIR )
|
62
|
-
rendered_str = ac.render_to_string("docker-compose/dc-#{app
|
66
|
+
rendered_str = ac.render_to_string("docker-compose/dc-#{app.kind}")
|
63
67
|
puts '+++ add_docker_service rendered_str:'
|
64
68
|
print rendered_str
|
65
69
|
|
@@ -68,15 +72,45 @@ class Wco::Serverhost
|
|
68
72
|
file.close
|
69
73
|
puts! file.path, 'file.path'
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
cmd = "scp #{file.path} #{ssh_host}:#{WORKDIR}/dc-#{app.service_name}.yml "
|
76
|
+
puts! cmd, 'cmd'
|
77
|
+
`#{cmd}`
|
78
|
+
|
79
|
+
cmd = "ssh #{ssh_host} 'cd #{WORKDIR} ; \
|
80
|
+
docker compose -f dc-#{app.service_name}.yml up -d #{app.service_name} ; \
|
81
|
+
echo ok #add_docker_service ' "
|
82
|
+
puts! cmd, 'cmd'
|
83
|
+
`#{cmd}`
|
84
|
+
|
85
|
+
puts "ok '#add_docker_service'"
|
75
86
|
end
|
76
87
|
|
77
|
-
def
|
78
|
-
|
88
|
+
def create_wordpress_volume app
|
89
|
+
ac = ActionController::Base.new
|
90
|
+
ac.instance_variable_set( :@app, app )
|
91
|
+
ac.instance_variable_set( :@workdir, WORKDIR )
|
92
|
+
rendered_str = ac.render_to_string("scripts/create_volume")
|
93
|
+
# puts '+++ create_volume rendered_str:'
|
94
|
+
# print rendered_str
|
95
|
+
|
96
|
+
file = Tempfile.new('prefix')
|
97
|
+
file.write rendered_str
|
98
|
+
file.close
|
99
|
+
# puts! file.path, 'file.path'
|
100
|
+
|
101
|
+
cmd = "scp #{file.path} #{ssh_host}:#{WORKDIR}/scripts/create_volume"
|
102
|
+
puts! cmd, 'cmd'
|
103
|
+
`#{cmd}`
|
79
104
|
|
105
|
+
cmd = "ssh #{ssh_host} 'chmod a+x #{WORKDIR}/scripts/create_volume ; \
|
106
|
+
#{WORKDIR}/scripts/create_volume ' "
|
107
|
+
puts! cmd, 'cmd'
|
108
|
+
`#{cmd}`
|
109
|
+
|
110
|
+
puts 'ok #create_volume'
|
111
|
+
end
|
112
|
+
|
113
|
+
def create_volume app
|
80
114
|
ac = ActionController::Base.new
|
81
115
|
ac.instance_variable_set( :@app, app )
|
82
116
|
ac.instance_variable_set( :@workdir, WORKDIR )
|
@@ -89,11 +123,17 @@ class Wco::Serverhost
|
|
89
123
|
file.close
|
90
124
|
# puts! file.path, 'file.path'
|
91
125
|
|
92
|
-
|
93
|
-
|
94
|
-
|
126
|
+
cmd = "scp #{file.path} #{ssh_host}:#{WORKDIR}/scripts/create_volume"
|
127
|
+
puts! cmd, 'cmd'
|
128
|
+
`#{cmd}`
|
129
|
+
|
130
|
+
cmd = "ssh #{ssh_host} 'chmod a+x #{WORKDIR}/scripts/create_volume ; \
|
131
|
+
#{WORKDIR}/scripts/create_volume ' "
|
132
|
+
puts! cmd, 'cmd'
|
133
|
+
`#{cmd}`
|
134
|
+
|
135
|
+
puts 'ok #create_volume'
|
95
136
|
end
|
96
|
-
# alias_method :create_volume, :create_volume_2
|
97
137
|
|
98
138
|
|
99
139
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 3.0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -191,7 +191,7 @@ files:
|
|
191
191
|
- lib/gameui/map.rb
|
192
192
|
- lib/gameui/map_bookmark.rb
|
193
193
|
- lib/gameui/marker.rb
|
194
|
-
- lib/iro/
|
194
|
+
- lib/iro/option_watch.rb
|
195
195
|
- lib/ish/cache_key.rb
|
196
196
|
- lib/ish/configuration.rb
|
197
197
|
- lib/ish/crawler.rb
|
@@ -226,6 +226,8 @@ files:
|
|
226
226
|
- lib/office/email_filter.rb
|
227
227
|
- lib/office/email_message.rb
|
228
228
|
- lib/office/email_message_stub.rb
|
229
|
+
- lib/office/emailtag.rb
|
230
|
+
- lib/office/emailtag_email_conversation.rb
|
229
231
|
- lib/office/lead_action.rb
|
230
232
|
- lib/office/lead_action_template.rb
|
231
233
|
- lib/office/obfuscated_redirect.rb
|
@@ -235,6 +237,8 @@ files:
|
|
235
237
|
- lib/video.rb
|
236
238
|
- lib/wco/appliance.rb
|
237
239
|
- lib/wco/appliance_tmpl.rb
|
240
|
+
- lib/wco/dns_domain.rb
|
241
|
+
- lib/wco/email_conversation_lead.rb
|
238
242
|
- lib/wco/leadset.rb
|
239
243
|
- lib/wco/price.rb
|
240
244
|
- lib/wco/product.rb
|
@@ -242,7 +246,7 @@ files:
|
|
242
246
|
- lib/wco/subscription.rb
|
243
247
|
homepage: https://wasya.co
|
244
248
|
licenses:
|
245
|
-
-
|
249
|
+
- CC-BY-NC-SA-4.0
|
246
250
|
metadata: {}
|
247
251
|
post_install_message:
|
248
252
|
rdoc_options: []
|