Skip to content

Commit

Permalink
Add: Groundpolis Gender
Browse files Browse the repository at this point in the history
  • Loading branch information
atsu1125 committed Dec 17, 2022
1 parent fcebbed commit acb4a31
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class Header extends ImmutablePureComponent {
const location = account.getIn(['other_settings', 'location']);
const birthday = account.getIn(['other_settings', 'birthday']);
const joined = account.get('created_at');
const gender = account.getIn(['other_settings', 'gender']);

return (
<div className={classNames('account__header', { inactive: !!account.get('moved') })} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
Expand Down Expand Up @@ -354,6 +355,10 @@ class Header extends ImmutablePureComponent {
<th><Icon id='birthday-cake' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.birthday' defaultMessage='Birthday' /></th>
<td><FormattedDate value={birthday} hour12={false} year='numeric' month='short' day='2-digit' />(<FormattedMessage id='account.age' defaultMessage='{age} years old}' values={{age: age(birthday)}} />)</td>
</tr>}
{gender && <tr>
<th><Icon id='sexIcon' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.gender' defaultMessage='Gender' /></th>
<td>{gender}</td>
</tr>}
<tr>
<th><Icon id='calendar' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.joined' defaultMessage='Joined' /></th>
<td><FormattedDate value={joined} hour12={false} year='numeric' month='short' day='2-digit' /></td>
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/mastodon/features/account/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class Header extends ImmutablePureComponent {
const location = account.getIn(['other_settings', 'location']);
const birthday = account.getIn(['other_settings', 'birthday']);
const joined = account.get('created_at');
const gender = account.getIn(['other_settings', 'gender']);

return (
<div className={classNames('account__header', { inactive: !!account.get('moved') })} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
Expand Down Expand Up @@ -354,6 +355,10 @@ class Header extends ImmutablePureComponent {
<th><Icon id='birthday-cake' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.birthday' defaultMessage='Birthday' /></th>
<td><FormattedDate value={birthday} hour12={false} year='numeric' month='short' day='2-digit' />(<FormattedMessage id='account.age' defaultMessage='{age} years old}' values={{age: age(birthday)}} />)</td>
</tr>}
{gender && <tr>
<th><Icon id='sexIcon' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.gender' defaultMessage='Gender' /></th>
<td>{gender}</td>
</tr>}
<tr>
<th><Icon id='calendar' fixedWidth aria-hidden='true' /> <FormattedMessage id='account.joined' defaultMessage='Joined' /></th>
<td><FormattedDate value={joined} hour12={false} year='numeric' month='short' day='2-digit' /></td>
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"account.following_counter": "{count, plural, one {{counter} Following} other {{counter} Following}}",
"account.follows.empty": "This user doesn't follow anyone yet.",
"account.follows_you": "Follows you",
"account.gender": "Gender",
"account.hide_reblogs": "Hide boosts from @{name}",
"account.joined": "Joined",
"account.last_status": "Last active",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"account.link_verified_on": "このリンクの所有権は{date}に確認されました",
"account.location": "場所",
"account.locked_info": "このアカウントは承認制アカウントです。相手が承認するまでフォローは完了しません。",
"account.gender": "性別",
"account.media": "メディア",
"account.mention": "@{name}さんに投稿",
"account.moved_to": "{name}さんは引っ越しました:",
Expand Down
5 changes: 5 additions & 0 deletions app/serializers/activitypub/actor_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
attribute :suspended, if: :suspended?
attribute :bday, key: :'vcard:bday'
attribute :address, key: :'vcard:Address'
attribute :gender, key: :'vcard:Gender'

has_many :virtual_other_settings, key: :other_setting

Expand Down Expand Up @@ -189,6 +190,10 @@ def address
object.location
end

def gender
object.gender
end

class CustomEmojiSerializer < ActivityPub::EmojiSerializer
end

Expand Down
8 changes: 7 additions & 1 deletion app/services/activitypub/process_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def set_immediate_attributes!
@account.note = @json['summary'] || ''
@account.locked = @json['manuallyApprovesFollowers'] || false
@account.fields = property_values || {}
@account.settings = defer_settings.merge(other_settings, birthday, address)
@account.settings = defer_settings.merge(other_settings, birthday, address, gender)
@account.also_known_as = as_array(@json['alsoKnownAs'] || []).map { |item| value_or_id(item) }
@account.discoverable = @json['discoverable'] || false
end
Expand Down Expand Up @@ -223,9 +223,15 @@ def address
{ 'location' => @json['vcard:Address'] }
end

def gender
return {} if @json['vcard:Gender'].blank?
{ 'gender' => @json['vcard:Gender'] }
end

DEFER_SETTINGS_KEYS = %w(
birthday
location
gender
).freeze

def defer_settings
Expand Down

0 comments on commit acb4a31

Please sign in to comment.