forked from w3c/activitystreams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activitystreams2.html
1449 lines (1284 loc) · 57.5 KB
/
activitystreams2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Activity Streams 2.0</title>
<meta charset="UTF-8" />
<script src="http://www.w3.org/Tools/respec/respec-w3c-common" async class="remove"></script>
<script class="remove">
var respecConfig = {
specStatus: "ED",
edDraftURI: "http://jasnell.github.io/w3c-socialwg-activitystreams/activitystreams2.html",
shortName: "activitystreams-core",
editors: [
{
name: "James M Snell",
url: "http://chmod777self.com",
company: "IBM",
companyUrl: "http://ibm.com"
}
],
additionalCopyrightHolders: ["Activity Streams Working Group", "IBM"],
maxTocLevel: 2,
previousMaturity: "FPWD",
previousPublishDate: "2014-10-23",
wg: "Social Web Working Group",
wgURI: "http://www.w3.org/Social/WG",
wgPublicList: "public-socialweb",
wgPatentURI: "http://www.w3.org/2004/01/pp-impl/72531/status",
localBiblio: {
"AS1": {
title: "JSON Activity Streams 1.0",
href: "http://activitystrea.ms/specs/json/1.0/",
authors: [
"J. Snell",
"M. Atkins",
"W. Norris",
"C. Messina",
"M. Wilkinson",
"R. Dolin"
],
status: "unofficial",
publisher: "http://activitystrea.ms"
}
},
otherLinks: [{
key: 'Repository',
data: [
{
value: 'Github',
href: 'https://github.com/jasnell/w3c-socialwg-activitystreams'
},
{
value: 'Issues',
href: 'https://github.com/jasnell/w3c-socialwg-activitystreams/issues'
},
{
value: 'Commits',
href: 'https://github.com/jasnell/w3c-socialwg-activitystreams/commits/master'
}
]
}]
};
</script>
<style>
thead {
background: #005A9C;
color: white;
}
thead th {
font-weight: normal;
}
table, td, th { border: 1px solid gray }
table { width: 100% ;}
td {
vertical-align: top;
padding: 5px;
}
</style>
</head>
<body>
<section id="abstract">
<p>
This specification details a model for representing potential and
completed activities using the JSON format.
</p>
<section id="authorsnote" class="informative">
<h2>Author's Note</h2>
<p>
This draft is heavily influenced by the JSON Activity
Streams 1.0 specification originally co-authored by Martin
Atkins, Will Norris, Chris Messina, Monica Wilkinson, Rob Dolin and
James Snell. The author is very thankful for their significant
contributions and gladly stands on their shoulders. Some portions of
the original text of Activity Streams 1.0 are used in this document.
</p>
</section>
</section>
<section id="sotd">
</section>
<section id="introduction">
<h2>Introduction</h2>
<p>
In the most basic sense, an "activity" is a semantic description of
a potential or completed action. In the former case, the activity
expresses what can or might be done with a particular object, while
in the latter case, it expresses what has already been done.
</p>
<p>
It is the goal of this specification to provide a JSON-based syntax
that is sufficient to express metadata about activities in a rich,
human-friendly, machine-processable and extensible manner. This may
include constructing natural-language descriptions or visual
representations about the activity, associating actionable
information with various types of objects, communicating or recording
activity logs, or delegation of potential actions to other
applications.
</p>
<p>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [[!RFC2119]].
</p>
<section id="activitystreams-1.0" class="informative">
<h2>Relationship to JSON Activity Streams 1.0</h2>
<p>
The JSON Activity Streams 1.0 [[!AS1]] specification was
published in May of 2011 and provided a baseline extensible syntax
for the expression of completed activities. This specification
builds upon that initial foundation by incorporating lessons learned
through extensive implementation, community feedback and related
ongoing work from a variety of other communities.
</p>
<p>
While the syntax defined by this specification diverges somewhat from
that defined by JSON Activity Streams 1.0, the verbs, objectTypes,
extensions and fundamental model defined by that original
specification remain intact, and every valid Activity Streams 1.0
document is a valid Activity Streams 2.0 document.
</p>
<p>
Please refer to Section 6 for more detail about the differences between
the 1.0 and 2.0 syntax and for a listing of specific backwards
compatibility requirements.
</p>
<p>
This specification incorporates several existing extensions to the
1.0 syntax directly into the 2.0 model. These include portions of
the Activity Streams 1.0 Base Schema, Audience
Targeting, Responses, and Priority extensions.
</p>
</section>
<section id="syntaxconventions">
<h2>Serialization Notes</h2>
<p>
This specification describes a JSON-based [[!RFC7159]] serialization
syntax for the <a href="activitystreams2-vocabulary.html">Activity
Vocabulary</a> that follows the conventions defined by the
[[!JSON-LD]] specification. While serialization forms other than
JSON-LD are possible, alternatives are not discussed by this
document.
</p>
<p>
When serialized, absent properties are represented by either (a)
setting the property value to null, or (b) by omitting the property
declaration altogether at the option of the publisher; these
representations are semantically equivalent. If a property has an
array value, the absence of any items in that array MUST be
represented by omitting the property entirely or by setting the value
to null. The appropriate interpretation of an omitted or explicitly
null value is that no value has been assigned as opposed to the view
that the given value is empty or nil.
</p>
<p>
This specification uses IRIs [[!RFC3987]]. Every URI [[!RFC3986]] is
also an IRI, so a URI may be used wherever an IRI is named. There are
two special considerations: (1) when an IRI that is not also a URI is
given for dereferencing, it MUST be mapped to a URI using the steps in
Section 3.1 of [[!RFC3987]] and (2) when an IRI is serving as an "id"
value, it MUST NOT be so mapped.
</p>
<p>
Unless otherwise specified, all properties with date and time values
MUST conform to the "date-time" production in [[!RFC3339]], with an
uppercase "T" character used to separate date and time, and an
uppercase "Z" character in the absence of a numeric time zone offset.
All such timestamps SHOULD be represented relative to Coordinated
Universal Time (UTC).
</p>
<p>
Activity Streams 2.0 documents MUST be serialized using the UTF-8
character encoding.
</p>
</section>
</section>
<section id="examples" class="informative">
<h2>Examples</h2>
<p>
Following are three examples of activities with varying degrees of detail. Each of the examples uses an implied JSON-LD @context equal to that provided <a href="activitystreams2-context.jsonld">here</a>.
</p>
<section id="example-1">
<h2>Minimal Activity</h2>
<figure>
<figcaption>
Expresses the statement "'urn:example:person:martin' posted
'http://example.org/foo.jpg'". No additional detail is given.
</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://www.w3.org/ns/activitystreams#Activity",
"verb": "post",
"actor": "urn:example:person:martin",
"object": "http://example.org/foo.jpg"
}</pre>
</figure>
<p><mark>Ed. Note: The example above uses the Activity Streams 1.0
form of an Activity "statement" consisting, essentially, of an
Actor+Verb+Object combination. It has been proposed that the "<code>verb</code>"
may be unnecessary in most cases. The proposal on the table is to
deprecate use of "<code>verb</code>" and use a "<code>@type</code>"
centric model instead, as illustrated in the following example:</mark></p>
<figure><figcaption>Expresses the same statement as above, using @type instead of verb</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "urn:example:Post",
"actor": "urn:example:person:martin",
"object": "http://example.org/foo.jpg"
}</pre></figure>
</section>
<section id="example-2">
<h2>Basic activity with some additional detail</h2>
<figure>
<figcaption>
Expresses the statement "Martin Smith posted an article to the blog
'Martin's Blog' at 3:04 PM GMT on February 2, 2011." Some additional
details about the article, actor and target blog are given using properties
defined by the <a href="activitystreams2-vocabulary.html">Activity Streams 2.0
Vocabulary</a>.
</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://www.w3.org/ns/activitystreams#Activity",
"language": "en",
"verb": "post",
"published": "2011-02-10T15:04:55Z",
"actor": {
"@type": "urn:example:types:person",
"@id": "urn:example:person:martin",
"displayName": "Martin Smith",
"url": "http://example.org/martin",
"image": {
"@id": "http://example.org/martin/image.jpg",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"mediaType": "image/jpeg"
}
},
"object" : {
"@type": "urn:example:types:article",
"@id": "urn:example:blog:abc123/xyz",
"url": "http://example.org/blog/2011/02/entry",
"displayName": "Why I love Activity Streams"
},
"target" : {
"@type": "urn:example:types:blog",
"@id": "http://example.org/blog/",
"displayName": "Martin's Blog"
}
}</pre>
</figure>
</section>
<section id="example-3">
<h2>An extended activity</h2>
<figure>
<figcaption>
A more extensive, single-entry "Activity Stream" follows.
</figcaption>
<pre class="example highlight json">
{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://www.w3.org/ns/activitystreams#Collection",
"totalItems": 1,
"items" : [
{
"@type": "http://www.w3.org/ns/activitystreams#Activity",
"language": "en",
"verb": "post",
"published": "2011-02-10T15:04:55Z",
"generator": "http://example.org/activities-app",
"provider": "http://example.org/activity-stream",
"displayName": {
"en": "Martin posted a new video to his album.",
"ga": "Martin phost le fisean nua a albam."
},
"actor": {
"@type": "urn:example:types:person",
"@id": "urn:example:person:martin",
"displayName": "Martin Smith",
"url": {
"@id": "http://example.org/martin",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"displayName": "Martin's Profile"
},
"image": {
"@id": "http://example.org/martin/image",
"@type": [
"http://www.w3.org/ns/activitystreams#Link",
"http://example.org/ImageResource"
],
"mediaType": "image/jpeg",
"width": 250,
"height": 250
}
},
"object" : {
"@type": "http://example.org/Photo",
"@id": "http://example.org/album/my_fluffy_cat.jpg",
"image": {
"@id": "http://example.org/album/my_fluffy_cat_thumb.jpg",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"mediaType": "image/jpeg",
"rel": "preview"
}
},
"target": {
"@type": "http://example.org/PhotoAlbum",
"@id": "http://example.org/album/",
"displayName": {
"en": "Martin's Photo Album",
"ga": "Grianghraif Mairtin"
},
"image": {
"@id": "http://example.org/album/thumbnail.jpg",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"mediaType": "image/jpeg"
}
}
}
]
}
</pre></figure>
</section>
</section>
<section id="model">
<h2>Model</h2>
<p>
The <a href="activitystreams2-vocabulary.html">Activity Vocabulary</a>
defines the abstract model for Activity Streams 2.0. The vocabulary
document defines seven distinct abstract classes: <a>Object</a>,
<a>Link</a>, <a>Collection</a>, <a>Activity</a>, <a>NaturalLanguageValue</a>,
<a>Verb</a>, and <a>ObjectType</a>. Each of these classes is described and
illustrated below.
</p>
<section id="object">
<h2><dfn title="Object" id="asobject">Object</dfn></h2>
<p>
The <code><a href="activitystreams2-vocabulary.html#dfn-object">Object</a></code>
class is the primary base class for the Activity Streams vocabulary. An
implementations would typically create it's own set of subclasses that
derive from the <code>http://www.w3.org/ns/activitystreams#Object</code> class as
opposed to using <code>Object</code> directly.
</p>
<p>
In addition to having a global identifier in the form of an absolute IRI
and an "object type" (expressed in JSON-LD using the <code>@type</code> keyword),
all instances of the <code>Object</code> class share a common set of properties
as defined by the <a href="activitystreams2-vocabulary.html">Activity Vocabulary</a>.
These include:
<code>
<a href="activitystreams2-vocabulary.html#dfn-action">action</a> |
<a href="activitystreams2-vocabulary.html#dfn-alias">alias</a> |
<a href="activitystreams2-vocabulary.html#dfn-attachment">attachment</a> |
<a href="activitystreams2-vocabulary.html#dfn-author">author</a> |
<a href="activitystreams2-vocabulary.html#dfn-content">content</a> |
<a href="activitystreams2-vocabulary.html#dfn-displayname">displayName</a> |
<a href="activitystreams2-vocabulary.html#dfn-duration">duration</a> |
<a href="activitystreams2-vocabulary.html#dfn-endtime">endTime</a> |
<a href="activitystreams2-vocabulary.html#dfn-generator">generator</a> |
<a href="activitystreams2-vocabulary.html#dfn-height">height</a> |
<a href="activitystreams2-vocabulary.html#dfn-icon">icon</a> |
<a href="activitystreams2-vocabulary.html#dfn-image">image</a> |
<a href="activitystreams2-vocabulary.html#dfn-inreplyto">inReplyTo</a> |
<a href="activitystreams2-vocabulary.html#dfn-language">language</a> |
<a href="activitystreams2-vocabulary.html#dfn-location">location</a> |
<a href="activitystreams2-vocabulary.html#dfn-memberof">memberOf</a> |
<a href="activitystreams2-vocabulary.html#dfn-provider">provider</a> |
<a href="activitystreams2-vocabulary.html#dfn-published">published</a> |
<a href="activitystreams2-vocabulary.html#dfn-rating">rating</a> |
<a href="activitystreams2-vocabulary.html#dfn-replies">replies</a> |
<a href="activitystreams2-vocabulary.html#dfn-resultof">resultOf</a> |
<a href="activitystreams2-vocabulary.html#dfn-scope">scope</a> |
<a href="activitystreams2-vocabulary.html#dfn-starttime">startTime</a> |
<a href="activitystreams2-vocabulary.html#dfn-summary">summary</a> |
<a href="activitystreams2-vocabulary.html#dfn-tag">tag</a> |
<a href="activitystreams2-vocabulary.html#dfn-title">title</a> |
<a href="activitystreams2-vocabulary.html#dfn-updated">updated</a> |
<a href="activitystreams2-vocabulary.html#dfn-validafter">validAfter</a> |
<a href="activitystreams2-vocabulary.html#dfn-validbefore">validBefore</a> |
<a href="activitystreams2-vocabulary.html#dfn-validfrom">validFrom</a> |
<a href="activitystreams2-vocabulary.html#dfn-validuntil">validUntil</a> |
<a href="activitystreams2-vocabulary.html#dfn-width">width</a> |
<a href="activitystreams2-vocabulary.html#dfn-url">url</a>
</code>
</p>
<p>
While all properties are optional, all <code>Object</code> instances SHOULD
at least contain a <a href="activitystreams2-vocabulary.html#dfn-displayname">displayName</a>.
</p>
<figure><figcaption>Following is an example Object that uses the JSON-ID <code>@id</code> and <code>@type</code>
JSON-LD keywords to express the global identifier and object type:</figcaption>
<pre class="example highlight json">
{
"@context": "http://www.w3.org/ns/activitystreams",
"@id": "http://example.org/foo",
"@type": "http://example.org/types/Note",
"language": "en",
"displayName": "This is a note",
"author": {
"@id": "urn:example:person:joe",
"@type": "http://example.org/types/Person",
"displayName": "Joe Smith"
},
"published": "2014-08-21T12:34:56Z"
}
</pre></figure>
</section>
<section id="naturalLanguageValues">
<h2><dfn title="NaturalLanguageValue">Natural Language Values</dfn></h2>
<p>
Several properties defined by the <a href="activitystreams2-vocabulary.html">Vocabulary</a>
are defined as being a <a href="activitystreams2-vocabulary.html">Natural Language Value</a>.
These are a representations of human-readable character sequences using one or more
languages. Within the JSON-LD serialization, they are expressed as either (1) a single JSON
string or (2) a JSON object mapping [[RFC5646]] Language-Tags to localized, equivalent
translations of the same string value. In [[JSON-LD]], such constructs are referred to
as "Language Maps".
</p>
<p>
For instance, the <code><a href="activitystreams2-vocabulary.html#dfn-displayname">displayName</a></code>
property is a Natural Language value.
</p>
<figure>
<figcaption>A single String value using the default language:</figcaption>
<pre class="example highlight json">{
"language": "en",
<b>"displayName": "This is the title"</b>
}</pre></figure>
<figure>
<figcaption>Multiple, language-specific values:</figcaption>
<pre class="example highlight json">{
<b>"displayName": {
"en": "This is the title",
"fr": "C'est le titre",
"sp": "Este es el titulo"
}</b>
}</pre></figure>
<p>
Every key in the JSON object MUST be an [[RFC5646]] Language-Tag.
The associated values MUST be Strings.
</p>
<section class="informative">
<h2>Implementation Note</h2>
<p>
Implementers ought to note that, in [[JSON-LD]], establishment of a default
language requires the use of the <code>@language</code> keyword inside the
JSON-LD <code>@context</code>. For instance:
</p>
<figure>
<figcaption>Using the <code>@language</code> keyword:</figcaption>
<pre class="example highlight json">{
"@context": {
"@language": "en"
},
"displayName": "This is the title"
}</pre></figure>
<p>Using the <code>@language</code> keyword in this manner establishes the
default language context for all string literal property values contained
by the object, including those that may not be intended as natural language
values. This current definition for <code>@language</code> makes it difficult
for implementations that choose to ignore JSON-LD semantics when processing
Activity Streams documents or that wish to limit the language context only to
properties that are truly intended as natural language values. The <code>language</code>
property introduced by the Activity Streams Vocabulary is provided to address
these shortcomings by allowing a default language to be established independently
of the JSON-LD <code>@context</code>.</p>
<figure>
<figcaption>Using the <code>language</code> property has the same effect
as using the <code>@language</code> inside the JSON-LD <code>@context</code>:</figcaption>
<pre class="example highlight json">{
"language": "en",
"displayName": "This is the title"
}</pre></figure>
<p>However, use of <code>language</code>
means that JSON-LD based implementations will need to take an additional
processing step to ensure that properties such as <code>title</code>, <code>displayName</code>,
<code>summary</code> and <code>content</code> are handled properly.
<figure>
<figcaption>For instance, the following example JavaScript function extracts
the value of the <code>language</code> property and injects it as an appropriate
JSON-LD <code>@language</code> keyword into specific properties that are defined
as Natural Language Values to ensure that such properties are properly handled
by the standardized JSON-LD algorithms:</figcaption>
<pre class="example highlight javascript">
function _fixdefaultlanguage(lang, obj) {
var __lang = obj['language'] || lang;
for (var n in obj) {
if (nlvs.indexOf(n) > -1) {
var vals = obj[n];
vals.forEach(function(val) {
val['@language'] = val['@language'] || __lang;
});
} else if (typeof obj[n] === 'object') {
var next = exp[n];
if (!Array.isArray(next))
next = [next];
next.forEach(
_fixdefaultlanguage.bind(
null,__lang));
}
}
}
</pre>
</figure>
</section>
</section>
<section id="link">
<h2><dfn title="Link">Link</dfn></h2>
<p>
A <code>Link</code> represents a dereferenceable pointer to another resource.
Within the JSON-LD serialization, they are expressed as either: (1) a String
containing an absolute or relative IRI, (2) a JSON object, or (3) an Array
containing a mixture of IRIs or JSON objects. Links are closely related to
the conceptual model of Links as established in [[!RFC5988]].
</p>
<p>
The target URI of the Link is the global identifier expressed in the JSON-LD
serialization using the <code>@id</code> keyword. In addition, all <code>Link</code>
instances share the following common set of properties as defined by the
<a href="activitystreams2-vocabulary.html">Activity Vocabulary</a>:
<code>
<a href="activitystreams2-vocabulary.html#dfn-displayname">displayName</a> |
<a href="activitystreams2-vocabulary.html#dfn-hreflang">hreflang</a> |
<a href="activitystreams2-vocabulary.html#dfn-language">language</a> |
<a href="activitystreams2-vocabulary.html#dfn-mediatype">mediaType</a> |
<a href="activitystreams2-vocabulary.html#dfn-rel">rel</a> |
<a href="activitystreams2-vocabulary.html#dfn-title">title</a>
</code>
</p>
<p>
For example, all <a title="Object">Objects</a> can contain an
<code><a href="activitystreams2-vocabulary.html#dfn-image">image</a></code>
property whose value describes a graphical
representation of the containing object. This property will
typically be used to provide the URL to a JPEG, GIF or PNG type
resource that can be displayed to the user. Any given object might
have multiple such visual representations -- multiple screenshots,
for instance, or the same image at different resolutions. Using Links,
there are essentially three ways of describing such references.
</p>
<figure><figcaption>To reference a single image without any additional metadata, the link
value can be expressed as a simple JSON string containing an absolute
or relative IRI:</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://example.org/types/application",
"@id": "http://example.org/application/123",
"displayName": "My Application",
<b>"image": "http://example.org/application/123.png"</b>
}</pre></figure>
<figure><figcaption>
Alternatively, if additional metadata is required, the link can be
expressed as a JSON object:.
</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://example.org/types/application",
"@id": "http://example.org/application/123",
"displayName": "My Application",
<b>"image": {
"@id": "http://example.org/application/123.png",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"mediaType": "image/png"
}</b>
}</pre></figure>
<p>
Formally, the former example establishes a unqualified
relationship to the image resource while the latter creates a
qualified relationship that allows additional properties
to be specified for the link. Such properties (e.g. <code>mediaType</code>,
<code>hreflang</code>, <code>rel</code>, etc) describe the <a>Link</a>
relationship itself as opposed to describing the referenced resource. For
many practical applications, this distinction will likely be fairly
insignificant but it is still worth keeping in mind.
</p>
<figure><figcaption>
If more than one link value is to be expressed, A JSON Array with a
mix of string and object elements can be used:
</figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://example.org/types/application",
"@id": "http://example.org/application/123",
"displayName": "My Application",
<b>"image": [
"http://example.org/application/abc.gif",
{
"@id": "http://example.org/application/123.png",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"mediaType": "image/png"
}
]</b>
}</pre></figure>
<p>
Individual items contained in such an array are independent of the
others and no significance is given to the ordering of those items.
</p>
<p>
RFC 5988 defines that all Links have a "link relation" that describes
the contextual purpose of the link. Within a <a>Link</a>,
the <code><a href="activitystreams2-vocabulary.html#dfn-rel">rel</a></code> property
provides the link relation value. If no <code>rel</code> property is
specified, the Link is not considered to have a specified link relation.
</p>
<p>
In the following example, two separate links are provided. The link
relation of the first is unspecified, while the link relation of the
second is "<code>preview</code>". Either link, however, can be used as
alternative visual representations of the object.
</p>
<figure><figcaption></figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "urn:example:types:application",
<b>"image": [
"http://example.org/foo.jpg",
{
"@id": "http://example.org/screens/1.jpg",
"@type": "http://www.w3.org/ns/activitystreams#Link",
"rel": "preview",
"mediaType": "image/jpeg"
}
]</b>
}</pre></figure>
<p>
It ought to be noted that the [[!HTML5]] specification provides it's own alternative
definition of a "link relation" that differs slightly from the [[RFC5988]] definition.
In the HTML5 definition, any string that does not contain the "space" U+0020, "tab" (U+0009),
"LF" (U+000A), "FF" (U+000C), "CR" (U+000D) or "," (U+002C) characters can be used as a
valid link relation. To promote interoperability, Activity Streams 2.0 implementations
MUST only use link relations that are valid in terms of both the [[RFC5988]] and
[[HTML5]] definitions.
</p>
<p>
Also note that it is possible to use <a>Link</a> and <a>Object</a> together to indicate
that a particular JSON object can be interpretted as both. For instance, in the
following example, the value of the <code>image</code> property is marked as being
both a <a>Link</a> and a hypothetical <code>urn:example:image</code> object that,
for the sake of this example, derives from <code>Object</code>. This allows additional
properties describing the <a>Object</a> -- such as <code>height</code> and <code>width</code> --
to be specified.
</p>
<figure><figcaption></figcaption>
<pre class="example highlight json">{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "urn:example:types:application",
"image": [
"http://example.org/foo.jpg",
{
"@id": "http://example.org/screens/1.jpg",
"@type": [
"http://www.w3.org/ns/activitystreams#Link",
"urn:example:image"],
"rel": "preview",
"mediaType": "image/jpeg",
"height": 200,
"width": 200
}
]
}</pre></figure>
</section>
<section id="activities">
<h2><dfn title="Activity" id="activity">Activity</dfn></h2>
<p>
Activity objects are specializations of the base <a>Object</a>
type that provide information about ongoing or completed actions.
</p>
<p>
In additional to common properties supported by all <a>Object</a>
instances, <code>Activity</code> objects support the following additional
properties defined by the <a href="activitystreams2-vocabulary.html">Vocabulary</a>:
<code>
<a href="activitystreams2-vocabulary.html#dfn-verb-term">verb</a> |
<a href="activitystreams2-vocabulary.html#dfn-actor">actor</a> |
<a href="activitystreams2-vocabulary.html#dfn-object-term">object</a> |
<a href="activitystreams2-vocabulary.html#dfn-target">target</a> |
<a href="activitystreams2-vocabulary.html#dfn-result">result</a> |
<a href="activitystreams2-vocabulary.html#dfn-instrument">instrument</a> |
<a href="activitystreams2-vocabulary.html#dfn-participant">participant</a> |
<a href="activitystreams2-vocabulary.html#dfn-priority">priority</a> |
<a href="activitystreams2-vocabulary.html#dfn-status">status</a> |
<a href="activitystreams2-vocabulary.html#dfn-to">to</a> |
<a href="activitystreams2-vocabulary.html#dfn-bto">bto</a> |
<a href="activitystreams2-vocabulary.html#dfn-cc">cc</a> |
<a href="activitystreams2-vocabulary.html#dfn-bcc">bcc</a>
</code>
</p>
<p>
The <code>verb</code> property is used to identify the type of activity.
If the <code>verb</code> is not specified, the <code>@type</code> keyword
MAY be used as an alternative means of determining the activity type.
</p>
<figure><figcaption>The following example illustrates a simple Activity:</figcaption>
<pre class="example highlight json"><code>{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://www.w3.org/ns/activitystreams#Activity",
"@id": "urn:example:activity:1",
"verb": {
"@id": "urn:example:verb:like",
"displayName": "like"
},
"actor": "http://example.org/profiles/joe",
"object": "http://example.com/notes/1",
"published": "2014-09-30T12:34:56Z"
}
</code></pre></figure>
<p><mark>Ed. Note: Following the proposal to deprecate "<code>verb</code>" in
favor of a "<code>@type</code>" centric approach, this example becomes:</mark></p>
<figure><figcaption></figcaption>
<pre class="example highlight json"><code>{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "urn:example:Like",
"@id": "urn:example:activity:1",
"actor": "http://example.org/profiles/joe",
"object": "http://example.com/notes/1",
"published": "2014-09-30T12:34:56Z"
}</code></pre></figure>
<section class="informative">
<h2>Implementation Note</h2>
<p>
Since Activity Streams 1.0, the <code>verb</code> property has
been defined to permit identifiers either in the form of absolute IRI's
or simple <code>isegment-nz-nc</code> tokens. For instance,
"<code>post</code>" is a valid Activity Streams verb.
</p>
<p>
However, existing JSON-LD processing algorithms have difficulty
processing such <code>isegment-nz-nc</code> token values properly
without additional processing. It is RECOMMENDED that JSON-LD
implementations handle simple <code>isegment-nz-nc</code> verbs
as "blank nodes". For instance, the value "<code>post</code>" would
map to the blank node identified as <code>_:post</code>.
</p>
</section>
<section id="audienceTargeting">
<h2>Audience Targeting</h2>
<p>
Every Activity has both a Primary and Secondary audience. The
Primary audience consists of those entities either directly involved
in the performance of the activity or who "own" the objects involved.
The Secondary audience consists of the collection of entities sharing
an interest in the activity but who are not directly involved (e.g.
"followers").
</p>
<p>
For instance, suppose a social network of three individuals: Bob, Joe
and Jane. Bob and Joe are each friends with Jane but not friends
with one another. Bob has chosen to "follow" activities for which
Jane is directly involved. Jane shares a file with Joe.
</p>
<p>
In this example, Jane and Joe are each directly involved in the file
sharing activity and together make up the Primary Audience for that
event. Bob, having an interest in activities involving Jane, is the
Secondary Audience. Knowing this, a system that produces or consumes
the activity can intelligently notify each person of the event.
</p>
<p>
While there are means, based on the verb, actor, object and target of
the activity, to infer the primary audience for many types of
activities, those do not work in every case and do not provide a
means of identifying the secondary audience. The
<code><a href="activitystreams2-vocabulary.html#dfn-to">to</a></code>,
<code><a href="activitystreams2-vocabulary.html#dfn-cc">cc</a></code>,
<code><a href="activitystreams2-vocabulary.html#dfn-bto">bto</a></code> and
<code><a href="activitystreams2-vocabulary.html#dfn-bcc">bcc</a></code>
properties MAY be used within an Activity to explicitly identify the
Primary and Secondary audiences.
</p>
<p>
The prototypical use case for an Activity containing these properties
is the publication and redistribution of Activities through an
intermediary. That is, an event source generates the activity and
publishes it to the intermediary which determines a subset of events
to display to specific individual users or groups. Such a
determination can be made, in part, by identifying the Primary and
Secondary Audiences for each activity.
</p>
<p>
When the event source generates the activity and specifies values for
the <code>to</code> and <code>cc</code> fields, the
intermediary SHOULD redistribute that event
with the values of those fields intact, allowing any processor to see
who the activity has been targeted to. This is precisely the same
model used by the <code>to</code> and <code>cc</code> fields in email systems.
<p>
There are situations, however, in which disclosing the identity of
specific members of the audience may be inappropriate. For instance,
a user may not wish to let other users know that they are interested
in various topics, individuals or types of events. To support this
option, an event source generating an activity MAY use the
<code>bto</code> and <code>bcc</code> properties to list
entities to whom the activity should be privately targeted. When an
intermediary receives an activity containing these properties, it
MUST remove those values prior to redistributing the activity. The
intent is that systems MUST consider entities listed within the
<code>bto</code> and <code>bcc<</code> properties as
part of the Primary and Secondary audience but MUST NOT disclose that
fact to any other party.
</p>
<p>
Audience targeting information included within an Activity only
describes the intent of the activity creator. With clear exception
given to the appropriate handling of <code>bto</code> and
<code>bcc</code>, this specification leaves it up to implementations
to determine how the audience targeting information is used.
</p>
</section>
</section>
<section id="collections">
<h2><dfn title="Collection" id="collection">Collection</dfn></h2>
<p>
Collection objects are a specialization of the base <a>Object</a>
that contain a listing of other <a title="Object">Objects</a>.
The Collection object is used primarily as the root of an
<a>Activity Streams Document</a>, but can also be used as the
value of object properties.
</p>
<p>
Collections have both a logical model and a physical serialization.
While the logical view of a collection might contain a large number
of objects, any single serialized representation might include only a
subset of those objects, with specific "paging" <a title="Link">Links</a>
used to reference additional serialized representations that include
additional subsets. Such representations are known as "multi-page
collections", with each serialized subset representing a single
"page".
</p>
<p>
All Collection objects have an <code><a href="activitystreams2-vocabulary#dfn-items">items</a></code>
property whose value is a JSON array of <a title="Object">Objects</a> of any type. The <code>items</code>
property MUST be supported by all implementations.
</p>
<p>
In addition to the common properties shared by all <a>Object</a> instances,
<code>Collection</code> objects set of properties defined by the
<a href="activitystreams2-vocabulary">Vocabulary</a>. These include:
<code>
<a href="activitystreams2-vocabulary.html#dfn-items">items</a> |
<a href="activitystreams2-vocabulary.html#dfn-totalitems">totalItems</a> |
<a href="activitystreams2-vocabulary.html#dfn-itemsperpage">itemsPerPage</a> |
<a href="activitystreams2-vocabulary.html#dfn-startindex">startIndex</a> |
<a href="activitystreams2-vocabulary.html#dfn-itemsafter">itemsAfter</a> |
<a href="activitystreams2-vocabulary.html#dfn-itemsbefore">itemsBefore</a> |
<a href="activitystreams2-vocabulary.html#dfn-current">current</a> |
<a href="activitystreams2-vocabulary.html#dfn-next">next</a> |
<a href="activitystreams2-vocabulary.html#dfn-prev">prev</a> |
<a href="activitystreams2-vocabulary.html#dfn-first">first</a> |
<a href="activitystreams2-vocabulary.html#dfn-last">last</a> |
<a href="activitystreams2-vocabulary.html#dfn-self">self</a>
</code>
</p>
<figure><figcaption>The following is a simple collection with paging:</figcaption>
<pre class="example highlight json">
{
"@context": "http://www.w3.org/ns/activitystreams",
"@type": "http://www.w3.org/ns/activitystreams#Collection",
"totalItems": 10,
"itemsPerPage": 1,
"itemsSince": "2012-12-12T12:34:56Z",
"next": "http://example.org/foo?page=2",
"self": "http://example.org/foo?page=1",
"items": [
{
"actor": "urn:example:person:sally",
"verb": "post",
"object": "http://example.org/foo"
}
]
}
</pre></figure>
</section>
<section id="verb-objecttype">
<h2>Verbs and Object Types</h2>
<p>
A <code><dfn>Verb</dfn></code> is a subclass of <a>Object</a> used to
specifically describe metadata associated with an <a>Activity</a> <code>verb</code>
identifier.