Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local attachments have no created_at value assigned #5901

Open
ChristophWurst opened this issue Dec 23, 2021 · 2 comments
Open

Local attachments have no created_at value assigned #5901

ChristophWurst opened this issue Dec 23, 2021 · 2 comments
Labels
1. to develop bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in.

Comments

@ChristophWurst
Copy link
Member

ChristophWurst commented Dec 23, 2021

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.
@ChristophWurst ChristophWurst added bug 1. to develop priority:medium good first issue Small tasks with clear documentation about how and in which place you need to fix things in. labels Dec 23, 2021
@miaulalala
Copy link
Contributor

Question for my understanding only: why do we not work with constraints like ON CREATE and ON UPDATE?

@ChristophWurst
Copy link
Member Author

Triggers are not possible at the moment: nextcloud/server#31130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants