Skip to content

Local attachments have no created_at value assigned #5901

@ChristophWurst

Description

@ChristophWurst

Expected behavior

Attachments added to new messages are stored in mail_attachments. At \OCA\Mail\Service\Attachment\AttachmentService::addFile we don't assign a value to createdAt, thus the timestamp is of default 0.

Actual behavior

The timestamp is set to a real value. We need this to clean up old data.

Mail app

Mail app version: v1.11


Implementation detail

  • Inject \OCP\AppFramework\Utility\ITimeFactory into \OCA\Mail\Service\Attachment\AttachmentService::__construct
  • Assign the time factory to a new private class property
  • Use the time factor and getTime() to fetch the current time stamp
  • Assign the time stamp value to the attachment via LocalAttachment::setCreatedAt
  • Bonus: write a migration that drops the default value of the mail_attachments.created_at column and make it NOT NULL. That enforces that a value has to be specified for an insert and would have prevented this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3. to reviewbuggood first issueSmall tasks with clear documentation about how and in which place you need to fix things in.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions