Remove content type from email attachment
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -26,26 +26,23 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
EmailAttachment struct {
|
EmailAttachment struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
EmailID gid.GID `db:"email_id"`
|
EmailID gid.GID `db:"email_id"`
|
||||||
FileID gid.GID `db:"file_id"`
|
FileID gid.GID `db:"file_id"`
|
||||||
Filename string `db:"filename"`
|
Filename string `db:"filename"`
|
||||||
// TODO (to drop)
|
CreatedAt time.Time `db:"created_at"`
|
||||||
ContentType string `db:"content_type"`
|
|
||||||
CreatedAt time.Time `db:"created_at"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailAttachments []*EmailAttachment
|
EmailAttachments []*EmailAttachment
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewEmailAttachment(emailID, fileID gid.GID, filename, contentType string) *EmailAttachment {
|
func NewEmailAttachment(emailID, fileID gid.GID, filename string) *EmailAttachment {
|
||||||
return &EmailAttachment{
|
return &EmailAttachment{
|
||||||
ID: gid.New(gid.NilTenant, EmailAttachmentEntityType),
|
ID: gid.New(gid.NilTenant, EmailAttachmentEntityType),
|
||||||
EmailID: emailID,
|
EmailID: emailID,
|
||||||
FileID: fileID,
|
FileID: fileID,
|
||||||
Filename: filename,
|
Filename: filename,
|
||||||
ContentType: contentType,
|
CreatedAt: time.Now(),
|
||||||
CreatedAt: time.Now(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,16 +51,15 @@ func (a *EmailAttachment) Insert(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO email_attachments (id, email_id, file_id, filename, content_type, created_at)
|
INSERT INTO email_attachments (id, email_id, file_id, filename, created_at)
|
||||||
VALUES (@id, @email_id, @file_id, @filename, @content_type, @created_at)
|
VALUES (@id, @email_id, @file_id, @filename, @created_at)
|
||||||
`
|
`
|
||||||
args := pgx.StrictNamedArgs{
|
args := pgx.StrictNamedArgs{
|
||||||
"id": a.ID,
|
"id": a.ID,
|
||||||
"email_id": a.EmailID,
|
"email_id": a.EmailID,
|
||||||
"file_id": a.FileID,
|
"file_id": a.FileID,
|
||||||
"filename": a.Filename,
|
"filename": a.Filename,
|
||||||
"content_type": a.ContentType,
|
"created_at": a.CreatedAt,
|
||||||
"created_at": a.CreatedAt,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := conn.Exec(ctx, q, args)
|
_, err := conn.Exec(ctx, q, args)
|
||||||
@@ -80,7 +76,7 @@ func (a *EmailAttachments) LoadByEmailID(
|
|||||||
emailID gid.GID,
|
emailID gid.GID,
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT id, email_id, file_id, filename, content_type, created_at
|
SELECT id, email_id, file_id, filename, created_at
|
||||||
FROM email_attachments
|
FROM email_attachments
|
||||||
WHERE email_id = @email_id
|
WHERE email_id = @email_id
|
||||||
ORDER BY created_at ASC
|
ORDER BY created_at ASC
|
||||||
|
|||||||
2
pkg/coredata/migrations/20260220T150000Z.sql
Normal file
2
pkg/coredata/migrations/20260220T150000Z.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE email_attachments
|
||||||
|
DROP COLUMN content_type;
|
||||||
@@ -328,13 +328,11 @@ func (w *CompletionCertificateWorker) generateCertificate(
|
|||||||
email.ID,
|
email.ID,
|
||||||
signedFile.ID,
|
signedFile.ID,
|
||||||
signedFile.FileName,
|
signedFile.FileName,
|
||||||
signedFile.MimeType,
|
|
||||||
),
|
),
|
||||||
coredata.NewEmailAttachment(
|
coredata.NewEmailAttachment(
|
||||||
email.ID,
|
email.ID,
|
||||||
certificateOfCompletionFile.ID,
|
certificateOfCompletionFile.ID,
|
||||||
certificateFilename,
|
certificateFilename,
|
||||||
"application/pdf",
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ func (m *Mailer) batchSendEmails(ctx context.Context) error {
|
|||||||
return fmt.Errorf("cannot download attachment %s: %w", att.Filename, err)
|
return fmt.Errorf("cannot download attachment %s: %w", att.Filename, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [esign] maybe use AddAttachmentWithReader instead?
|
// TODO [esign] maybe use AddAttachmentWithReader instead?
|
||||||
mail = mail.AddAttachment(data, att.ContentType, att.Filename)
|
mail = mail.AddAttachment(data, file.MimeType, att.Filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
envelope, err := mail.Build()
|
envelope, err := mail.Build()
|
||||||
|
|||||||
Reference in New Issue
Block a user