add content id for attachments#30
add content id for attachments#30farhan27 wants to merge 1 commit intoStackStorm-Exchange:masterfrom
Conversation
nmaludy
left a comment
There was a problem hiding this comment.
Couple other things we need here:
- Updated pack version. This is a breaking change, so a bump in the major version is probably necessary.
- Updated changelog
- Add unit tests
| items: | ||
| type: "string" | ||
| description: "The absolute paths to the files to be included as attachments." | ||
| type: "Object" |
There was a problem hiding this comment.
should "object" instead of uppercase "Object", this is why the test failed
There was a problem hiding this comment.
I don't like simply converting this over, because it would break this action for all users and all workflows that are currently using this action and passing in strings here.
We should be able to use oneOf here to preserve backwards compatibility for existing users of this pack. Please do so.
attachments:
type: array
description: |
An array or list of items, either strings or objects/dictionaries, that specifies
each file to be included as attachments.
items:
oneOf: # this should be camelCase, as defined by JSONSchema
- type: string
description: The absolute path to the file to be attached
- type: object
description: An object containing file_id and file_path keys
properties:
file_id:
type: string
description: A unique identifier for the attachment in the mail envelope
file_path:
type: string
description: The absolute path to the file to be attachedNote that oneOf should be camelCase, as it is defined in JSONSchema, but file_id and file_path should both be snake_case, as they are interpreted by Python in StackStorm.
| filename = os.path.basename(el['filePath']) | ||
| with open(el['filePath'], 'rb') as f: |
There was a problem hiding this comment.
Additionally, it should be possible to make this backwards compatible, so users of this pack do not have to update every single place they call this action. Please modify the Python to use the old code path if el is a string, and the new codepath if el is a dictionary.
Also, please use snake_case for dictionary keys in StackStorm, not camelCase.
| items: | ||
| type: "string" | ||
| description: "The absolute paths to the files to be included as attachments." | ||
| type: "Object" |
There was a problem hiding this comment.
I don't like simply converting this over, because it would break this action for all users and all workflows that are currently using this action and passing in strings here.
We should be able to use oneOf here to preserve backwards compatibility for existing users of this pack. Please do so.
attachments:
type: array
description: |
An array or list of items, either strings or objects/dictionaries, that specifies
each file to be included as attachments.
items:
oneOf: # this should be camelCase, as defined by JSONSchema
- type: string
description: The absolute path to the file to be attached
- type: object
description: An object containing file_id and file_path keys
properties:
file_id:
type: string
description: A unique identifier for the attachment in the mail envelope
file_path:
type: string
description: The absolute path to the file to be attachedNote that oneOf should be camelCase, as it is defined in JSONSchema, but file_id and file_path should both be snake_case, as they are interpreted by Python in StackStorm.
|
|
Change attachments input from string to object to allow adding of attachment Id
This to allow the attachment ie image to be use in the email body
example of attachment input :
[{'filePath':'/test1', 'fileId':'test1'}]