tent.io/content/docs/example-conversation.md
Jonathan Rudenberg 787fafd49d fix typos
2012-08-22 18:47:52 -04:00

9.3 KiB
Raw Blame History

title
Example Tent Conversation

Example Tent Conversation

Jerrold posts an opinionated status to his 'friends' group of followers:

His client posts to his server:

POST https://tent.jerrold.me/posts
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
{
  "time": 1345317062,
  "recipients": [
    "friends"
  ],
  "licences": [
    {
      "url": "https://tent.io/types/licenses/creative-commons",
      "version": "3.0.0"
    }
  ],
  "content": {
    "type": {
      "url": "https://tent.io/types/posts/status",
      "version": "0.1.0"
    },
    "text": "I love kittens!"
  }
}
201 Created

Jerrold has Kavon and Shirley in his friends group of followers.

His server lets the recipients know about the post:

POST https://tent.kavon.me/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "jA4Mzdh",
    "entity": "jerrold.me",
    "time": 1345317062,
    "licenses": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "scope": "limited",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/status",
        "version": "0.1.0"
      },
      "text": "I love kittens!"
    }
  }
]
200 OK
POST https://shirley.me/tent/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "jA4Mzdh",
    "entity": "jerrold.me",
    "time": 1345317062,
    "licenses": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "scope": "limited",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/status",
        "version": "0.1.0"
      },
      "text": "I love kittens!"
    }
  }
]
200 OK

Their servers instantly propagate the post to designated clients:

POST https://status-updates.kavon.me/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "jA4Mzdh",
    "entity": "jerrold.me",
    "time": 1345317062,
    "licenses": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "scope": "limited",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/status",
        "version": "0.1.0",
        "view": "full"
      },
      "text": "I love kittens!"
    }
  }
]
200 OK ## response can be any 200 series http code

Shirley has her client in maintenance mode; jerrold.me will attempt to deliver the notification later using an exponential backoff algorithm.

POST https://shirley.me/status-updates/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "jA4Mzdh",
    "entity": "jerrold.me",
    "time": 1345317062,
    "licenses": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "scope": "limited",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/status",
        "version": "0.1.0",
        "view": "full"
      },
      "text": "I love kittens!"
    }
  }
]
503 Service Unavailable

Kavon responds to the post:

POST https://tent.kavon.me/posts
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
{
  "time": 1345409893,
  "recipients": [
    "jerrold.me"
  ],
  "licences": [
    {
      "url": "https://tent.io/types/licenses/creative-commons",
      "version": "3.0.0"
    }
  ],
  "mentions": [
    {
      "id": "jA4Mzdh",
      "entity": "jerrold.me"
    }
  ],
  "content": {
    "type": {
      "url": "https://tent.io/types/posts/photo",
      "version": "0.1.0"
    },
    "exif": { ... },
    "binary": "...",
    "filetype": "jpeg",
    "caption": "Cute Kitten"
  }
}
201 Created

His server sends it along to Jerrolds server:

POST https://tent.jerrold.me/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "d8c9d3453e33",
    "time": 1345409893,
    "licences": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "mentions": [
      {
        "id": "jA4Mzdh",
        "entity": "jerrold.me"
      }
    ],
    "scope": "direct",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/photo",
        "version": "0.1.0"
      },
      "exif": { ... },
      "binary": "...",
      "filetype": "jpeg",
      "caption": "Cute Kitten"
    }
  }
]
200 OK

Jerrolds server instantly propagates it to his client:

POST https://status.jerrold.me/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "d8c9d3453e33",
    "time": 1345409893,
    "licences": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "mentions": [
      {
        "id": "jA4Mzdh",
        "entity": "jerrold.me"
      }
    ],
    "scope": "direct",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/photo",
        "version": "0.1.0"
      },
      "exif": { ... },
      "binary": "...",
      "filetype": "jpeg",
      "caption": "Cute Kitten"
    }
  }
]
200 OK

Jerrold sees Kavons reply and reposts it to his friends:

POST https://tent.jerrold.me/posts
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
{
  "time": 1345410615,
  "recipients": [
    "friends"
  ],
  "licences": [
    {
      "url": "https://tent.io/types/licenses/creative-commons",
      "version": "3.0.0"
    }
  ],
  "mentions": [
    {
      "id": "jA4Mzdh",
      "entity": "jerrold.me"
    }
  ],
  "content": {
    "type": {
      "url": "https://tent.io/types/posts/repost",
      "version": "0.1.0"
    },
    "entity": "kavon.me",
    "id": "d8c9d3453e33"
  }
}
201 Created

Shirleys client is back up and receives the two posts:

POST https://shirley.me/status-updates/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
[
  {
    "id": "jA4Mzdh",
    "entity": "jerrold.me",
    "time": 1345317062,
    "licenses": [
      {
        "url": "https://tent.io/types/licenses/creative-commons",
        "version": "3.0.0"
      }
    ],
    "scope": "limited",
    "content": {
      "type": {
        "url": "https://tent.io/types/posts/status",
        "version": "0.1.0",
        "view": "full"
      },
      "text": "I love kittens!"
    }
  }
]
200 OK
POST https://shirley.me/status-updates/notifications
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
{
  "id": "d0f2eeb833e8",
  "time": 1345410615,
  "licences": [
    {
      "url": "https://tent.io/types/licenses/creative-commons",
      "version": "3.0.0"
    }
  ],
  "mentions": [
    {
      "id": "jA4Mzdh",
      "entity": "jerrold.me"
    }
  ],
  "scope": "limited",
  "content": {
    "type": {
      "url": "https://tent.io/types/posts/repost",
      "version": "0.1.0"
    },
    "entity": "kavon.me",
    "id": "d8c9d3453e33"
  }
}
200 OK

Her client requests Kavons post:

GET https://shirley.me/tent/posts/d8c9d3453e33
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="

It is not on her server, so it attempts to fetch it:

GET https://tent.kavon.me/posts/d8c9d3453e33
Content-Type: application/json
Authorization: MAC id="775ecf8",
                   ts="1336363200",
                   nonce="dj83hs9s",
                   mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="

She is not authorized to see it, so Kavons server responds with:

403 Forbidden

Her server responds to her client:

403 Forbidden