activity.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { ActivityPubActor } from './activitypub-actor'
  2. import { ActivityPubSignature } from './activitypub-signature'
  3. import { ActivityFlagReasonObject, CacheFileObject, VideoObject, WatchActionObject } from './objects'
  4. import { AbuseObject } from './objects/abuse-object'
  5. import { DislikeObject } from './objects/dislike-object'
  6. import { APObject } from './objects/object.model'
  7. import { PlaylistObject } from './objects/playlist-object'
  8. import { VideoCommentObject } from './objects/video-comment-object'
  9. export type Activity =
  10. ActivityCreate |
  11. ActivityUpdate |
  12. ActivityDelete |
  13. ActivityFollow |
  14. ActivityAccept |
  15. ActivityAnnounce |
  16. ActivityUndo |
  17. ActivityLike |
  18. ActivityReject |
  19. ActivityView |
  20. ActivityDislike |
  21. ActivityFlag
  22. export type ActivityType =
  23. 'Create' |
  24. 'Update' |
  25. 'Delete' |
  26. 'Follow' |
  27. 'Accept' |
  28. 'Announce' |
  29. 'Undo' |
  30. 'Like' |
  31. 'Reject' |
  32. 'View' |
  33. 'Dislike' |
  34. 'Flag'
  35. export interface ActivityAudience {
  36. to: string[]
  37. cc: string[]
  38. }
  39. export interface BaseActivity {
  40. '@context'?: any[]
  41. id: string
  42. to?: string[]
  43. cc?: string[]
  44. actor: string | ActivityPubActor
  45. type: ActivityType
  46. signature?: ActivityPubSignature
  47. }
  48. export interface ActivityCreate extends BaseActivity {
  49. type: 'Create'
  50. object: VideoObject | AbuseObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject | WatchActionObject
  51. }
  52. export interface ActivityUpdate extends BaseActivity {
  53. type: 'Update'
  54. object: VideoObject | ActivityPubActor | CacheFileObject | PlaylistObject
  55. }
  56. export interface ActivityDelete extends BaseActivity {
  57. type: 'Delete'
  58. object: string | { id: string }
  59. }
  60. export interface ActivityFollow extends BaseActivity {
  61. type: 'Follow'
  62. object: string
  63. }
  64. export interface ActivityAccept extends BaseActivity {
  65. type: 'Accept'
  66. object: ActivityFollow
  67. }
  68. export interface ActivityReject extends BaseActivity {
  69. type: 'Reject'
  70. object: ActivityFollow
  71. }
  72. export interface ActivityAnnounce extends BaseActivity {
  73. type: 'Announce'
  74. object: APObject
  75. }
  76. export interface ActivityUndo extends BaseActivity {
  77. type: 'Undo'
  78. object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce
  79. }
  80. export interface ActivityLike extends BaseActivity {
  81. type: 'Like'
  82. object: APObject
  83. }
  84. export interface ActivityView extends BaseActivity {
  85. type: 'View'
  86. actor: string
  87. object: APObject
  88. // If sending a "viewer" event
  89. expires?: string
  90. }
  91. export interface ActivityDislike extends BaseActivity {
  92. id: string
  93. type: 'Dislike'
  94. actor: string
  95. object: APObject
  96. }
  97. export interface ActivityFlag extends BaseActivity {
  98. type: 'Flag'
  99. content: string
  100. object: APObject | APObject[]
  101. tag?: ActivityFlagReasonObject[]
  102. startAt?: number
  103. endAt?: number
  104. }