From e6f5623c7f77dd6d48ed1e492439806237640c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 29 Mar 2024 09:02:12 +0400 Subject: [PATCH 1/3] Enable Mastodon service by default (for now) --- app/models/setting.rb | 2 +- spec/models/user_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/setting.rb b/app/models/setting.rb index c00152a..1d895b2 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -209,6 +209,6 @@ class Setting < RailsSettings::Base def self.default_services # TODO Make configurable from respective service settings page - %w[ discourse gitea mediawiki xmpp ] + %w[ discourse gitea mastodon mediawiki xmpp ] end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 249ac61..6e7300d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -147,7 +147,7 @@ RSpec.describe User, type: :model do after { clear_enqueued_jobs } it "enables default services" do - expect(user).to receive(:enable_service).with(%w[ discourse gitea mediawiki xmpp ]) + expect(user).to receive(:enable_service).with(%w[ discourse gitea mastodon mediawiki xmpp ]) user.send :devise_after_confirmation end From 0367450c4b6e1f4069baf537ffef08c714c5037b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 29 Mar 2024 09:08:15 +0400 Subject: [PATCH 2/3] Replace hyphen with underscore in Mastodon address Unfortunately, Mastodon only allows underscores for usernames, and reversely, akkounts only allows hyphens and no underscores. --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2169402..f0609a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,7 +131,7 @@ class User < ApplicationRecord def mastodon_address return nil unless Setting.mastodon_enabled? - "#{self.cn}@#{Setting.mastodon_address_domain}" + "#{self.cn.gsub("-", "_")}@#{Setting.mastodon_address_domain}" end def valid_attribute?(attribute_name) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 6e7300d..b0d077e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -41,6 +41,14 @@ RSpec.describe User, type: :model do expect(user.mastodon_address).to eq("jimmy@kosmos.social") end end + + describe "username contains hyphen/dash" do + let(:jammy) { build :user, cn: "jammy-jellyfish", ou: "kosmos.org" } + + it "returns the user address" do + expect(jammy.mastodon_address).to eq("jammy_jellyfish@kosmos.org") + end + end end end From 8b608900619abf4ae8a5209baab7204d464daee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 29 Mar 2024 09:21:17 +0400 Subject: [PATCH 3/3] Add Phanpy to recommended Mastodon apps It's too good not to. --- app/views/services/mastodon/show.html.erb | 30 +++++++++- public/img/logos/icon_phanpy.svg | 67 +++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 public/img/logos/icon_phanpy.svg diff --git a/app/views/services/mastodon/show.html.erb b/app/views/services/mastodon/show.html.erb index 27a30e3..0e10c98 100644 --- a/app/views/services/mastodon/show.html.erb +++ b/app/views/services/mastodon/show.html.erb @@ -98,7 +98,17 @@ description: "The official Web app", icon_path: "/img/logos/icon_mastodon-2.svg", links: [ - ["Launch", "https://kosmos.social"] + ["Launch", "https://kosmos.social"], + ["GitHub", "https://github.com/mastodon/mastodon"] + ] + ) %> + <%= render AppInfoComponent.new( + name: "Phanpy", + description: " A slick, feature-rich Web app for mobile and desktop", + icon_path: "/img/logos/icon_phanpy.svg", + links: [ + ["Launch", "https://phanpy.social"], + ["GitHub", "https://github.com/cheeaun/phanpy"] ] ) %> <%= render AppInfoComponent.new( @@ -150,6 +160,15 @@ ["Google Play", "https://play.google.com/store/apps/details?id=org.joinmastodon.android.sk"] ] ) %> + <%= render AppInfoComponent.new( + name: "Phanpy", + description: " A slick, feature-rich Web app for mobile and desktop", + icon_path: "/img/logos/icon_phanpy.svg", + links: [ + ["Launch", "https://phanpy.social"], + ["GitHub", "https://github.com/cheeaun/phanpy"] + ] + ) %>