Replace hyphen with underscore in Mastodon address
Unfortunately, Mastodon only allows underscores for usernames, and reversely, akkounts only allows hyphens and no underscores.
This commit is contained in:
parent
e6f5623c7f
commit
0367450c4b
@ -131,7 +131,7 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
def mastodon_address
|
def mastodon_address
|
||||||
return nil unless Setting.mastodon_enabled?
|
return nil unless Setting.mastodon_enabled?
|
||||||
"#{self.cn}@#{Setting.mastodon_address_domain}"
|
"#{self.cn.gsub("-", "_")}@#{Setting.mastodon_address_domain}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_attribute?(attribute_name)
|
def valid_attribute?(attribute_name)
|
||||||
|
@ -41,6 +41,14 @@ RSpec.describe User, type: :model do
|
|||||||
expect(user.mastodon_address).to eq("jimmy@kosmos.social")
|
expect(user.mastodon_address).to eq("jimmy@kosmos.social")
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user