Add edited_at property to the profile message
This is needed so we can make sure to not overwrite newer data by older one, for example when there are two edits close together and the newer arrives faster.
This commit is contained in:
parent
8563855be1
commit
057ebd69f0
6 changed files with 31 additions and 18 deletions
|
|
@ -21,33 +21,35 @@ only contain the base profile.
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
| Property | Type | Description |
|
| Property | Type | Editable | Description |
|
||||||
| -------- | ---------------------------- | -------------------------------- |
|
| -------- | ---------------------------- |:--------:| -------------------------------- |
|
||||||
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the person. |
|
| `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the person. |
|
||||||
|
|
||||||
## Optional Properties
|
## Optional Properties
|
||||||
|
|
||||||
| Property | Type (Length) | Description |
|
| Property | Type (Length) | Editable | Description |
|
||||||
| ------------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------- |
|
| ------------------ | ---------------------------- |:--------:| -------------------------------------------------------------------------------------------------------- |
|
||||||
| `first_name` | [Name][name] (32) | The first name of the person. |
|
| `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the profile was edited. |
|
||||||
| `last_name` | [Name][name] (32) | The last name of the person. |
|
| `first_name` | [Name][name] (32) | ✔ | The first name of the person. |
|
||||||
| `image_url` | [URL][url] (255) | The URL to the big avatar (300x300) of the person. |
|
| `last_name` | [Name][name] (32) | ✔ | The last name of the person. |
|
||||||
| `image_url_medium` | [URL][url] (255) | The URL to the medium avatar (100x100) of the person. |
|
| `image_url` | [URL][url] (255) | ✔ | The URL to the big avatar (300x300) of the person. |
|
||||||
| `image_url_small` | [URL][url] (255) | The URL to the small avatar (50x50) of the person. |
|
| `image_url_medium` | [URL][url] (255) | ✔ | The URL to the medium avatar (100x100) of the person. |
|
||||||
| `bio` | [Markdown][markdown] (65535) | The description of the person. This field can contain markdown. |
|
| `image_url_small` | [URL][url] (255) | ✔ | The URL to the small avatar (50x50) of the person. |
|
||||||
| `birthday` | [Date][date] | The birthday of the person. The year may be `1004` or less, if the person specifies only day and month. |
|
| `bio` | [Markdown][markdown] (65535) | ✔ | The description of the person. This field can contain markdown. |
|
||||||
| `gender` | [String][string] (255) | The gender of the person. |
|
| `birthday` | [Date][date] | ✔ | The birthday of the person. The year may be `1004` or less, if the person specifies only day and month. |
|
||||||
| `location` | [String][string] (255) | The location of the person. |
|
| `gender` | [String][string] (255) | ✔ | The gender of the person. |
|
||||||
| `searchable` | [Boolean][boolean] | `false` if the person doesn't want to be searchable by name. |
|
| `location` | [String][string] (255) | ✔ | The location of the person. |
|
||||||
| `public` | [Boolean][boolean] | `true` if the profile is visible to everyone. |
|
| `searchable` | [Boolean][boolean] | ✔ | `false` if the person doesn't want to be searchable by name. |
|
||||||
| `nsfw` | [Boolean][boolean] | `true` if all posts of this person should be marked as NSFW. |
|
| `public` | [Boolean][boolean] | ✔ | `true` if the profile is visible to everyone. |
|
||||||
| `tag_string` | [String][string] | A list of hashtags for this person, each tag beginning with `#` and seperated by spaces, at most 5 tags. |
|
| `nsfw` | [Boolean][boolean] | ✔ | `true` if all posts of this person should be marked as NSFW. |
|
||||||
|
| `tag_string` | [String][string] | ✔ | A list of hashtags for this person, each tag beginning with `#` and seperated by spaces, at most 5 tags. |
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
~~~xml
|
~~~xml
|
||||||
<profile>
|
<profile>
|
||||||
<author>alice@example.org</author>
|
<author>alice@example.org</author>
|
||||||
|
<edited_at>2018-01-23T01:19:56Z</edited_at>
|
||||||
<first_name>Alice</first_name>
|
<first_name>Alice</first_name>
|
||||||
<last_name>Smith</last_name>
|
<last_name>Smith</last_name>
|
||||||
<image_url>https://example.org/images/thumb_large_a795f872c93309597345.jpg</image_url>
|
<image_url>https://example.org/images/thumb_large_a795f872c93309597345.jpg</image_url>
|
||||||
|
|
@ -65,6 +67,7 @@ only contain the base profile.
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
[diaspora-id]: {{ site.baseurl }}/federation/types.html#diaspora-id
|
[diaspora-id]: {{ site.baseurl }}/federation/types.html#diaspora-id
|
||||||
|
[timestamp]: {{ site.baseurl }}/federation/types.html#timestamp
|
||||||
[name]: {{ site.baseurl }}/federation/types.html#name
|
[name]: {{ site.baseurl }}/federation/types.html#name
|
||||||
[url]: {{ site.baseurl }}/federation/types.html#url
|
[url]: {{ site.baseurl }}/federation/types.html#url
|
||||||
[date]: {{ site.baseurl }}/federation/types.html#date
|
[date]: {{ site.baseurl }}/federation/types.html#date
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ module DiasporaFederation
|
||||||
# @return [String] diaspora* ID
|
# @return [String] diaspora* ID
|
||||||
property :author, :string, alias: :diaspora_id, xml_name: :diaspora_handle
|
property :author, :string, alias: :diaspora_id, xml_name: :diaspora_handle
|
||||||
|
|
||||||
|
# @!attribute [r] edited_at
|
||||||
|
# The timestamp when the profile was edited
|
||||||
|
# @return [Time] edited time
|
||||||
|
property :edited_at, :timestamp, optional: true
|
||||||
|
|
||||||
# @!attribute [r] first_name
|
# @!attribute [r] first_name
|
||||||
# @deprecated We decided to only use one name field, these should be removed
|
# @deprecated We decided to only use one name field, these should be removed
|
||||||
# in later iterations (will affect older diaspora* installations).
|
# in later iterations (will affect older diaspora* installations).
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
Fabricator(:profile_entity, class_name: DiasporaFederation::Entities::Profile) do
|
Fabricator(:profile_entity, class_name: DiasporaFederation::Entities::Profile) do
|
||||||
author { Fabricate.sequence(:diaspora_id) }
|
author { Fabricate.sequence(:diaspora_id) }
|
||||||
|
edited_at { Time.now.utc }
|
||||||
first_name "my name"
|
first_name "my name"
|
||||||
last_name nil
|
last_name nil
|
||||||
image_url "/assets/user/default.png"
|
image_url "/assets/user/default.png"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ module DiasporaFederation
|
||||||
hash.tap {|hash|
|
hash.tap {|hash|
|
||||||
properties = described_class.new(hash).send(:enriched_properties)
|
properties = described_class.new(hash).send(:enriched_properties)
|
||||||
hash[:signature] = properties[:signature]
|
hash[:signature] = properties[:signature]
|
||||||
|
hash[:profile] = Entities::Profile.new(hash[:profile].to_h.tap {|profile| profile[:edited_at] = nil })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let(:signature_data) { "AccountMigration:#{old_diaspora_id}:#{new_diaspora_id}" }
|
let(:signature_data) { "AccountMigration:#{old_diaspora_id}:#{new_diaspora_id}" }
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ module DiasporaFederation
|
||||||
<url>#{data[:url]}</url>
|
<url>#{data[:url]}</url>
|
||||||
<profile>
|
<profile>
|
||||||
<author>#{data[:profile].author}</author>
|
<author>#{data[:profile].author}</author>
|
||||||
|
<edited_at>#{data[:profile].edited_at.utc.iso8601}</edited_at>
|
||||||
<first_name>#{data[:profile].first_name}</first_name>
|
<first_name>#{data[:profile].first_name}</first_name>
|
||||||
<image_url>#{data[:profile].image_url}</image_url>
|
<image_url>#{data[:profile].image_url}</image_url>
|
||||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ module DiasporaFederation
|
||||||
let(:xml) { <<-XML }
|
let(:xml) { <<-XML }
|
||||||
<profile>
|
<profile>
|
||||||
<author>#{data[:author]}</author>
|
<author>#{data[:author]}</author>
|
||||||
|
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||||
<first_name>#{data[:first_name]}</first_name>
|
<first_name>#{data[:first_name]}</first_name>
|
||||||
<image_url>#{data[:image_url]}</image_url>
|
<image_url>#{data[:image_url]}</image_url>
|
||||||
<image_url_medium>#{data[:image_url]}</image_url_medium>
|
<image_url_medium>#{data[:image_url]}</image_url_medium>
|
||||||
|
|
@ -25,6 +26,7 @@ XML
|
||||||
"entity_type": "profile",
|
"entity_type": "profile",
|
||||||
"entity_data": {
|
"entity_data": {
|
||||||
"author": "#{data[:author]}",
|
"author": "#{data[:author]}",
|
||||||
|
"edited_at": "#{data[:edited_at].iso8601}",
|
||||||
"first_name": "#{data[:first_name]}",
|
"first_name": "#{data[:first_name]}",
|
||||||
"image_url": "#{data[:image_url]}",
|
"image_url": "#{data[:image_url]}",
|
||||||
"image_url_medium": "#{data[:image_url]}",
|
"image_url_medium": "#{data[:image_url]}",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue