* Update multiple activities with partial operations. * @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update * @param {ActivityPartialChanges []} changes array containing the changesets to be applied. Every cha
(changes: ActivityPartialChanges<StreamFeedGenerics>[])
| 1038 | * ]) |
| 1039 | */ |
| 1040 | activitiesPartialUpdate(changes: ActivityPartialChanges<StreamFeedGenerics>[]) { |
| 1041 | if (!(changes instanceof Array)) { |
| 1042 | throw new TypeError('changes should be an Array'); |
| 1043 | } |
| 1044 | changes.forEach( |
| 1045 | (item: ActivityPartialChanges<StreamFeedGenerics> & { foreign_id?: string; foreignID?: string }) => { |
| 1046 | if (!(item instanceof Object)) { |
| 1047 | throw new TypeError(`changeset should be and Object`); |
| 1048 | } |
| 1049 | if (item.foreignID) { |
| 1050 | item.foreign_id = item.foreignID; |
| 1051 | } |
| 1052 | if (item.id === undefined && (item.foreign_id === undefined || item.time === undefined)) { |
| 1053 | throw new TypeError('missing id or foreign_id and time'); |
| 1054 | } |
| 1055 | if (item.set && !(item.set instanceof Object)) { |
| 1056 | throw new TypeError('set field should be an Object'); |
| 1057 | } |
| 1058 | if (item.unset && !(item.unset instanceof Array)) { |
| 1059 | throw new TypeError('unset field should be an Array'); |
| 1060 | } |
| 1061 | }, |
| 1062 | ); |
| 1063 | |
| 1064 | let token = this.userToken as string; |
| 1065 | if (this.usingApiSecret) { |
| 1066 | token = JWTScopeToken(this.apiSecret as string, 'activities', '*', { |
| 1067 | feedId: '*', |
| 1068 | expireTokens: this.expireTokens, |
| 1069 | }); |
| 1070 | } |
| 1071 | |
| 1072 | return this.post<APIResponse & { activities: Activity<StreamFeedGenerics>[] }>({ |
| 1073 | url: 'activity/', |
| 1074 | body: { changes }, |
| 1075 | token, |
| 1076 | }); |
| 1077 | } |
| 1078 | |
| 1079 | /** |
| 1080 | * Flag a user for moderation |
no test coverage detected