Class: Readiness::TicketProcessor::Namesquatting
- Inherits:
-
Client
- Object
- Client
- Readiness::TicketProcessor::Namesquatting
show all
- Defined in:
- lib/support_readiness/ticket_processor/namesquatting.rb
Overview
Defines the class Namesquatting within the module Zendesk.
Class Method Summary
collapse
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Class Method Details
162
163
164
165
166
167
168
169
170
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 162
def self.contact_owner(owners)
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket. = { body: (owners), public: false }
new_ticket.custom_fields = [
{ id: @ticket_stage_field.id, value: 'stage-frt' }
]
Readiness::Zendesk::Tickets.update!(@zendesk_client, new_ticket)
end
|
214
215
216
217
218
219
220
221
222
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 214
def self.(owners)
<<~STRING
The namespace checks for #{namespace_to_check} have determined it might be eligible for release after contacting owners.
The list of owner emails are:
#{owners.map { |o| "- #{o.email}" }.join("\n")}
STRING
end
|
.group_checks ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 53
def self.group_checks
group = Readiness::GitLab::Groups.new
group.id = namespace.id
request = @gitlab_admin_client.connection.get "groups/#{namespace.id}"
group_data = Oj.load(request.body)
has_data = false
recent_activity = false
projects = Readiness::GitLab::Groups.projects(@gitlab_admin_client, group, ["archived=false", "include_subgroups=true"])
members = Readiness::GitLab::Groups.members(@gitlab_admin_client, group)
owners_list = members.select { |m| m['access_level'] == 50 }
owners = []
projects.each do |p|
has_data = true if p.empty_repo
recent_activity = true if (Date.today - 2.years) < Date.parse(p.last_activity_at)
end
created_recently = Date.parse(group_data['created_at']) <= (Date.today + 6.months)
return immediate_release if projects.count.zero? && !created_recently
return immediate_release if !has_data && !created_recently
return rejection_request if recent_activity
owners_list.each do |o|
search = Readiness::GitLab::Users.search_by_username(@gitlab_admin_client, o['username'])
owners.push(search.detect { |s| s.username.downcase == o['username'].downcase })
end
recent_owner_signin = false
owners.compact.each do |o|
recent_owner_signin = true if (Date.today - 2.years) < Date.parse(o.last_sign_in_at)
end
return immediate_release if (projects.count.zero? || !has_data) && !recent_owner_signin
contact_owner(owners)
end
|
141
142
143
144
145
146
147
148
149
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 141
def self.immediate_release
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket. = { body: , public: false }
new_ticket.custom_fields = [
{ id: @ticket_stage_field.id, value: 'stage-frt' }
]
Readiness::Zendesk::Tickets.update!(@zendesk_client, new_ticket)
end
|
196
197
198
199
200
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 196
def self.
<<~STRING
The namespace checks for #{namespace_to_check} have determined it is available for immediate release.
STRING
end
|
.invalid_namespace ⇒ Object
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 130
def self.invalid_namespace
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket.status = 'solved'
new_ticket. = { body: , public: true }
new_ticket.custom_fields = [
{ id: @ticket_stage_field.id, value: 'stage-frt' }
]
Readiness::Zendesk::Tickets.update!(@zendesk_client, new_ticket)
end
|
186
187
188
189
190
191
192
193
194
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 186
def self.
<<~STRING
Hello,
We were unable to locate the namespace `#{namespace_to_check}` on gitlab.com at this time. As such, this should mean you are able to utilize it for your setup.
I'll mark this ticket as solved, please reach out if you have any further questions.
STRING
end
|
.namespace ⇒ Object
111
112
113
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 111
def self.namespace
@namespace ||= Readiness::GitLab::Namespaces.find(@gitlab_admin_client, namespace_to_check)
end
|
.namespace_to_check ⇒ Object
115
116
117
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 115
def self.namespace_to_check
@namespace_to_check ||= ENV.fetch('NAMESPACE')
end
|
.not_for_free_users ⇒ Object
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 119
def self.not_for_free_users
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket.status = 'solved'
new_ticket. = { body: , public: true }
new_ticket.custom_fields = [
{ id: @ticket_stage_field.id, value: 'stage-frt' }
]
Readiness::Zendesk::Tickets.update!(@zendesk_client, new_ticket)
end
|
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 172
def self.
<<~STRING
Hello,
Thank you for reaching out.
Please note that According to our [Name Squatting Policy](https://about.gitlab.com/support/gitlab-com-policies/#name-squatting-policy), namespaces may be released when they meet the appropriate criteria, and requested **by a member of paid namespace**.
Unfortunately your account doesn't appear to be part of a paid namespace so it isn't eligible for the namesquatting policy. If you believe we made a mistake and you are a part of the paid namespace please let us know and we will revisit this request.
I'll mark this ticket as solved, please reach out if you have any further questions.
STRING
end
|
107
108
109
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 107
def self.paid_tags
%w[priority-prospect ultimater premium gold silver]
end
|
.process!(zendesk_client, gitlab_admin_client, ticket_id) ⇒ Object
Process a Blocked Account request
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 18
def self.process!(zendesk_client, gitlab_admin_client, ticket_id)
@zendesk_client = zendesk_client
@gitlab_admin_client = gitlab_admin_client
@ticket_id = ticket_id
@ticket = Readiness::Zendesk::Tickets.find(@zendesk_client, @ticket_id)
puts 'No ticket found, so namesquatting to work' if @ticket.is_a? Hash
exit 0 if @ticket.is_a? Hash
puts 'Ticket is closed, so no org notes to add' if @ticket.status == 'closed'
exit 0 if @ticket.status == 'closed'
@ticket_fields = Readiness::Zendesk::TicketFields.list(@zendesk_client)
@ticket_stage_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Ticket Stage', @ticket_fields)
return not_for_free_users unless paid_tags.any? { |t| @ticket.tags.include? t }
return invalid_namespace unless Readiness::GitLab::Namespaces.exists?(@gitlab_admin_client, namespace_to_check)
return rejection_request if Readiness::GitLab::Namespaces.is_paid?(@gitlab_admin_client, namespace)
group_checks if namespace.kind == 'group'
user_checks if namespace.kind == 'user'
end
|
.rejection_request ⇒ Object
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 151
def self.rejection_request
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket.status = 'solved'
new_ticket. = { body: , public: true }
new_ticket.custom_fields = [
{ id: @ticket_stage_field.id, value: 'stage-frt' }
]
Readiness::Zendesk::Tickets.update!(@zendesk_client, new_ticket)
end
|
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 202
def self.
<<~STRING
Hello,
The namespace requested `#{namespace_to_check}` is **not eligible** for release in accordance with our [Name Squatting Policy](https://about.gitlab.com/support/gitlab-com-policies/#name-squatting-policy) and we are unable to process your request. As per our [Subscription Agreement](https://about.gitlab.com/handbook/legal/subscription-agreement/#5-restrictions-and-responsibilities) point 5.8, `Account names are administered by GitLab on a "first come, first served" basis`.
Please note often activity cannot be seen for private namespaces, so activity on a profile is not a true indicator of whether a namespace is active. Profiles can also be made private which also hides activity from public view.
I'll mark this ticket as solved, please reach out if you have any further questions.
STRING
end
|
.user_checks ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/support_readiness/ticket_processor/namesquatting.rb', line 87
def self.user_checks
search = Readiness::GitLab::Users.search_by_username(@gitlab_admin_client, namespace_to_check)
user_namespace = search.detect { |s| s.username.downcase == namespace_to_check.downcase }
created_recently = (Date.today - 90.days) < Date.parse(user_namespace.created_at)
return immediate_release if user_namespace.confirmed_at.nil? && !created_recently
has_data = false
projects = Readiness::GitLab::Users.projects(@gitlab_admin_client, user_namespace, ["archived=false"])
projects.each do |p|
has_data = true if p.empty_repo
break if has_data
end
maintainer_check = Readiness::GitLab::Users.only_maintainer?(@gitlab_admin_client, user_namespace)
recent_signin = (Date.today - 90.days) < Date.parse(user_namespace.created_at)
return immediate_release if (!created_recently && !maintainer_check) && !has_data
return contact_owner([user_namespace]) if (!recent_signin && !maintainer_check) && has_data
rejection_request
end
|