Skip to content
Merged
Show file tree
Hide file tree
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 Nov 5, 2024
f643019
fix: Update Webpacker configurations (#121)
Quentinchampenois Nov 7, 2024
b6aa45a
fix: Decidim awesome slowness on proposals index page (#123)
Quentinchampenois Nov 14, 2024
4573247
fix: Adjust probability score for spam detection (#124)
Quentinchampenois Nov 22, 2024
c5367b2
feat: Export proposals attachments url (#126)
Quentinchampenois Dec 4, 2024
2b28f6d
merge: Sync master
Quentinchampenois Dec 4, 2024
2069404
fix: Separator in attachment urls (#127)
Quentinchampenois Dec 6, 2024
bbf4025
feat: Addition of Half Signup (#128)
AyakorK Dec 26, 2024
757170d
Backport: fix Half sign up (#130)
luciegrau Feb 14, 2025
8c2f272
add method moderator? in user extend model (#132)
BarbaraOliveira13 Feb 18, 2025
003d0f8
Fix/admin proposals answers import (#131)
Stef-Rousset Feb 18, 2025
68c99d4
fix: Remove config entry to enforce OSM default over HERE (#133)
AyakorK Mar 3, 2025
482b0b6
add survey-multiple-answers module
BarbaraOliveira13 Mar 18, 2025
9c83682
Merge pull request #135 from OpenSourcePolitics/feature/add-survey-mu…
luciegrau Mar 21, 2025
7a978c9
bump: budget booth
Stef-Rousset Apr 9, 2025
4a1f60f
Revert "bump: budget booth"
Stef-Rousset Apr 9, 2025
56a4bf3
bump: budget booth
Stef-Rousset Apr 9, 2025
178e58e
ci: try fixing CI
Stef-Rousset Apr 9, 2025
19d80ce
fix: update package-lock.json
Stef-Rousset Apr 9, 2025
24faf91
Merge pull request #139 from OpenSourcePolitics/bump/budget_booth
luciegrau Apr 9, 2025
5e5136c
bump: budget_booth
Stef-Rousset Apr 16, 2025
8a6d1be
Merge pull request #140 from OpenSourcePolitics/bump/last_budget_boot…
luciegrau Apr 17, 2025
89adb9f
bump: Half signup to last release
AyakorK Apr 25, 2025
b5199ae
feat: Add static locales to avoid awesome unstable issues
AyakorK Apr 25, 2025
922e72b
Merge pull request #142 from OpenSourcePolitics/bump/half_signup
luciegrau Apr 28, 2025
5013f9a
Merge pull request #143 from OpenSourcePolitics/feat/add_static_locales
luciegrau Apr 28, 2025
4f10db5
Merge branch 'master' into develop
Stef-Rousset Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ DECIDIM_SESSION_TIMEOUT=
# SKIP_FIRST_LOGIN_AUTHORIZATION=true
# RAILS_LOG_LEVEL=warn

# DECIDIM_AWESOME_WEIGHTED_PROPOSAL_VOTING_ENABLED=disabled # or enabled
# DECIDIM_AWESOME_WEIGHTED_PROPOSAL_VOTING_ENABLED=disabled # or enabled

# SMS_GATEWAY_SERVICE="Decidim::SmsGatewayService"
# SMS_GATEWAY_URL="https://sms.gateway.service/api"
# SMS_GATEWAY_BULK_URL="https://sms.gateway.service/api/bulk"
# SMS_GATEWAY_USERNAME=
# SMS_GATEWAY_PASSWORD=
## Set to replace the organization name
# SMS_GATEWAY_PLATFORM="hashimoto.local"

# Redirect to the TOS page after signup (default: true)
# DECIDIM_HALF_SIGNUP_SHOW_TOS_PAGE_AFTER_SIGNUP=true

16 changes: 14 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
SIMPLECOV: "true"
RSPEC_FORMAT: "documentation"
RUBY_VERSION: 3.0.6
CHROME_VERSION: 126.0.6478.182
RAILS_ENV: test
NODE_VERSION: 16.9.1
RUBYOPT: '-W:no-deprecated'
Expand Down Expand Up @@ -88,8 +89,12 @@ jobs:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- run: |
sudo apt update
sudo apt install libu2f-udev imagemagick
name: Install libu2f-udev and imagemagick
wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${{env.CHROME_VERSION}}-1_amd64.deb
sudo dpkg -i /tmp/chrome.deb
rm /tmp/chrome.deb
name: Install Chrome version ${{ env.CHROME_VERSION }}
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
Expand All @@ -108,6 +113,8 @@ jobs:
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: ${{ env.CHROME_VERSION }}
- run: bundle exec rake "test:run[exclude, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
Expand Down Expand Up @@ -158,7 +165,10 @@ jobs:
bundler-cache: true
- run: |
sudo apt install libu2f-udev imagemagick
name: Install libu2f-udev and imagemagick
wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${{env.CHROME_VERSION}}-1_amd64.deb
sudo dpkg -i /tmp/chrome.deb
rm /tmp/chrome.deb
name: Install Chrome version ${{ env.CHROME_VERSION }}
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
Expand All @@ -177,6 +187,8 @@ jobs:
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: ${{ env.CHROME_VERSION }}
- run: bundle exec rake "test:run[include, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ gem "decidim-budgets_paper_ballots", git: "https://github.com/digidemlab/decidim
gem "decidim-cache_cleaner"
gem "decidim-custom_proposal_states", git: "https://github.com/alecslupu-pfa/decidim-module-custom_proposal_states", branch: DECIDIM_BRANCH
gem "decidim-decidim_awesome", git: "https://github.com/decidim-ice/decidim-module-decidim_awesome", branch: DECIDIM_BRANCH
gem "decidim-extra_user_fields", git: "https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git", branch: DECIDIM_BRANCH
gem "decidim-extra_user_fields", git: "https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git", branch: "temp/twilio-compatibility-0.27"
gem "decidim-friendly_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git"
gem "decidim-half_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-half_sign_up.git", branch: "middleware-1.0.0"
gem "decidim-homepage_interactive_map", git: "https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git", branch: DECIDIM_BRANCH
gem "decidim-simple_proposal", git: "https://github.com/opensourcepolitics/decidim-module-simple_proposal.git", branch: DECIDIM_BRANCH
gem "decidim-slider", git: "https://github.com/OpenSourcePolitics/decidim-module-slider", branch: "rc/0.27"
gem "decidim-spam_detection", git: "https://github.com/OpenSourcePolitics/decidim-spam_detection.git", tag: "4.1.2"
gem "decidim-survey_multiple_answers", git: "https://github.com/OpenSourcePolitics/decidim-module-survey_multiple_answers"
gem "decidim-term_customizer", git: "https://github.com/opensourcepolitics/decidim-module-term_customizer.git", branch: "fix/multi-threading-compliant"

# Omniauth gems
Expand Down
33 changes: 28 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git
revision: 25f5a7843a38a5f9360f9bd42eb7e246d997bc7b
branch: release/0.27-stable
revision: 40edb6a73ee1e21fa939392bcdcd8c0820436460
branch: temp/twilio-compatibility-0.27
specs:
decidim-extra_user_fields (0.27.2)
country_select (~> 9.0)
Expand All @@ -23,6 +23,15 @@ GIT
decidim-friendly_signup (0.4.6)
decidim-core (~> 0.27)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-half_sign_up.git
revision: b449e37dca1a51fc03824b6f37811b18806febe5
branch: middleware-1.0.0
specs:
decidim-half_signup (0.27.0)
countries (~> 5.1, >= 5.1.2)
decidim-core (~> 0.27.0)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git
revision: 1ff222533cb3e7c30c8112a56c09c217c0530dbc
Expand All @@ -37,7 +46,7 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-ptp.git
revision: 46bb834a68d52cd7d1d4bba6182cca55f2495125
revision: 9f02c08e6715deb3c32569ecd4ec3a4385fd2b00
specs:
decidim-budgets_booth (0.27.0)
decidim-budgets (~> 0.27.0)
Expand All @@ -51,6 +60,16 @@ GIT
decidim-slider (0.0.3)
decidim-core (~> 0.27.0)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-survey_multiple_answers
revision: 65ea83227f99d0f3d6237f98334ecc914a2a5597
specs:
decidim-survey_multiple_answers (0.26.2)
decidim-admin (>= 0.26.0, < 0.28.0)
decidim-core (>= 0.26.0, < 0.28.0)
decidim-forms (>= 0.26.0, < 0.28.0)
decidim-surveys (>= 0.26.0, < 0.28.0)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-spam_detection.git
revision: 5e4f92f19b903228b8349fb002d735e900d63ed4
Expand Down Expand Up @@ -288,7 +307,7 @@ GEM
commonmarker (0.23.10)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
countries (6.0.1)
countries (5.7.2)
unaccent (~> 0.3)
country_select (9.0.0)
countries (> 5.0, < 7.0)
Expand Down Expand Up @@ -542,6 +561,8 @@ GEM
faraday-net_http (3.1.0)
net-http
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-darwin)
file_validators (3.0.0)
activemodel (>= 3.2)
mime-types (>= 1.0)
Expand Down Expand Up @@ -1051,10 +1072,12 @@ DEPENDENCIES
decidim-dev (~> 0.27.0)
decidim-extra_user_fields!
decidim-friendly_signup!
decidim-half_signup!
decidim-homepage_interactive_map!
decidim-simple_proposal!
decidim-slider!
decidim-spam_detection!
decidim-survey_multiple_answers!
decidim-term_customizer!
dotenv-rails
faker (~> 2.14)
Expand Down Expand Up @@ -1090,4 +1113,4 @@ RUBY VERSION
ruby 3.0.6p216

BUNDLED WITH
2.4.6
2.5.10
80 changes: 80 additions & 0 deletions app/jobs/archive_users_phone_job.rb
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
24 changes: 24 additions & 0 deletions app/jobs/concerns/decidim/logging.rb
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
51 changes: 51 additions & 0 deletions app/services/decidim/sms_gateway_service.rb
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
Loading
Loading