-
Notifications
You must be signed in to change notification settings - Fork 2
release: half sign up, multiple answers and translations #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6868e5f
fix: Disable author tooltip (#113)
Quentinchampenois f643019
fix: Update Webpacker configurations (#121)
Quentinchampenois b6aa45a
fix: Decidim awesome slowness on proposals index page (#123)
Quentinchampenois 4573247
fix: Adjust probability score for spam detection (#124)
Quentinchampenois c5367b2
feat: Export proposals attachments url (#126)
Quentinchampenois 2b28f6d
merge: Sync master
Quentinchampenois 2069404
fix: Separator in attachment urls (#127)
Quentinchampenois bbf4025
feat: Addition of Half Signup (#128)
AyakorK 757170d
Backport: fix Half sign up (#130)
luciegrau 8c2f272
add method moderator? in user extend model (#132)
BarbaraOliveira13 003d0f8
Fix/admin proposals answers import (#131)
Stef-Rousset 68c99d4
fix: Remove config entry to enforce OSM default over HERE (#133)
AyakorK 482b0b6
add survey-multiple-answers module
BarbaraOliveira13 9c83682
Merge pull request #135 from OpenSourcePolitics/feature/add-survey-mu…
luciegrau 7a978c9
bump: budget booth
Stef-Rousset 4a1f60f
Revert "bump: budget booth"
Stef-Rousset 56a4bf3
bump: budget booth
Stef-Rousset 178e58e
ci: try fixing CI
Stef-Rousset 19d80ce
fix: update package-lock.json
Stef-Rousset 24faf91
Merge pull request #139 from OpenSourcePolitics/bump/budget_booth
luciegrau 5e5136c
bump: budget_booth
Stef-Rousset 8a6d1be
Merge pull request #140 from OpenSourcePolitics/bump/last_budget_boot…
luciegrau 89adb9f
bump: Half signup to last release
AyakorK b5199ae
feat: Add static locales to avoid awesome unstable issues
AyakorK 922e72b
Merge pull request #142 from OpenSourcePolitics/bump/half_signup
luciegrau 5013f9a
Merge pull request #143 from OpenSourcePolitics/feat/add_static_locales
luciegrau 4f10db5
Merge branch 'master' into develop
Stef-Rousset File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ArchiveUsersPhoneJob < ApplicationJob | ||
| include Decidim::Logging | ||
|
|
||
| def perform | ||
| metrics = { total: 0, quick_auth_users: 0, decidim_users: 0 } | ||
| log! "Start clearing phone numbers from accounts..." | ||
|
|
||
| users_to_archive.find_in_batches(batch_size: 1000) do |users| | ||
| users.each do |user| | ||
| metrics[:total] += 1 | ||
|
|
||
| if user.email.include?("quick_auth") | ||
| metrics[:quick_auth_users] += 1 | ||
| soft_delete_user(user, delete_reason) | ||
| else | ||
| metrics[:decidim_users] += 1 | ||
| clear_account_phone_number(user) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| log! "Total distinct numbers to clear : #{metrics[:total]}" | ||
| log! "Half signup users archived : #{metrics[:quick_auth_users]}" | ||
| log! "Decidim users account updated : #{metrics[:decidim_users]}" | ||
| log! "Terminated !" | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def users_to_archive | ||
| Decidim::User.where.not(phone_number: [nil, ""]).where.not(phone_country: [nil, ""]) | ||
| end | ||
|
|
||
| def soft_delete_user(user, reason) | ||
| email = user.email | ||
| phone = user.phone_number | ||
| user.extended_data = user.extended_data.merge({ | ||
| half_signup: { | ||
| email: email, | ||
| phone_number: phone, | ||
| phone_country: user.phone_country | ||
| } | ||
| }) | ||
|
|
||
| user.phone_number = nil | ||
| user.phone_country = nil | ||
|
|
||
| form = Decidim::DeleteAccountForm.from_params(delete_reason: reason) | ||
| Decidim::DestroyAccount.call(user, form) do | ||
| on(:invalid) do | ||
| log!("User (ID/#{user.id} email/#{email} phone/#{obfuscate_phone_number(phone)}) cannot be deleted: #{form.errors.full_messages}") | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def clear_account_phone_number(user) | ||
| Decidim::User.transaction do | ||
| user.extended_data = user.extended_data.merge({ | ||
| half_signup: { | ||
| phone_number: user.phone_number, | ||
| phone_country: user.phone_country | ||
| } | ||
| }) | ||
|
|
||
| user.phone_number = nil | ||
| user.phone_country = nil | ||
| user.save(validate: false) | ||
| end | ||
| end | ||
|
|
||
| def current_date | ||
| Date.current.strftime "%Y-%m-%d" | ||
| end | ||
|
|
||
| def delete_reason | ||
| "Archived account - #{current_date}" | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Decidim | ||
| module Logging | ||
| private | ||
|
|
||
| def log!(msg, level = :warn) | ||
| msg = "(#{self.class})> #{msg}" | ||
|
|
||
| case level | ||
| when :info | ||
| Rails.logger.info msg | ||
| stdout_logger.info msg unless Rails.env.test? | ||
| else | ||
| Rails.logger.warn msg | ||
| stdout_logger.warn msg unless Rails.env.test? | ||
| end | ||
| end | ||
|
|
||
| def stdout_logger | ||
| @stdout_logger ||= Logger.new($stdout) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "uri" | ||
| require "net/http" | ||
|
|
||
| module Decidim | ||
| class SmsGatewayService | ||
| attr_reader :mobile_phone_number, :code | ||
|
|
||
| def initialize(mobile_phone_number, code, sms_gateway_context = {}) | ||
| Rails.logger.debug { "#{mobile_phone_number} - #{code}" } | ||
|
|
||
| @mobile_phone_number = mobile_phone_number | ||
| @code = code | ||
| @organization_name = sms_gateway_context[:organization]&.name | ||
| @url = fetch_configuration(:url) | ||
| @username = fetch_configuration(:username) | ||
| @password = fetch_configuration(:password) | ||
| @message = sms_message | ||
| @type = "sms" | ||
| end | ||
|
|
||
| def deliver_code | ||
| url = URI("#{@url}?u=#{@username}&p=#{@password}&t=#{@message}&n=#{@mobile_phone_number}&f=#{@type}") | ||
| https = Net::HTTP.new(url.host, url.port) | ||
| https.use_ssl = true | ||
| request = Net::HTTP::Get.new(url) | ||
| https.request(request) | ||
|
|
||
| true | ||
| end | ||
|
|
||
| # Ensure '@code' is not a full i18n keys rather than a verification code. | ||
| def sms_message | ||
| return code if code.to_s.length > Decidim::HalfSignup.auth_code_length | ||
|
|
||
| platform = fetch_configuration(:platform, required: false).presence || @organization_name | ||
| I18n.t("sms_verification_workflow.message", code: code, platform: platform) | ||
| end | ||
|
|
||
| def fetch_configuration(key, required: true) | ||
| value = Rails.application.secrets.dig(:decidim, :sms_gateway, key.to_sym) | ||
| if required && value.blank? | ||
| Rails.logger.error "Decidim::SmsGatewayService is missing a configuration value for :#{key}, " \ | ||
| "please check Rails.application.secrets.dig(:decidim, :sms_gateway, :#{key}) " \ | ||
| "or environment variable SMS_GATEWAY_#{key.to_s.upcase}" | ||
| end | ||
| value | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.