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
| Property | Type (Length) | Description |
| ------------------------- | ---------------------------- | ----------------------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the comment. |
| `guid` | [GUID][guid] | The GUID of the comment. |
| `parent_guid` | [GUID][guid] | The GUID of the parent entity. |
| `text` | [Markdown][markdown] (65535) | The comment text. |
| `created_at` | [Timestamp][timestamp] | The create timestamp of the comment. |
| `author_signature` | [Signature][signature] | The signature from the author of the comment. |
| Property | Type (Length) | Editable | Description |
| ------------------------- | ---------------------------- |:--------:| ----------------------------------------------- |
| `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the comment. |
| `guid` | [GUID][guid] | ✘ | The GUID of the comment. |
| `parent_guid` | [GUID][guid] | ✘ | The GUID of the parent entity. |
| `text` | [Markdown][markdown] (65535) | ✔ | The comment text. |
| `created_at` | [Timestamp][timestamp] | ✘ | The create timestamp of the comment. |
| `author_signature` | [Signature][signature] | ✔ | The signature from the author of the comment. |
## Optional Properties
| Property | Type (Length) | Description |
| -------------------- | ------------- | --------------------------------------------- |
| `thread_parent_guid` | [GUID][guid] | The GUID of the parent comment in the thread. |
| Property | Type (Length) | Editable | Description |
| -------------------- | ---------------------- |:--------:| --------------------------------------------- |
| `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

View file

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

View file

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

View file

@ -6,23 +6,24 @@ This entity represents a reshare of a status message. It inherits from [Post][po
## Properties
| Property | Type (Length) | Description |
| ------------ | ---------------------------- | ------------------------------------------------------ |
| `author` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the author of the status message. |
| `guid` | [GUID][guid] | The GUID 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. |
| `text` | [Markdown][markdown] (65535) | The status message text. |
| Property | Type (Length) | Editable | Description |
| ------------ | ---------------------------- |:--------:| ------------------------------------------------------ |
| `author` | [diaspora\* ID][diaspora-id] | ✘ | The diaspora\* ID of the author of the status message. |
| `guid` | [GUID][guid] | ✘ | The GUID 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. |
| `text` | [Markdown][markdown] (65535) | ✔ | The status message text. |
## Optional Properties
| Property | Type (Length) | Description |
| ----------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `provider_display_name` | [String][string] (255) | The means by which the author has posted the status message. |
| `location` | [Location][location] | The Location information 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. |
| `poll` | [Poll][poll] | The attached Poll of the status message. |
| `event` | [Event][event] | The attached Event of the status message. |
| Property | Type (Length) | Editable | Description |
| ----------------------- | ---------------------- |:--------:| ----------------------------------------------------------------------------------------------------------------------- |
| `edited_at` | [Timestamp][timestamp] | ✔ | The timestamp when the status message was edited. |
| `provider_display_name` | [String][string] (255) | ✘ | The means by which the author has posted the status message. |
| `location` | [Location][location] | ✔ | The Location information 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. |
| `poll` | [Poll][poll] | ✘ | The attached Poll of the status message. |
| `event` | [Event][event] | ✘ | The attached Event of the status message. |
## Examples

View file

@ -17,6 +17,11 @@ module DiasporaFederation
# Comment entity creation time
# @return [Time] creation time
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

View file

@ -26,6 +26,11 @@ module DiasporaFederation
# @return [Time] creation time
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
# Guid of a conversation this message belongs to
# @see Conversation#guid

View file

@ -26,6 +26,11 @@ module DiasporaFederation
# @return [Time] creation time
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
# An url of the photo on a remote server
# @return [String] remote photo url

View file

@ -11,6 +11,11 @@ module DiasporaFederation
# @return [String] text of the status 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
# Optional photos attached to the status message
# @return [[Entities::Photo]] photos

View file

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

View file

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

View file

@ -8,6 +8,7 @@ module DiasporaFederation
<guid>#{data[:guid]}</guid>
<text>#{data[:text]}</text>
<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>
</message>
XML

View file

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

View file

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