Simplify send templates (#237)

* Simplify Send templates

* Fix internal template reference

* No trailing whitespace
This commit is contained in:
Matt Gibson 2021-02-26 12:47:11 -06:00 committed by GitHub
parent 2c11e5d6a9
commit e77e1c94e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -36,6 +36,8 @@ import { Response } from 'jslib/cli/models/response';
import { MessageResponse } from 'jslib/cli/models/response/messageResponse';
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
import { SendType } from 'jslib/enums/sendType';
import { CipherResponse } from '../models/response/cipherResponse';
import { CollectionResponse } from '../models/response/collectionResponse';
import { FolderResponse } from '../models/response/folderResponse';
@ -430,14 +432,11 @@ export class GetCommand extends DownloadCommand {
case 'org-collection':
template = OrganizationCollectionRequest.template();
break;
case 'send':
template = SendResponse.template();
break;
case 'send.text':
template = SendTextResponse.template();
template = SendResponse.template(SendType.Text);
break;
case 'send.file':
template = SendFileResponse.template();
template = SendResponse.template(SendType.File);
break;
default:
return Response.badRequest('Unknown template object.');

View File

@ -14,13 +14,13 @@ const dateProperties: string[] = [Utils.nameOf<SendResponse>('deletionDate'), Ut
export class SendResponse implements BaseResponse {
static template(deleteInDays = 7): SendResponse {
static template(sendType?: SendType, deleteInDays = 7): SendResponse {
const req = new SendResponse();
req.name = 'Send name';
req.notes = 'Some notes about this send.';
req.type = SendType.Text;
req.text = null;
req.file = null;
req.text = sendType === SendType.Text ? SendTextResponse.template() : null;
req.file = sendType === SendType.File ? SendFileResponse.template() : null;
req.maxAccessCount = null;
req.deletionDate = this.getStandardDeletionDate(deleteInDays);
req.expirationDate = null;

View File

@ -251,7 +251,7 @@ export class SendProgram extends Program {
sendText = SendTextResponse.template(data, options.hidden);
}
const template = Utils.assign(SendResponse.template(options.deleteInDays), {
const template = Utils.assign(SendResponse.template(null, options.deleteInDays), {
name: options.name ?? name,
notes: options.notes,
file: sendFile,