From 8f804e376afdadcdc3303bdbc2ae40c92fac8a3f Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 3 Jul 2021 03:28:29 +0200 Subject: [PATCH 1/3] Don't export chat_enabled flag anymore The chat is already removed for 0.8, so there is no need to still export this data since it can't be imported anyway. Related to #8069 closes #8265 --- Changelog.md | 1 + app/serializers/export/aspect_serializer.rb | 2 +- lib/schemas/archive-format.json | 3 +-- spec/integration/exporter_spec.rb | 6 ++---- spec/serializers/export/aspect_serializer_spec.rb | 3 +-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index c8fabc745..1aac93634 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Refactor * Cache local posts/comments count for statistics [#8241](https://github.com/diaspora/diaspora/pull/8241) * Fix html-syntax in some handlebars templates [#8251](https://github.com/diaspora/diaspora/pull/8251) +* Remove `chat_enabled` flag from archive export [#8265](https://github.com/diaspora/diaspora/pull/8265) ## Bug fixes diff --git a/app/serializers/export/aspect_serializer.rb b/app/serializers/export/aspect_serializer.rb index 938939ad9..478bef3fa 100644 --- a/app/serializers/export/aspect_serializer.rb +++ b/app/serializers/export/aspect_serializer.rb @@ -2,6 +2,6 @@ module Export class AspectSerializer < ActiveModel::Serializer - attributes :name, :chat_enabled + attributes :name end end diff --git a/lib/schemas/archive-format.json b/lib/schemas/archive-format.json index 9d839c5ac..79105232d 100644 --- a/lib/schemas/archive-format.json +++ b/lib/schemas/archive-format.json @@ -35,8 +35,7 @@ "items": { "type": "object", "properties": { - "name": { "type": "string" }, - "chat_enabled": { "type": "boolean" } + "name": { "type": "string" } }, "required": [ "name" diff --git a/spec/integration/exporter_spec.rb b/spec/integration/exporter_spec.rb index ac9bdbfd9..7794c07de 100644 --- a/spec/integration/exporter_spec.rb +++ b/spec/integration/exporter_spec.rb @@ -46,12 +46,10 @@ describe Diaspora::Exporter do user: { "contact_groups": [ { - "name": "generic", - "chat_enabled": false + "name": "generic" }, { - "name": "Work", - "chat_enabled": false + "name": "Work" } ] } diff --git a/spec/serializers/export/aspect_serializer_spec.rb b/spec/serializers/export/aspect_serializer_spec.rb index eba297f19..41ea5e874 100644 --- a/spec/serializers/export/aspect_serializer_spec.rb +++ b/spec/serializers/export/aspect_serializer_spec.rb @@ -6,8 +6,7 @@ describe Export::AspectSerializer do it "has aspect attributes" do expect(serializer.attributes).to eq( - name: aspect.name, - chat_enabled: aspect.chat_enabled + name: aspect.name ) end end From 407f51d5a31088f84c42d8f84293373302eeea2b Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Sun, 4 Jul 2021 20:34:07 +0200 Subject: [PATCH 2/3] Allow points and dashes in the username. This reverts b3ca504c4000f912d6599d4f100b1e0262fbfa46. We don't quite know why that was added, but we assume it's because of format strings. Some pre-2011 users exist that still have dots or dashes in their username, and those accounts are somewhat broken now. closes #8266 --- Changelog.md | 1 + app/models/user.rb | 6 ++---- app/views/registrations/_form.haml | 2 +- config/routes.rb | 6 +++++- spec/models/user_spec.rb | 5 ----- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1aac93634..9287182bd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ ## Features * Add tags to tumblr posts [#8244](https://github.com/diaspora/diaspora/pull/8244) * Add blocks to the archive export [#8263](https://github.com/diaspora/diaspora/pull/8263) +* Allow points and dashes in the username [#8266](https://github.com/diaspora/diaspora/pull/8266) # 0.7.15.0 diff --git a/app/models/user.rb b/app/models/user.rb index bfc97325b..14eb4562c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,10 +36,8 @@ class User < ApplicationRecord before_validation :set_current_language, :on => :create before_validation :set_default_color_theme, on: :create - validates :username, :presence => true, :uniqueness => true - validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/ - validates_length_of :username, :maximum => 32 - validates_exclusion_of :username, :in => AppConfig.settings.username_blacklist + validates :username, presence: true, uniqueness: true, format: {with: /\A[A-Za-z0-9_.\-]+\z/}, + length: {maximum: 32}, exclusion: {in: AppConfig.settings.username_blacklist} validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES validates :color_theme, inclusion: {in: AVAILABLE_COLOR_THEMES}, allow_blank: true validates_format_of :unconfirmed_email, :with => Devise.email_regexp, :allow_blank => true diff --git a/app/views/registrations/_form.haml b/app/views/registrations/_form.haml index 9cd6ce0f7..b9f99cfa5 100644 --- a/app/views/registrations/_form.haml +++ b/app/views/registrations/_form.haml @@ -32,7 +32,7 @@ placeholder: t("registrations.new.username"), title: t("registrations.new.enter_username"), required: true, - pattern: "[A-Za-z0-9_]+", + pattern: "[A-Za-z0-9_.\-]+", aria: {labelledby: "usernameLabel"} - if mobile diff --git a/config/routes.rb b/config/routes.rb index 8a4f45ebe..bd624d1f4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -186,7 +186,11 @@ Rails.application.routes.draw do post 'by_handle' => :retrieve_remote, :as => 'person_by_handle' end end - get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ } + + # Note: The contraint for this route's username parameter cannot be removed. + # This constraint turns off the format parameter, so that an username + # doctor.example would not try to render the user `doctor` in `example` format. + get "/u/:username" => "people#show", :as => "user_profile", :constraints => {username: %r{[^/]+}} # External diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 560432927..f457c9b28 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -267,11 +267,6 @@ describe User, :type => :model do expect(alice).not_to be_valid end - it 'should not contain periods' do - alice.username = "kittens." - expect(alice).not_to be_valid - end - it "can be 32 characters long" do alice.username = "hexagoooooooooooooooooooooooooon" expect(alice).to be_valid From 805a35e985262d07425221410d3cc9f06da5ebe1 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Sun, 4 Jul 2021 20:36:44 +0200 Subject: [PATCH 3/3] Point /protocol route to the current federation documentation. --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index bd624d1f4..73bd3a383 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -213,7 +213,7 @@ Rails.application.routes.draw do get 'help/:topic' => 'help#faq' #Protocol Url - get "protocol" => redirect("https://wiki.diasporafoundation.org/Federation_Protocol_Overview") + get "protocol" => redirect("https://diaspora.github.io/diaspora_federation/") # NodeInfo get ".well-known/nodeinfo", to: "node_info#jrd"