Merge from docusealco/wip
This commit is contained in:
@@ -50,7 +50,7 @@ class AccountsController < ApplicationController
|
||||
# rubocop:disable Layout/LineLength
|
||||
render turbo_stream: turbo_stream.replace(
|
||||
:account_delete_button,
|
||||
html: helpers.tag.p(I18n.t('your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account'))
|
||||
html: helpers.tag.p(I18n.t('your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account'))
|
||||
)
|
||||
# rubocop:enable Layout/LineLength
|
||||
end
|
||||
|
||||
@@ -64,6 +64,7 @@ class StartFormController < ApplicationController
|
||||
.or(template.submissions.where(expire_at: nil)).where(archived_at: nil))
|
||||
.order(id: :desc)
|
||||
.where(declined_at: nil)
|
||||
.where(external_id: nil)
|
||||
.then { |rel| params[:resubmit].present? ? rel.where(completed_at: nil) : rel }
|
||||
.find_or_initialize_by(**submitter_params.compact_blank)
|
||||
end
|
||||
|
||||
@@ -20,7 +20,10 @@ class SubmissionsPreviewController < ApplicationController
|
||||
|
||||
@submission ||= Submission.find_by!(slug: params[:slug])
|
||||
|
||||
if @submission.account.archived_at? || (!@submission.submitters.all?(&:completed_at?) && current_user.blank?)
|
||||
raise ActionController::RoutingError if @submission.account.archived_at?
|
||||
|
||||
if !@submission.submitters.all?(&:completed_at?) && !signature_valid &&
|
||||
(!current_user || !current_ability.can?(:read, @submission))
|
||||
raise ActionController::RoutingError, I18n.t('not_found')
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmittersResubmitController < ApplicationController
|
||||
load_and_authorize_resource :submitter, parent: false
|
||||
|
||||
def update
|
||||
return redirect_to submit_form_path(slug: @submitter.slug) if @submitter.email != current_user.email
|
||||
|
||||
submission = @submitter.template.submissions.new(created_by_user: current_user,
|
||||
submitters_order: :preserved,
|
||||
**@submitter.submission.slice(:template_fields,
|
||||
:account_id,
|
||||
:template_schema,
|
||||
:template_submitters,
|
||||
:preferences))
|
||||
|
||||
@submitter.submission.submitters.each do |submitter|
|
||||
new_submitter = submission.submitters.new(submitter.slice(:uuid, :email, :phone, :name,
|
||||
:preferences, :metadata, :account_id))
|
||||
|
||||
next unless submitter.uuid == @submitter.uuid
|
||||
|
||||
assign_submitter_values(new_submitter, submitter)
|
||||
|
||||
@new_submitter ||= new_submitter
|
||||
end
|
||||
|
||||
submission.save!
|
||||
|
||||
redirect_to submit_form_path(slug: @new_submitter.slug)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_submitter_values(new_submitter, submitter)
|
||||
attachments_index = submitter.attachments.index_by(&:uuid)
|
||||
|
||||
submitter.submission.template_fields.each do |field|
|
||||
next if field['submitter_uuid'] != submitter.uuid
|
||||
next if field['default_value'] == '{{date}}'
|
||||
next if field['type'] == 'stamp'
|
||||
next if field['type'] == 'signature'
|
||||
next if field.dig('preferences', 'formula').present?
|
||||
|
||||
value = submitter.values[field['uuid']]
|
||||
|
||||
next if value.blank?
|
||||
|
||||
if field['type'].in?(%w[image file initials])
|
||||
Array.wrap(value).each do |attachment_uuid|
|
||||
new_submitter.attachments << attachments_index[attachment_uuid].dup
|
||||
end
|
||||
end
|
||||
|
||||
new_submitter.values[field['uuid']] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (file.type === 'image/bmp') {
|
||||
if (file.type === 'image/bmp' || file.type === 'image/vnd.microsoft.icon') {
|
||||
file = await this.convertBmpToPng(file)
|
||||
}
|
||||
|
||||
|
||||
@@ -361,6 +361,7 @@ export default {
|
||||
isMoved: false,
|
||||
renderDropdown: false,
|
||||
isNameFocus: false,
|
||||
isHeadingSelected: false,
|
||||
textOverflowChars: 0,
|
||||
dragFrom: { x: 0, y: 0 }
|
||||
}
|
||||
@@ -377,7 +378,7 @@ export default {
|
||||
}
|
||||
},
|
||||
isValueInput () {
|
||||
return (this.field.type === 'heading' && this.isSelected) || this.isContenteditable || (this.inputMode && ['text', 'number', 'date'].includes(this.field.type))
|
||||
return (this.field.type === 'heading' && this.isHeadingSelected) || this.isContenteditable || (this.inputMode && ['text', 'number', 'date'].includes(this.field.type))
|
||||
},
|
||||
modalContainerEl () {
|
||||
return this.$el.getRootNode().querySelector('#docuseal_modal_container')
|
||||
@@ -485,7 +486,7 @@ export default {
|
||||
if (['text', 'number'].includes(this.field.type)) {
|
||||
this.isContenteditable = true
|
||||
|
||||
this.$nextTick(() => this.focusValueInput())
|
||||
this.focusValueInput()
|
||||
} else if (this.field.type === 'checkbox') {
|
||||
this.field.readonly = !this.field.readonly
|
||||
this.field.default_value === true ? delete this.field.default_value : this.field.default_value = true
|
||||
@@ -507,16 +508,18 @@ export default {
|
||||
}
|
||||
},
|
||||
focusValueInput (e) {
|
||||
if (this.$refs.defaultValue !== document.activeElement) {
|
||||
this.$refs.defaultValue.focus()
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.defaultValue && this.$refs.defaultValue !== document.activeElement) {
|
||||
this.$refs.defaultValue.focus()
|
||||
|
||||
if (this.$refs.defaultValue.innerText.length && this.$refs.defaultValue !== e?.target) {
|
||||
window.getSelection().collapse(
|
||||
this.$refs.defaultValue.firstChild,
|
||||
this.$refs.defaultValue.innerText.length
|
||||
)
|
||||
if (this.$refs.defaultValue.innerText.length && this.$refs.defaultValue !== e?.target) {
|
||||
window.getSelection().collapse(
|
||||
this.$refs.defaultValue.firstChild,
|
||||
this.$refs.defaultValue.innerText.length
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
formatNumber (number, format) {
|
||||
if (format === 'comma') {
|
||||
@@ -632,6 +635,7 @@ export default {
|
||||
const text = this.$refs.defaultValue.innerText.trim()
|
||||
|
||||
this.isContenteditable = false
|
||||
this.isHeadingSelected = false
|
||||
|
||||
if (text) {
|
||||
if (this.field.type === 'number') {
|
||||
@@ -749,10 +753,6 @@ export default {
|
||||
|
||||
this.selectedAreaRef.value = this.area
|
||||
|
||||
if (this.field.type === 'heading') {
|
||||
this.$nextTick(() => this.focusValueInput())
|
||||
}
|
||||
|
||||
this.dragFrom = { x: rect.left - e.clientX, y: rect.top - e.clientY }
|
||||
|
||||
this.$el.getRootNode().addEventListener('mousemove', this.mouseMove)
|
||||
@@ -787,6 +787,12 @@ export default {
|
||||
this.save()
|
||||
}
|
||||
|
||||
if (this.field.type === 'heading') {
|
||||
this.isHeadingSelected = !this.isMoved
|
||||
|
||||
this.focusValueInput()
|
||||
}
|
||||
|
||||
this.isDragged = false
|
||||
this.isMoved = false
|
||||
|
||||
|
||||
@@ -1427,6 +1427,8 @@ export default {
|
||||
const documentRef = this.documentRefs.find((e) => e.document.uuid === area.attachment_uuid)
|
||||
const areaRef = documentRef.pageRefs[area.page].areaRefs.find((ref) => ref.area === this.selectedAreaRef.value)
|
||||
|
||||
areaRef.isHeadingSelected = true
|
||||
|
||||
areaRef.focusValueInput()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@
|
||||
<li
|
||||
v-for="(submitter, index) in submitters"
|
||||
:key="submitter.uuid"
|
||||
class="w-full"
|
||||
>
|
||||
<a
|
||||
href="#"
|
||||
@@ -191,7 +192,10 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="submitters.length < names.length && editable && allowAddNew">
|
||||
<li
|
||||
v-if="submitters.length < names.length && editable && allowAddNew"
|
||||
class="w-full"
|
||||
>
|
||||
<a
|
||||
href="#"
|
||||
class="flex px-2"
|
||||
@@ -215,6 +219,14 @@ import { IconUserPlus, IconTrashX, IconPlus, IconChevronUp, IconChevronDown } fr
|
||||
import Contenteditable from './contenteditable'
|
||||
import { v4 } from 'uuid'
|
||||
|
||||
function getOrdinalSuffix (num) {
|
||||
if (num % 10 === 1 && num % 100 !== 11) return 'st'
|
||||
if (num % 10 === 2 && num % 100 !== 12) return 'nd'
|
||||
if (num % 10 === 3 && num % 100 !== 13) return 'rd'
|
||||
|
||||
return 'th'
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'FieldSubmitter',
|
||||
components: {
|
||||
@@ -288,6 +300,14 @@ export default {
|
||||
]
|
||||
},
|
||||
names () {
|
||||
const generatedNames = []
|
||||
|
||||
for (let i = 21; i < 101; i++) {
|
||||
const suffix = getOrdinalSuffix(i)
|
||||
|
||||
generatedNames.push(`${i}${suffix} ${this.t('party')}`)
|
||||
}
|
||||
|
||||
return [
|
||||
this.t('first_party'),
|
||||
this.t('second_party'),
|
||||
@@ -308,7 +328,8 @@ export default {
|
||||
this.t('seventeenth_party'),
|
||||
this.t('eighteenth_party'),
|
||||
this.t('nineteenth_party'),
|
||||
this.t('twentieth_party')
|
||||
this.t('twentieth_party'),
|
||||
...generatedNames
|
||||
]
|
||||
},
|
||||
lastPartyIndex () {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
class="roles-dropdown w-full rounded-lg"
|
||||
:style="withStickySubmitters ? { backgroundColor } : {}"
|
||||
:submitters="submitters"
|
||||
:menu-style="{ backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor }"
|
||||
:menu-style="{ overflow: 'auto', display: 'flex', flexDirection: 'row', maxHeight: 'calc(100vh - 120px)', backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor }"
|
||||
:editable="editable && !defaultSubmitters.length"
|
||||
@new-submitter="save"
|
||||
@remove="removeSubmitter"
|
||||
@@ -327,7 +327,7 @@ export default {
|
||||
},
|
||||
filteredSubmitterDefaultFields () {
|
||||
if (this.defaultFieldsSearch) {
|
||||
return this.submitterDefaultFields.filter((f) => f.name.toLowerCase().includes(this.defaultFieldsSearch.toLowerCase()))
|
||||
return this.submitterDefaultFields.filter((f) => (f.title || f.name).toLowerCase().includes(this.defaultFieldsSearch.toLowerCase()))
|
||||
} else {
|
||||
return this.submitterDefaultFields
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const en = {
|
||||
party: 'Party',
|
||||
method: 'Method',
|
||||
reorder_fields: 'Reorder fields',
|
||||
verify_id: 'Verify ID',
|
||||
@@ -160,6 +161,7 @@ const en = {
|
||||
}
|
||||
|
||||
const es = {
|
||||
party: 'Parte',
|
||||
method: 'Método',
|
||||
reorder_fields: 'Reordenar campos',
|
||||
verify_id: 'Verificar ID',
|
||||
@@ -321,6 +323,7 @@ const es = {
|
||||
}
|
||||
|
||||
const it = {
|
||||
party: 'Parte',
|
||||
method: 'Metodo',
|
||||
reorder_fields: 'Riordina i campi',
|
||||
verify_id: 'Verifica ID',
|
||||
@@ -482,6 +485,7 @@ const it = {
|
||||
}
|
||||
|
||||
const pt = {
|
||||
party: 'Parte',
|
||||
method: 'Método',
|
||||
reorder_fields: 'Reorganizar campos',
|
||||
verify_id: 'Verificar ID',
|
||||
@@ -643,6 +647,7 @@ const pt = {
|
||||
}
|
||||
|
||||
const fr = {
|
||||
party: 'Partie',
|
||||
method: 'Méthode',
|
||||
reorder_fields: 'Réorganiser les champs',
|
||||
verify_id: "Vérifier l'ID",
|
||||
@@ -804,6 +809,7 @@ const fr = {
|
||||
}
|
||||
|
||||
const de = {
|
||||
party: 'Partei',
|
||||
method: 'Verfahren',
|
||||
reorder_fields: 'Felder neu anordnen',
|
||||
verify_id: 'ID überprüfen',
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendFormCompletedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 20
|
||||
|
||||
def perform(params = {})
|
||||
@@ -21,19 +19,8 @@ class SendFormCompletedWebhookRequestJob
|
||||
|
||||
ActiveStorage::Current.url_options = Docuseal.default_url_options
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'form.completed',
|
||||
timestamp: Time.current,
|
||||
data: Submitters::SerializeForWebhook.call(submitter)
|
||||
}.to_json,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT,
|
||||
**webhook_url.secret.to_h)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'form.completed',
|
||||
data: Submitters::SerializeForWebhook.call(submitter))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendFormDeclinedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -19,19 +17,8 @@ class SendFormDeclinedWebhookRequestJob
|
||||
|
||||
ActiveStorage::Current.url_options = Docuseal.default_url_options
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'form.declined',
|
||||
timestamp: Time.current,
|
||||
data: Submitters::SerializeForWebhook.call(submitter)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'form.declined',
|
||||
data: Submitters::SerializeForWebhook.call(submitter))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendFormStartedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -19,19 +17,8 @@ class SendFormStartedWebhookRequestJob
|
||||
|
||||
ActiveStorage::Current.url_options = Docuseal.default_url_options
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'form.started',
|
||||
timestamp: Time.current,
|
||||
data: Submitters::SerializeForWebhook.call(submitter)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'form.started',
|
||||
data: Submitters::SerializeForWebhook.call(submitter))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendFormViewedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -19,19 +17,8 @@ class SendFormViewedWebhookRequestJob
|
||||
|
||||
ActiveStorage::Current.url_options = Docuseal.default_url_options
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'form.viewed',
|
||||
timestamp: Time.current,
|
||||
data: Submitters::SerializeForWebhook.call(submitter)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'form.viewed',
|
||||
data: Submitters::SerializeForWebhook.call(submitter))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendSubmissionArchivedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -17,19 +15,8 @@ class SendSubmissionArchivedWebhookRequestJob
|
||||
|
||||
return if webhook_url.url.blank? || webhook_url.events.exclude?('submission.archived')
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'submission.archived',
|
||||
timestamp: Time.current,
|
||||
data: submission.as_json(only: %i[id archived_at])
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'submission.archived',
|
||||
data: submission.as_json(only: %i[id archived_at]))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendSubmissionCompletedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -17,19 +15,8 @@ class SendSubmissionCompletedWebhookRequestJob
|
||||
|
||||
return if webhook_url.url.blank? || webhook_url.events.exclude?('submission.completed')
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'submission.completed',
|
||||
timestamp: Time.current,
|
||||
data: Submissions::SerializeForApi.call(submission)
|
||||
}.to_json,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT,
|
||||
**webhook_url.secret.to_h)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'submission.completed',
|
||||
data: Submissions::SerializeForApi.call(submission))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendSubmissionCreatedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -17,19 +15,8 @@ class SendSubmissionCreatedWebhookRequestJob
|
||||
|
||||
return if webhook_url.url.blank? || webhook_url.events.exclude?('submission.created')
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'submission.created',
|
||||
timestamp: Time.current,
|
||||
data: Submissions::SerializeForApi.call(submission)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'submission.created',
|
||||
data: Submissions::SerializeForApi.call(submission))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendTemplateCreatedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -17,19 +15,8 @@ class SendTemplateCreatedWebhookRequestJob
|
||||
|
||||
return if webhook_url.url.blank? || webhook_url.events.exclude?('template.created')
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'template.created',
|
||||
timestamp: Time.current,
|
||||
data: Templates::SerializeForApi.call(template)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'template.created',
|
||||
data: Templates::SerializeForApi.call(template))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -5,8 +5,6 @@ class SendTemplateUpdatedWebhookRequestJob
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
@@ -17,19 +15,8 @@ class SendTemplateUpdatedWebhookRequestJob
|
||||
|
||||
return if webhook_url.url.blank? || webhook_url.events.exclude?('template.updated')
|
||||
|
||||
resp = begin
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'template.updated',
|
||||
timestamp: Time.current,
|
||||
data: Templates::SerializeForApi.call(template)
|
||||
}.to_json,
|
||||
**webhook_url.secret.to_h,
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => USER_AGENT)
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
resp = SendWebhookRequest.call(webhook_url, event_type: 'template.updated',
|
||||
data: Templates::SerializeForApi.call(template))
|
||||
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<%= render 'shared/navbar_warning' %>
|
||||
<div class="max-w-6xl mb-4 mx-auto px-4 md:px-2 py-3 flex items-center justify-between">
|
||||
<div class="flex items-center space-x-4">
|
||||
<a href="<%= root_path %>" class="text-2xl font-bold items-center flex space-x-2">
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<div class="group border border-base-300 rounded-md px-2 py-1 mb-1">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span class="mx-1 w-3 h-3 shrink-0 rounded-full <%= colors[index] %>"></span>
|
||||
<span class="mx-1 w-3 h-3 shrink-0 rounded-full <%= colors[index % 10] %>"></span>
|
||||
<span class="text-lg" dir="auto">
|
||||
<%= (@submission.template_submitters || @submission.template.submitters).find { |e| e['uuid'] == submitter&.uuid }&.dig('name') || "#{(index + 1).ordinalize} Submitter" %>
|
||||
</span>
|
||||
@@ -190,6 +190,11 @@
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if signed_in? && submitter && submitter.completed_at? && submitter.email == current_user.email && submitter.completed_at > 1.month.ago && can?(:update, @submission) %>
|
||||
<div class="mt-2 mb-1">
|
||||
<%= button_to t('resubmit'), submitters_resubmit_path(submitter), method: :put, class: 'btn btn-sm btn-primary w-full', form: { target: '_blank' }, data: { turbo: false } %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-1.5 mb-4">
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
</download-button>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if Templates.filter_undefined_submitters(@submitter.submission.template).size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && !@submitter.template.archived_at? %>
|
||||
<% undefined_submitters = Templates.filter_undefined_submitters(@submitter.submission.template) %>
|
||||
<% if undefined_submitters.size == 1 && undefined_submitters.first['uuid'] == @submitter.uuid && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && !@submitter.template.archived_at? %>
|
||||
<div class="divider uppercase"><%= t('or') %></div>
|
||||
<toggle-submit class="block">
|
||||
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@submitter.submission.template.slug), params: { submitter: { email: @submitter.email, phone: @submitter.phone, name: @submitter.name }, resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
||||
|
||||
+18
-6
@@ -165,7 +165,7 @@ en: &en
|
||||
schedule_account_for_deletion_: Schedule account for deletion?
|
||||
account_information_has_been_updated: Account information has been updated.
|
||||
should_be_a_valid_url: should be a valid URL
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: Your account removal request will be processed within 2 weeks. Please contact us if you want to keep your account.
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: Your account removal request will be processed within 2 months. Please contact us if you want to keep your account.
|
||||
test_mode: Test mode
|
||||
copy: Copy
|
||||
copied: Copied
|
||||
@@ -688,6 +688,8 @@ en: &en
|
||||
tell_us_more_about_your_experience: Tell us more about your experience
|
||||
extremely_dissatisfied: Extremely Dissatisfied
|
||||
extremely_satisfied: Extremely Satisfied
|
||||
your_pro_plan_payment_is_overdue: Your Pro plan payment is overdue.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: <a href="%{url}" class="link">Click here</a> to update your payment details and clear the invoice to ensure uninterrupted service.
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>Email sent</b> to %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>Reminder email sent</b> to %{submitter_name}'
|
||||
@@ -873,7 +875,7 @@ es: &es
|
||||
schedule_account_for_deletion_: ¿Programar la eliminación de la cuenta?
|
||||
account_information_has_been_updated: La información de la cuenta ha sido actualizada.
|
||||
should_be_a_valid_url: debe ser una URL válida
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: Tu solicitud de eliminación de cuenta se procesará en un plazo de 2 semanas. Por favor contáctanos si deseas mantener tu cuenta.
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: Tu solicitud de eliminación de cuenta se procesará en un plazo de 2 meses. Por favor contáctanos si deseas mantener tu cuenta.
|
||||
test_mode: Modo de prueba
|
||||
copy: Copiar
|
||||
copied: Copiado
|
||||
@@ -1396,6 +1398,8 @@ es: &es
|
||||
tell_us_more_about_your_experience: Cuéntanos más sobre tu experiencia
|
||||
extremely_dissatisfied: Extremadamente insatisfecho
|
||||
extremely_satisfied: Extremadamente satisfecho
|
||||
your_pro_plan_payment_is_overdue: El pago de tu plan Pro está atrasado.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: '<a href="%{url}" class="link">Haz clic aquí</a> para actualizar tus datos de pago y liquidar la factura para garantizar un servicio ininterrumpido.'
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>Correo electrónico enviado</b> a %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>Correo de recordatorio enviado</b> a %{submitter_name}'
|
||||
@@ -1580,7 +1584,7 @@ it: &it
|
||||
schedule_account_for_deletion_: "Programmare l'eliminazione dell'account?"
|
||||
account_information_has_been_updated: "Le informazioni dell'account sono state aggiornate."
|
||||
should_be_a_valid_url: deve essere un URL valido
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: "La tua richiesta di rimozione dell'account sarà elaborata entro 2 settimane. Contattaci se desideri mantenere il tuo account."
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: "La tua richiesta di rimozione dell'account sarà elaborata entro 2 mesi. Contattaci se desideri mantenere il tuo account."
|
||||
test_mode: Modalità di test
|
||||
copy: Copia
|
||||
copied: Copiato
|
||||
@@ -2103,6 +2107,8 @@ it: &it
|
||||
tell_us_more_about_your_experience: Raccontaci di più sulla tua esperienza
|
||||
extremely_dissatisfied: Estremamente insoddisfatto
|
||||
extremely_satisfied: Estremamente soddisfatto
|
||||
your_pro_plan_payment_is_overdue: Il pagamento del tuo piano Pro è in ritardo.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: '<a href="%{url}" class="link">Fai clic qui</a> per aggiornare i tuoi dati di pagamento e saldare la fattura per garantire un servizio ininterrotto.'
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>E-mail inviato</b> a %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>E-mail di promemoria inviato</b> a %{submitter_name}'
|
||||
@@ -2289,7 +2295,7 @@ fr: &fr
|
||||
schedule_account_for_deletion_: Programmer la suppression du compte?
|
||||
account_information_has_been_updated: Les informations du compte ont été mises à jour.
|
||||
should_be_a_valid_url: doit être une URL valide
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: Votre demande de suppression du compte sera traitée dans un délai de 2 semaines. Veuillez nous contacter si vous souhaitez conserver votre compte.
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: Votre demande de suppression du compte sera traitée dans un délai de 2 mois. Veuillez nous contacter si vous souhaitez conserver votre compte.
|
||||
test_mode: Mode test
|
||||
copy: Copier
|
||||
copied: Copié
|
||||
@@ -2812,6 +2818,8 @@ fr: &fr
|
||||
tell_us_more_about_your_experience: Parlez-nous davantage de votre expérience
|
||||
extremely_dissatisfied: Extrêmement insatisfait
|
||||
extremely_satisfied: Extrêmement satisfait
|
||||
your_pro_plan_payment_is_overdue: Le paiement de votre plan Pro est en retard.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: '<a href="%{url}" class="link">Cliquez ici</a> pour mettre à jour vos informations de paiement et régler la facture afin de garantir un service ininterrompu.'
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>E-mail envoyé</b> à %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>E-mail de rappel envoyé</b> à %{submitter_name}'
|
||||
@@ -2997,7 +3005,7 @@ pt: &pt
|
||||
schedule_account_for_deletion_: Agendar exclusão da conta?
|
||||
account_information_has_been_updated: As informações da conta foram atualizadas.
|
||||
should_be_a_valid_url: deve ser um URL válido
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: Seu pedido de remoção da conta será processado em até 2 semanas. Entre em contato conosco se você quiser manter sua conta.
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: Seu pedido de remoção da conta será processado em até 2 meses. Entre em contato conosco se você quiser manter sua conta.
|
||||
test_mode: Modo de teste
|
||||
copy: Copiar
|
||||
copied: Copiado
|
||||
@@ -3520,6 +3528,8 @@ pt: &pt
|
||||
tell_us_more_about_your_experience: Conte-nos mais sobre sua experiência
|
||||
extremely_dissatisfied: Extremamente insatisfeito
|
||||
extremely_satisfied: Extremamente satisfeito
|
||||
your_pro_plan_payment_is_overdue: O pagamento do seu plano Pro está atrasado.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: '<a href="%{url}" class="link">Clique aqui</a> para atualizar seus dados de pagamento e quitar a fatura para garantir um serviço ininterrupto.'
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>E-mail enviado</b> para %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>E-mail de lembrete enviado</b> para %{submitter_name}'
|
||||
@@ -3705,7 +3715,7 @@ de: &de
|
||||
schedule_account_for_deletion_: Konto zur Löschung einplanen?
|
||||
account_information_has_been_updated: Die Kontoinformationen wurden aktualisiert.
|
||||
should_be_a_valid_url: sollte eine gültige URL sein
|
||||
your_account_removal_request_will_be_processed_within_2_weeks_please_contact_us_if_you_want_to_keep_your_account: Deine Anfrage zur Kontolöschung wird innerhalb von 2 Wochen bearbeitet. Bitte kontaktiere uns, wenn du dein Konto behalten möchtest.
|
||||
your_account_removal_request_will_be_processed_within_2_months_please_contact_us_if_you_want_to_keep_your_account: Deine Anfrage zur Kontolöschung wird innerhalb von 2 Monaten bearbeitet. Bitte kontaktiere uns, wenn du dein Konto behalten möchtest.
|
||||
test_mode: Testmodus
|
||||
copy: Kopieren
|
||||
copied: Kopiert
|
||||
@@ -4228,6 +4238,8 @@ de: &de
|
||||
tell_us_more_about_your_experience: Erzählen Sie uns mehr über Ihre Erfahrung
|
||||
extremely_dissatisfied: Extrem unzufrieden
|
||||
extremely_satisfied: Extrem zufrieden
|
||||
your_pro_plan_payment_is_overdue: Ihre Zahlung für den Pro-Plan ist überfällig.
|
||||
click_here_to_update_your_payment_details_and_clear_the_invoice_to_ensure_uninterrupted_service_html: '<a href="%{url}" class="link">Klicken Sie hier</a>, um Ihre Zahlungsdaten zu aktualisieren und die Rechnung zu begleichen, um einen unterbrechungsfreien Service sicherzustellen.'
|
||||
submission_event_names:
|
||||
send_email_to_html: '<b>E-Mail gesendet</b> an %{submitter_name}'
|
||||
send_reminder_email_to_html: '<b>Erinnerungs-E-Mail gesendet</b> an %{submitter_name}'
|
||||
|
||||
@@ -79,6 +79,7 @@ Rails.application.routes.draw do
|
||||
resource :testing_account, only: %i[show destroy]
|
||||
resources :testing_api_settings, only: %i[index]
|
||||
resources :submitters_autocomplete, only: %i[index]
|
||||
resources :submitters_resubmit, only: %i[update]
|
||||
resources :template_folders_autocomplete, only: %i[index]
|
||||
resources :webhook_secret, only: %i[show update]
|
||||
resources :webhook_preferences, only: %i[update]
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SendWebhookRequest
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
module_function
|
||||
|
||||
def call(webhook_url, event_type:, data:)
|
||||
Faraday.post(webhook_url.url) do |req|
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.headers['User-Agent'] = USER_AGENT
|
||||
req.headers.merge!(webhook_url.secret.to_h) if webhook_url.secret.present?
|
||||
|
||||
req.body = {
|
||||
event_type: event_type,
|
||||
timestamp: Time.current,
|
||||
data: data
|
||||
}.to_json
|
||||
|
||||
req.options.read_timeout = 8
|
||||
req.options.open_timeout = 8
|
||||
end
|
||||
rescue Faraday::Error
|
||||
nil
|
||||
end
|
||||
end
|
||||
+18
-11
@@ -107,20 +107,27 @@ module Submissions
|
||||
|
||||
def normalize_email(email)
|
||||
return if email.blank?
|
||||
return email.downcase if email.to_s.include?(',')
|
||||
return email.downcase if email.to_s.include?('.gob')
|
||||
return email.downcase if email.to_s.include?('.om')
|
||||
return email.downcase if email.to_s.include?('.mm')
|
||||
return email.downcase if email.to_s.include?('.cm')
|
||||
return email.downcase if email.to_s.include?('.et')
|
||||
return email.downcase if email.to_s.include?('.mo')
|
||||
return email.downcase if email.to_s.include?('.nz')
|
||||
return email.downcase if email.to_s.include?('.za')
|
||||
return email.downcase unless email.to_s.include?('.')
|
||||
|
||||
return email.downcase if email.to_s.include?(',') ||
|
||||
email.to_s.match?(/\.(?:gob|om|mm|cm|et|mo|nz|za|ie)\z/) ||
|
||||
email.to_s.exclude?('.')
|
||||
|
||||
fixed_email = EmailTypo.call(email.delete_prefix('<'))
|
||||
|
||||
Rails.logger.info("Fixed email #{email.split('@').last}") if fixed_email != email.downcase.delete_prefix('<').strip
|
||||
return fixed_email if fixed_email == email
|
||||
|
||||
domain = email.to_s.split('@').last.to_s.downcase
|
||||
fixed_domain = fixed_email.to_s.split('@').last
|
||||
|
||||
return email.downcase if domain == fixed_domain
|
||||
|
||||
if DidYouMean::Levenshtein.distance(domain, fixed_domain) > 3
|
||||
Rails.logger.info("Skipped email fix #{domain}")
|
||||
|
||||
return email.downcase
|
||||
end
|
||||
|
||||
Rails.logger.info("Fixed email #{domain}") if fixed_email != email.downcase.delete_prefix('<').strip
|
||||
|
||||
fixed_email
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user