Add edited_at property to entities with a text property

This commit is contained in:
Benjamin Neff 2017-09-06 01:13:53 +02:00
parent 0ff382248a
commit 8563855be1
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
13 changed files with 95 additions and 50 deletions

View file

@ -9,20 +9,21 @@ See also: [Relayable][relayable]
## Properties ## Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| ------------------------- | ---------------------------- | ----------------------------------------------- | | ------------------------- | ---------------------------- |:--------:| ----------------------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the comment. | | `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the comment. |
| `guid` | [GUID][guid] | The GUID of the comment. | | `guid` | [GUID][guid] | ✘ | The GUID of the comment. |
| `parent_guid` | [GUID][guid] | The GUID of the parent entity. | | `parent_guid` | [GUID][guid] | ✘ | The GUID of the parent entity. |
| `text` | [Markdown][markdown] (65535) | The comment text. | | `text` | [Markdown][markdown] (65535) | ✔ | The comment text. |
| `created_at` | [Timestamp][timestamp] | The create timestamp of the comment. | | `created_at` | [Timestamp][timestamp] | ✘ | The create timestamp of the comment. |
| `author_signature` | [Signature][signature] | The signature from the author of the comment. | | `author_signature` | [Signature][signature] | ✔ | The signature from the author of the comment. |
## Optional Properties ## Optional Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| -------------------- | ------------- | --------------------------------------------- | | -------------------- | ---------------------- |:--------:| --------------------------------------------- |
| `thread_parent_guid` | [GUID][guid] | The GUID of the parent comment in the thread. | | `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the comment was edited. |
| `thread_parent_guid` | [GUID][guid] | ✘ | The GUID of the parent comment in the thread. |
## Examples ## Examples

View file

@ -7,13 +7,19 @@ This entity represents a private message exchanged in private conversation. It c
## Properties ## Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| ------------------- | ---------------------------- | ----------------------------------------------- | | ------------------- | ---------------------------- |:--------:| ----------------------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the message. | | `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the message. |
| `guid` | [GUID][guid] | The GUID of the message. | | `guid` | [GUID][guid] | ✘ | The GUID of the message. |
| `conversation_guid` | [GUID][guid] | The GUID of the [Conversation][conversation]. | | `conversation_guid` | [GUID][guid] | ✘ | The GUID of the [Conversation][conversation]. |
| `text` | [Markdown][markdown] (65535) | The message text. | | `text` | [Markdown][markdown] (65535) | ✔ | The message text. |
| `created_at` | [Timestamp][timestamp] | The create timestamp of the message. | | `created_at` | [Timestamp][timestamp] | ✘ | The create timestamp of the message. |
## Optional Properties
| Property | Type (Length) | Editable | Description |
| -------------------- | ---------------------- |:--------:| ------------------------------------------ |
| `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the message was edited. |
## Example ## Example

View file

@ -6,23 +6,24 @@ This entity represents a photo. It can be standalone or nested in a [StatusMessa
## Properties ## Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| ------------------- | ---------------------------- | ---------------------------------------------------------------- | | ------------------- | ---------------------------- |:--------:| ---------------------------------------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the photo. | | `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the photo. |
| `guid` | [GUID][guid] | The GUID of the photo. | | `guid` | [GUID][guid] | ✘ | The GUID of the photo. |
| `public` | [Boolean][boolean] | `true` if the photo is public. | | `public` | [Boolean][boolean] | ✘ | `true` if the photo is public. |
| `created_at` | [Timestamp][timestamp] | The create timestamp of the photo. | | `created_at` | [Timestamp][timestamp] | ✘ | The create timestamp of the photo. |
| `remote_photo_path` | [URL][url] | The URL to the photo, without filename (see `remote_photo_name`) | | `remote_photo_path` | [URL][url] | ✔ | The URL to the photo, without filename (see `remote_photo_name`) |
| `remote_photo_name` | [String][string] (255) | The filename of the photo. | | `remote_photo_name` | [String][string] (255) | ✔ | The filename of the photo. |
## Optional Properties ## Optional Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| --------------------- | ------------------------ | ------------------------------------------------------------------------------- | | --------------------- | ------------------------ |:--------:| ------------------------------------------------------------------------------- |
| `text` | [String][string] (65535) | Description text for the photo. | | `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the photo was edited. |
| `status_message_guid` | [GUID][guid] | The GUID of the [StatusMessage][status_message] to which the photo is attached. | | `text` | [String][string] (65535) | ✔ | Description text for the photo. |
| `height` | [Integer][integer] | The height of the photo in pixels. | | `status_message_guid` | [GUID][guid] | ✘ | The GUID of the [StatusMessage][status_message] to which the photo is attached. |
| `width` | [Integer][integer] | The width of the photo in pixels. | | `height` | [Integer][integer] | ✔ | The height of the photo in pixels. |
| `width` | [Integer][integer] | ✔ | The width of the photo in pixels. |
## Example ## Example

View file

@ -6,23 +6,24 @@ This entity represents a reshare of a status message. It inherits from [Post][po
## Properties ## Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| ------------ | ---------------------------- | ------------------------------------------------------ | | ------------ | ---------------------------- |:--------:| ------------------------------------------------------ |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the status message. | | `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the status message. |
| `guid` | [GUID][guid] | The GUID of the status message. | | `guid` | [GUID][guid] | ✘ | The GUID of the status message. |
| `created_at` | [Timestamp][timestamp] | The create timestamp of the status message. | | `created_at` | [Timestamp][timestamp] | ✘ | The create timestamp of the status message. |
| `public` | [Boolean][boolean] | `true` if the status message is public. | | `public` | [Boolean][boolean] | ✘ | `true` if the status message is public. |
| `text` | [Markdown][markdown] (65535) | The status message text. | | `text` | [Markdown][markdown] (65535) | ✔ | The status message text. |
## Optional Properties ## Optional Properties
| Property | Type (Length) | Description | | Property | Type (Length) | Editable | Description |
| ----------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------- | | ----------------------- | ---------------------- |:--------:| ----------------------------------------------------------------------------------------------------------------------- |
| `provider_display_name` | [String][string] (255) | The means by which the author has posted the status message. | | `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the status message was edited. |
| `location` | [Location][location] | The Location information of the status message. | | `provider_display_name` | [String][string] (255) | ✘ | The means by which the author has posted the status message. |
| `photo` | [Photo][photo]s | The attached Photos of the status message, the `status_message_guid` and the `author` need to match the status message. | | `location` | [Location][location] | ✔ | The Location information of the status message. |
| `poll` | [Poll][poll] | The attached Poll of the status message. | | `photo` | [Photo][photo]s | ✔ | The attached Photos of the status message, the `status_message_guid` and the `author` need to match the status message. |
| `event` | [Event][event] | The attached Event of the status message. | | `poll` | [Poll][poll] | ✘ | The attached Poll of the status message. |
| `event` | [Event][event] | ✘ | The attached Event of the status message. |
## Examples ## Examples

View file

@ -17,6 +17,11 @@ module DiasporaFederation
# Comment entity creation time # Comment entity creation time
# @return [Time] creation time # @return [Time] creation time
property :created_at, :timestamp, default: -> { Time.now.utc } property :created_at, :timestamp, default: -> { Time.now.utc }
# @!attribute [r] edited_at
# The timestamp when the comment was edited
# @return [Time] edited time
property :edited_at, :timestamp, optional: true
end end
end end
end end

View file

@ -26,6 +26,11 @@ module DiasporaFederation
# @return [Time] creation time # @return [Time] creation time
property :created_at, :timestamp, default: -> { Time.now.utc } property :created_at, :timestamp, default: -> { Time.now.utc }
# @!attribute [r] edited_at
# The timestamp when the message was edited
# @return [Time] edited time
property :edited_at, :timestamp, optional: true
# @!attribute [r] conversation_guid # @!attribute [r] conversation_guid
# Guid of a conversation this message belongs to # Guid of a conversation this message belongs to
# @see Conversation#guid # @see Conversation#guid

View file

@ -26,6 +26,11 @@ module DiasporaFederation
# @return [Time] creation time # @return [Time] creation time
property :created_at, :timestamp, default: -> { Time.now.utc } property :created_at, :timestamp, default: -> { Time.now.utc }
# @!attribute [r] edited_at
# The timestamp when the photo was edited
# @return [Time] edited time
property :edited_at, :timestamp, optional: true
# @!attribute [r] remote_photo_path # @!attribute [r] remote_photo_path
# An url of the photo on a remote server # An url of the photo on a remote server
# @return [String] remote photo url # @return [String] remote photo url

View file

@ -11,6 +11,11 @@ module DiasporaFederation
# @return [String] text of the status message # @return [String] text of the status message
property :text, :string, xml_name: :raw_message property :text, :string, xml_name: :raw_message
# @!attribute [r] edited_at
# The timestamp when the status message was edited
# @return [Time] edited time
property :edited_at, :timestamp, optional: true
# @!attribute [r] photos # @!attribute [r] photos
# Optional photos attached to the status message # Optional photos attached to the status message
# @return [[Entities::Photo]] photos # @return [[Entities::Photo]] photos

View file

@ -81,6 +81,7 @@ module DiasporaFederation
author { Fabricate.sequence(:diaspora_id) } author { Fabricate.sequence(:diaspora_id) }
public true public true
created_at { Time.now.utc } created_at { Time.now.utc }
edited_at { Time.now.utc + 3600 }
remote_photo_path "https://diaspora.example.tld/uploads/images/" remote_photo_path "https://diaspora.example.tld/uploads/images/"
remote_photo_name "f2a41e9d2db4d9a199c8.jpg" remote_photo_name "f2a41e9d2db4d9a199c8.jpg"
text "what you see here..." text "what you see here..."
@ -107,6 +108,7 @@ module DiasporaFederation
guid { Fabricate.sequence(:guid) } guid { Fabricate.sequence(:guid) }
public true public true
created_at { Time.now.utc } created_at { Time.now.utc }
edited_at { Time.now.utc + 3600 }
end end
Fabricator(:contact_entity, class_name: DiasporaFederation::Entities::Contact) do Fabricator(:contact_entity, class_name: DiasporaFederation::Entities::Contact) do
@ -121,6 +123,8 @@ module DiasporaFederation
author { Fabricate.sequence(:diaspora_id) } author { Fabricate.sequence(:diaspora_id) }
guid { Fabricate.sequence(:guid) } guid { Fabricate.sequence(:guid) }
text "this is a very informative comment" text "this is a very informative comment"
created_at { Time.now.utc }
edited_at { Time.now.utc + 3600 }
end end
Fabricator(:like_entity, class_name: DiasporaFederation::Entities::Like, from: :relayable_entity) do Fabricator(:like_entity, class_name: DiasporaFederation::Entities::Like, from: :relayable_entity) do
@ -144,6 +148,7 @@ module DiasporaFederation
author { Fabricate.sequence(:diaspora_id) } author { Fabricate.sequence(:diaspora_id) }
text "this is a very informative text" text "this is a very informative text"
created_at { Time.now.utc } created_at { Time.now.utc }
edited_at { Time.now.utc + 3600 }
conversation_guid { Fabricate.sequence(:guid) } conversation_guid { Fabricate.sequence(:guid) }
end end

View file

@ -8,8 +8,7 @@ module DiasporaFederation
:comment_entity, :comment_entity,
author: alice.diaspora_id, author: alice.diaspora_id,
parent_guid: parent.guid, parent_guid: parent.guid,
parent: parent_entity, parent: parent_entity
created_at: Time.now.utc
).tap {|hash| add_signatures(hash) } ).tap {|hash| add_signatures(hash) }
} }
@ -20,6 +19,7 @@ module DiasporaFederation
<parent_guid>#{parent.guid}</parent_guid> <parent_guid>#{parent.guid}</parent_guid>
<text>#{data[:text]}</text> <text>#{data[:text]}</text>
<created_at>#{data[:created_at].utc.iso8601}</created_at> <created_at>#{data[:created_at].utc.iso8601}</created_at>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<author_signature>#{data[:author_signature]}</author_signature> <author_signature>#{data[:author_signature]}</author_signature>
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</comment> </comment>
@ -34,14 +34,16 @@ XML
"parent_guid": "#{parent.guid}", "parent_guid": "#{parent.guid}",
"author_signature": "#{data[:author_signature]}", "author_signature": "#{data[:author_signature]}",
"text": "#{data[:text]}", "text": "#{data[:text]}",
"created_at": "#{data[:created_at].iso8601}" "created_at": "#{data[:created_at].iso8601}",
"edited_at": "#{data[:edited_at].iso8601}"
}, },
"property_order": [ "property_order": [
"author", "author",
"guid", "guid",
"parent_guid", "parent_guid",
"text", "text",
"created_at" "created_at",
"edited_at"
] ]
} }
JSON JSON

View file

@ -8,6 +8,7 @@ module DiasporaFederation
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<text>#{data[:text]}</text> <text>#{data[:text]}</text>
<created_at>#{data[:created_at].utc.iso8601}</created_at> <created_at>#{data[:created_at].utc.iso8601}</created_at>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<conversation_guid>#{data[:conversation_guid]}</conversation_guid> <conversation_guid>#{data[:conversation_guid]}</conversation_guid>
</message> </message>
XML XML

View file

@ -8,6 +8,7 @@ module DiasporaFederation
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<public>#{data[:public]}</public> <public>#{data[:public]}</public>
<created_at>#{data[:created_at].utc.iso8601}</created_at> <created_at>#{data[:created_at].utc.iso8601}</created_at>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path> <remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
<remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name> <remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name>
<text>#{data[:text]}</text> <text>#{data[:text]}</text>
@ -25,6 +26,7 @@ XML
"author": "#{data[:author]}", "author": "#{data[:author]}",
"public": #{data[:public]}, "public": #{data[:public]},
"created_at": "#{data[:created_at].utc.iso8601}", "created_at": "#{data[:created_at].utc.iso8601}",
"edited_at": "#{data[:edited_at].iso8601}",
"remote_photo_path": "#{data[:remote_photo_path]}", "remote_photo_path": "#{data[:remote_photo_path]}",
"remote_photo_name": "#{data[:remote_photo_name]}", "remote_photo_name": "#{data[:remote_photo_name]}",
"text": "#{data[:text]}", "text": "#{data[:text]}",

View file

@ -22,11 +22,13 @@ module DiasporaFederation
<public>#{data[:public]}</public> <public>#{data[:public]}</public>
<provider_display_name>#{data[:provider_display_name]}</provider_display_name> <provider_display_name>#{data[:provider_display_name]}</provider_display_name>
<text>#{data[:text]}</text> <text>#{data[:text]}</text>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<photo> <photo>
<guid>#{photo1.guid}</guid> <guid>#{photo1.guid}</guid>
<author>#{photo1.author}</author> <author>#{photo1.author}</author>
<public>#{photo1.public}</public> <public>#{photo1.public}</public>
<created_at>#{photo1.created_at.utc.iso8601}</created_at> <created_at>#{photo1.created_at.utc.iso8601}</created_at>
<edited_at>#{photo1.edited_at.utc.iso8601}</edited_at>
<remote_photo_path>#{photo1.remote_photo_path}</remote_photo_path> <remote_photo_path>#{photo1.remote_photo_path}</remote_photo_path>
<remote_photo_name>#{photo1.remote_photo_name}</remote_photo_name> <remote_photo_name>#{photo1.remote_photo_name}</remote_photo_name>
<text>#{photo1.text}</text> <text>#{photo1.text}</text>
@ -39,6 +41,7 @@ module DiasporaFederation
<author>#{photo2.author}</author> <author>#{photo2.author}</author>
<public>#{photo2.public}</public> <public>#{photo2.public}</public>
<created_at>#{photo2.created_at.utc.iso8601}</created_at> <created_at>#{photo2.created_at.utc.iso8601}</created_at>
<edited_at>#{photo2.edited_at.utc.iso8601}</edited_at>
<remote_photo_path>#{photo2.remote_photo_path}</remote_photo_path> <remote_photo_path>#{photo2.remote_photo_path}</remote_photo_path>
<remote_photo_name>#{photo2.remote_photo_name}</remote_photo_name> <remote_photo_name>#{photo2.remote_photo_name}</remote_photo_name>
<text>#{photo2.text}</text> <text>#{photo2.text}</text>
@ -64,6 +67,7 @@ XML
"public": #{data[:public]}, "public": #{data[:public]},
"provider_display_name": "#{data[:provider_display_name]}", "provider_display_name": "#{data[:provider_display_name]}",
"text": "#{data[:text]}", "text": "#{data[:text]}",
"edited_at": "#{data[:edited_at].iso8601}",
"photos": [ "photos": [
{ {
"entity_type": "photo", "entity_type": "photo",
@ -72,6 +76,7 @@ XML
"author": "#{photo1.author}", "author": "#{photo1.author}",
"public": #{photo1.public}, "public": #{photo1.public},
"created_at": "#{photo1.created_at.utc.iso8601}", "created_at": "#{photo1.created_at.utc.iso8601}",
"edited_at": "#{photo1.edited_at.utc.iso8601}",
"remote_photo_path": "#{photo1.remote_photo_path}", "remote_photo_path": "#{photo1.remote_photo_path}",
"remote_photo_name": "#{photo1.remote_photo_name}", "remote_photo_name": "#{photo1.remote_photo_name}",
"text": "#{photo1.text}", "text": "#{photo1.text}",
@ -87,6 +92,7 @@ XML
"author": "#{photo2.author}", "author": "#{photo2.author}",
"public": #{photo2.public}, "public": #{photo2.public},
"created_at": "#{photo2.created_at.utc.iso8601}", "created_at": "#{photo2.created_at.utc.iso8601}",
"edited_at": "#{photo2.edited_at.utc.iso8601}",
"remote_photo_path": "#{photo2.remote_photo_path}", "remote_photo_path": "#{photo2.remote_photo_path}",
"remote_photo_name": "#{photo2.remote_photo_name}", "remote_photo_name": "#{photo2.remote_photo_name}",
"text": "#{photo2.text}", "text": "#{photo2.text}",