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:
Benjamin Neff 2018-01-23 02:05:36 +01:00
parent 8563855be1
commit 057ebd69f0
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
6 changed files with 31 additions and 18 deletions

View file

@ -21,33 +21,35 @@ only contain the base profile.
## Properties
| Property | Type | Description |
| -------- | ---------------------------- | -------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the person. |
| Property | Type | Editable | Description |
| -------- | ---------------------------- |:--------:| -------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the person. |
## Optional Properties
| Property | Type (Length) | Description |
| ------------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------- |
| `first_name` | [Name][name] (32) | The first name of the person. |
| `last_name` | [Name][name] (32) | The last name of the person. |
| `image_url` | [URL][url] (255) | The URL to the big avatar (300x300) of the person. |
| `image_url_medium` | [URL][url] (255) | The URL to the medium avatar (100x100) of the person. |
| `image_url_small` | [URL][url] (255) | The URL to the small avatar (50x50) of the person. |
| `bio` | [Markdown][markdown] (65535) | The description of the person. This field can contain markdown. |
| `birthday` | [Date][date] | The birthday of the person. The year may be `1004` or less, if the person specifies only day and month. |
| `gender` | [String][string] (255) | The gender of the person. |
| `location` | [String][string] (255) | The location of the person. |
| `searchable` | [Boolean][boolean] | `false` if the person doesn't want to be searchable by name. |
| `public` | [Boolean][boolean] | `true` if the profile is visible to everyone. |
| `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. |
| Property | Type (Length) | Editable | Description |
| ------------------ | ---------------------------- |:--------:| -------------------------------------------------------------------------------------------------------- |
| `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the profile was edited. |
| `first_name` | [Name][name] (32) | ✔ | The first name of the person. |
| `last_name` | [Name][name] (32) | ✔ | The last name of the person. |
| `image_url` | [URL][url] (255) | ✔ | The URL to the big avatar (300x300) of the person. |
| `image_url_medium` | [URL][url] (255) | ✔ | The URL to the medium avatar (100x100) of the person. |
| `image_url_small` | [URL][url] (255) | ✔ | The URL to the small avatar (50x50) of the person. |
| `bio` | [Markdown][markdown] (65535) | ✔ | The description of the person. This field can contain markdown. |
| `birthday` | [Date][date] | ✔ | The birthday of the person. The year may be `1004` or less, if the person specifies only day and month. |
| `gender` | [String][string] (255) | ✔ | The gender of the person. |
| `location` | [String][string] (255) | ✔ | The location of the person. |
| `searchable` | [Boolean][boolean] | ✔ | `false` if the person doesn't want to be searchable by name. |
| `public` | [Boolean][boolean] | ✔ | `true` if the profile is visible to everyone. |
| `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
~~~xml
<profile>
<author>alice@example.org</author>
<edited_at>2018-01-23T01:19:56Z</edited_at>
<first_name>Alice</first_name>
<last_name>Smith</last_name>
<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
[timestamp]: {{ site.baseurl }}/federation/types.html#timestamp
[name]: {{ site.baseurl }}/federation/types.html#name
[url]: {{ site.baseurl }}/federation/types.html#url
[date]: {{ site.baseurl }}/federation/types.html#date

View file

@ -14,6 +14,11 @@ module DiasporaFederation
# @return [String] diaspora* ID
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
# @deprecated We decided to only use one name field, these should be removed
# in later iterations (will affect older diaspora* installations).

View file

@ -55,6 +55,7 @@ module DiasporaFederation
Fabricator(:profile_entity, class_name: DiasporaFederation::Entities::Profile) do
author { Fabricate.sequence(:diaspora_id) }
edited_at { Time.now.utc }
first_name "my name"
last_name nil
image_url "/assets/user/default.png"

View file

@ -9,6 +9,7 @@ module DiasporaFederation
hash.tap {|hash|
properties = described_class.new(hash).send(:enriched_properties)
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}" }

View file

@ -9,6 +9,7 @@ module DiasporaFederation
<url>#{data[:url]}</url>
<profile>
<author>#{data[:profile].author}</author>
<edited_at>#{data[:profile].edited_at.utc.iso8601}</edited_at>
<first_name>#{data[:profile].first_name}</first_name>
<image_url>#{data[:profile].image_url}</image_url>
<image_url_medium>#{data[:profile].image_url}</image_url_medium>

View file

@ -5,6 +5,7 @@ module DiasporaFederation
let(:xml) { <<-XML }
<profile>
<author>#{data[:author]}</author>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<first_name>#{data[:first_name]}</first_name>
<image_url>#{data[:image_url]}</image_url>
<image_url_medium>#{data[:image_url]}</image_url_medium>
@ -25,6 +26,7 @@ XML
"entity_type": "profile",
"entity_data": {
"author": "#{data[:author]}",
"edited_at": "#{data[:edited_at].iso8601}",
"first_name": "#{data[:first_name]}",
"image_url": "#{data[:image_url]}",
"image_url_medium": "#{data[:image_url]}",