Replies to replies

17 views
Skip to first unread message

Evan Prodromou

unread,
Jun 22, 2012, 4:05:25 PM6/22/12
to activity...@googlegroups.com
I'm wondering about encoding conversations with replies to replies. Does this look right?

{
    "author": {
        "objectType": "person",
        "displayName": "Bob"
    },
    "objectType": "note",
    "content": "Hello, world!",
    "replies": {
        "totalItems": 2,
        "items": [
            {
                "author": {
                    "objectType": "person",
                    "displayName": "Bob"
                },
                "objectType": "comment",
                "content": "Hello, Alice!",
                "replies": {
                    "totalItems": 2,
                    "items": [
                        {
                            "author": {
                                "objectType": "person",
                                "displayName": "Alice"
                            },
                            "objectType": "comment",
                            "content": "Thanks, Bob!"
                        },
                        {
                            "author": {
                                "objectType": "person",
                                "displayName": "Charlie"
                            },
                            "objectType": "comment",
                            "content": "That was nice."
                        }
                    ]
                }
            },
            {
                "author": {
                    "objectType": "person",
                    "displayName": "Denise"
                },
                "objectType": "comment",
                "content": "Good to hear from you again."
            }
        ]
    }
}


Nathan Rixham

unread,
Jun 22, 2012, 4:12:16 PM6/22/12
to activity...@googlegroups.com
Evan Prodromou wrote:
> I'm wondering about encoding conversations with replies to replies. Does
> this look right?

no, that tree could grow infinitely and fork in all kinds of directions
- the { inReplyTo: id } reduces complexity massively.

> {

Evan Prodromou

unread,
Jun 22, 2012, 4:25:52 PM6/22/12
to activity...@googlegroups.com, nri...@gmail.com
Are you thinking something like this, then?

{
    "id": "http://example.com/1",
    "author": {
        "objectType": "person",
        "displayName": "Alice"

    },
    "objectType": "note",
    "content": "Hello, world!",
    "replies": {
        "totalItems": 4,
        "items": [
            {
                "id": "http://example.com/2",
                "author": {
                    "objectType": "person",

                    "displayName": "Bob"
                },
                "objectType": "comment",
                "content": "Hello, Alice!",
                "inReplyTo": "http://example.com/1"
            },
            {
                "id": "http://example.com/3",

                "author": {
                    "objectType": "person",
                    "displayName": "Alice"
                },
                "objectType": "comment",
                "content": "Thanks, Bob!",
                "inReplyTo": "http://example.com/2"
            },
            {
                "id": "http://example.com/4",

                "author": {
                    "objectType": "person",
                    "displayName": "Charlie"
                },
                "objectType": "comment",
                "content": "That was nice.",
                "inReplyTo": "http://example.com/2"
            },
            {
                "id": "http://example.com/5",

                "author": {
                    "objectType": "person",
                    "displayName": "Denise"
                },
                "objectType": "comment",
                "content": "Good to hear from you again.",
                "inReplyTo": "http://example.com/1"
            }
        ]
    }
}

My understanding from the "replies" doc was that all the elements in the "replies" list should have an implicit "inReplyTo" to the enclosing object. This encoding breaks that implied relationship.

Typically on processing this kind of data, I'd probably end up building a tree in memory, anyway.

James M Snell

unread,
Jun 22, 2012, 4:55:49 PM6/22/12
to activity...@googlegroups.com
There are actually several ways to make it happen, depending on
specific needs. Nesting things like in your example is one approach,
but if not managed correctly it can get unwieldy very quickly. Another
approach is to use a flat list that treats replies as activities in
their own right... for instance...

{
"items": [
{
"id": "http://example.org/2",
"actor": {"displayName":"Joe"},
"verb": "post",
"object": [
"objectType": "note",
"content": "this is my reply",
"inReplyTo": [
{"id": "http://example.org/1"}
]
]
},
{
"id": "http://example.org/1",
"actor": {"displayName":"Sally"},
"verb": "post",
"object": [
"objectType": "note",
"content": "this is sally's note"
]
},
}
]
}

This reduces the complexity of the overall structure and allows for a
more efficient streaming model, but puts the burden on the consuming
end to reconstruct the structure of the conversation.

Either approach is valid and has their relative pros and cons. There
are other possible ways of constructing it also.

- James

> --
> You received this message because you are subscribed to the Google Groups
> "Activity Streams" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/activity-streams/-/uThOu3NI0DUJ.
> To post to this group, send email to activity...@googlegroups.com.
> To unsubscribe from this group, send email to
> activity-strea...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/activity-streams?hl=en.

Martin Atkins

unread,
Jun 22, 2012, 5:58:46 PM6/22/12
to activity...@googlegroups.com
It seems like it would be harmless to modify that rule so that the
implied inReplyTo only applies when there's no explicit inReplyTo, thus
allowing the common case of a flat discussion to be simple while still
allowing a hierarchical discussion.

> Typically on processing this kind of data, I'd probably end up building
> a tree in memory, anyway.

Once consideration I'd make here is that different consumers might have
different rendering requirements... not all UIs can accommodate a
threaded discussion, and some impose limits on the level of nesting, so
either:

* Processors that do support threading have to re-constitute the tree
from the inReplyTo relationships, possibly resulting in a tree that has
missing nodes, cycles, or other insanity, or

* Processors that don't support threading have to flatten the tree into
a single list.

It's not clear to me that either one of these is obviously better than
the other, and I believe both serializations are valid per our current
spec...

Reply all
Reply to author
Forward
0 new messages