-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug] content-publisher needs to be its own source of truth for annou…
…ncement attachments (#341) # Description As a user, I should not have to keep track of the association between an uploaded asset reference ID and its media type. More specifically, I should not be able to tell content-publisher the type of an asset in an Announcment publish request (Broadcast, Reply, etc), as that opens up an attack vector to specify a media type that does not match the actual uploaded asset. content-publisher should be its own source of truth in coordinating asset type with the actual asset. - [x] Remove `type` from `BroadcastDto`, `UpdateDto`, `ReplyDto` - Removed from `AssetDto`, which is included by all of the above - [x] Update OpenAPI spec - Updated using the `generate` scripts - [x] Add `type` to cached metadata for uploaded asset Closes #338
- Loading branch information
1 parent
f3dc764
commit a166a97
Showing
8 changed files
with
187 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,27 +167,16 @@ Use the provided [env.template](./env.template) file to create an initial enviro | |
|
||
```sh | ||
cp env.template .env | ||
cp env.template .env.docker.dev | ||
``` | ||
|
||
2. Configure the environment variable values according to your environment. | ||
|
||
### Setup | ||
|
||
Clone this repository to your desired folder: | ||
|
||
Example commands: | ||
|
||
```sh | ||
git clone [email protected]:AmplicaLabs/content-publishing-service.git | ||
cd content-publishing-service | ||
``` | ||
|
||
### Install | ||
|
||
Install NPM Dependencies: | ||
|
||
```sh | ||
cd services/content-publishing | ||
npm install | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,93 @@ | ||
/* eslint-disable */ | ||
export default async () => { | ||
const t = { | ||
["../../../libs/common/src/dtos/activity.dto"]: await import("../../../libs/common/src/dtos/activity.dto"), | ||
["../../../libs/common/src/dtos/announcement.dto"]: await import("../../../libs/common/src/dtos/announcement.dto") | ||
}; | ||
return { "@nestjs/swagger": { "models": [[import("../../../libs/common/src/dtos/common.dto"), { "DsnpUserIdParam": { userDsnpId: { required: true, type: () => String } }, "AnnouncementResponseDto": { referenceId: { required: true, type: () => String } }, "UploadResponseDto": { assetIds: { required: true, type: () => [String] } }, "FilesUploadDto": { files: { required: true, type: () => [Object] } } }], [import("../../../libs/common/src/dtos/activity.dto"), { "LocationDto": { name: { required: true, type: () => String, minLength: 1 }, accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, altitude: { required: false, type: () => Number }, latitude: { required: false, type: () => Number }, longitude: { required: false, type: () => Number }, radius: { required: false, type: () => Number, minimum: 0 }, units: { required: false, enum: t["../../../libs/common/src/dtos/activity.dto"].UnitTypeDto } }, "AssetReferenceDto": { referenceId: { required: true, type: () => String, minLength: 1 }, height: { required: false, type: () => Number, minimum: 1 }, width: { required: false, type: () => Number, minimum: 1 }, duration: { required: false, type: () => String, pattern: "DURATION_REGEX" } }, "TagDto": { type: { required: true, enum: t["../../../libs/common/src/dtos/activity.dto"].TagTypeDto }, name: { required: false, type: () => String, minLength: 1 }, mentionedId: { required: false, type: () => String } }, "AssetDto": { type: { required: true, enum: t["../../../libs/common/src/dtos/activity.dto"].AttachmentTypeDto }, references: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, name: { required: false, type: () => String, minLength: 1 }, href: { required: false, type: () => String, minLength: 1 } }, "BaseActivityDto": { name: { required: false, type: () => String }, tag: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].TagDto] }, location: { required: false, type: () => t["../../../libs/common/src/dtos/activity.dto"].LocationDto } }, "NoteActivityDto": { content: { required: true, type: () => String, minLength: 1 }, published: { required: true, type: () => String }, assets: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetDto] } }, "ProfileActivityDto": { icon: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, summary: { required: false, type: () => String }, published: { required: false, type: () => String } } }], [import("../../../libs/common/src/dtos/announcement.dto"), { "BroadcastDto": { content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReplyDto": { inReplyTo: { required: true, type: () => String }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "TombstoneDto": { targetContentHash: { required: true, type: () => String }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto } }, "UpdateDto": { targetContentHash: { required: true, type: () => String }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReactionDto": { emoji: { required: true, type: () => String, minLength: 1, pattern: "DSNP_EMOJI_REGEX" }, apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, inReplyTo: { required: true, type: () => String } }, "ProfileDto": { profile: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].ProfileActivityDto } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }]] } }; | ||
}; | ||
const t = { | ||
['../../../libs/common/src/dtos/activity.dto']: await import('../../../libs/common/src/dtos/activity.dto'), | ||
['../../../libs/common/src/dtos/announcement.dto']: await import('../../../libs/common/src/dtos/announcement.dto'), | ||
}; | ||
return { | ||
'@nestjs/swagger': { | ||
models: [ | ||
[ | ||
import('../../../libs/common/src/dtos/common.dto'), | ||
{ | ||
DsnpUserIdParam: { userDsnpId: { required: true, type: () => String } }, | ||
AnnouncementResponseDto: { referenceId: { required: true, type: () => String } }, | ||
UploadResponseDto: { assetIds: { required: true, type: () => [String] } }, | ||
FilesUploadDto: { files: { required: true, type: () => [Object] } }, | ||
}, | ||
], | ||
[ | ||
import('../../../libs/common/src/dtos/activity.dto'), | ||
{ | ||
LocationDto: { | ||
name: { required: true, type: () => String, minLength: 1 }, | ||
accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, | ||
altitude: { required: false, type: () => Number }, | ||
latitude: { required: false, type: () => Number }, | ||
longitude: { required: false, type: () => Number }, | ||
radius: { required: false, type: () => Number, minimum: 0 }, | ||
units: { required: false, enum: t['../../../libs/common/src/dtos/activity.dto'].UnitTypeDto }, | ||
}, | ||
AssetReferenceDto: { | ||
referenceId: { required: true, type: () => String, minLength: 1 }, | ||
height: { required: false, type: () => Number, minimum: 1 }, | ||
width: { required: false, type: () => Number, minimum: 1 }, | ||
duration: { required: false, type: () => String, pattern: 'DURATION_REGEX' }, | ||
}, | ||
TagDto: { | ||
type: { required: true, enum: t['../../../libs/common/src/dtos/activity.dto'].TagTypeDto }, | ||
name: { required: false, type: () => String, minLength: 1 }, | ||
mentionedId: { required: false, type: () => String }, | ||
}, | ||
AssetDto: { | ||
references: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto] }, | ||
name: { required: false, type: () => String, minLength: 1 }, | ||
href: { required: false, type: () => String, minLength: 1 }, | ||
}, | ||
BaseActivityDto: { | ||
name: { required: false, type: () => String }, | ||
tag: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].TagDto] }, | ||
location: { required: false, type: () => t['../../../libs/common/src/dtos/activity.dto'].LocationDto }, | ||
}, | ||
NoteActivityDto: { | ||
content: { required: true, type: () => String, minLength: 1 }, | ||
published: { required: true, type: () => String }, | ||
assets: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetDto] }, | ||
}, | ||
ProfileActivityDto: { | ||
icon: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto] }, | ||
summary: { required: false, type: () => String }, | ||
published: { required: false, type: () => String }, | ||
}, | ||
}, | ||
], | ||
[ | ||
import('../../../libs/common/src/dtos/announcement.dto'), | ||
{ | ||
BroadcastDto: { content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto } }, | ||
ReplyDto: { | ||
inReplyTo: { required: true, type: () => String }, | ||
content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, | ||
}, | ||
TombstoneDto: { | ||
targetContentHash: { required: true, type: () => String }, | ||
targetAnnouncementType: { required: true, enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto }, | ||
}, | ||
UpdateDto: { | ||
targetContentHash: { required: true, type: () => String }, | ||
targetAnnouncementType: { required: true, enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto }, | ||
content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, | ||
}, | ||
ReactionDto: { | ||
emoji: { required: true, type: () => String, minLength: 1, pattern: 'DSNP_EMOJI_REGEX' }, | ||
apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, | ||
inReplyTo: { required: true, type: () => String }, | ||
}, | ||
ProfileDto: { profile: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].ProfileActivityDto } }, | ||
}, | ||
], | ||
], | ||
controllers: [[import('./controllers/health.controller'), { HealthController: { healthz: {}, livez: {}, readyz: {} } }]], | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.