53 Commits

Author SHA1 Message Date
Christophe Bliard 643a58f801 Trigger virus scanning after completing direct upload to S3 storage
https://community.openproject.org/wp/67664

When storing attachments on S3, the file is not fully uploaded until the
direct upload finishes (hook called from client browser when file is
finished uploading).

The `FinishDirectUploadService#schedule_jobs` now calls
`attachment.enqueue_jobs` to ensure the same jobs are run on attachment
creation (useful when s3 storage is not used) and on attachment upload
completion. This means virus scanning job is now triggered correctly.
2025-09-24 12:21:58 +02:00
Alexander Brandon Coles 5e9f3827f5 Freeze string literals in app/services
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze app/services
2025-07-18 17:45:24 +01:00
Jan Sandbrink 40aff02f11 Remove params argument from BaseCallable#perform
This is making the interface of BaseCallable more consistent.
Previously it was unclear, whether the params passed to perform
should be used to reference parameters or whether the attribute accessor
should be used. Different code used different approaches.

To apply this change more consistently, BaseContracted also removed
params from the methods called inside its own perform method, e.g.
before_perform or after_validate.

At a later point we might consider removing this argument from other large
inheritors as well, for example `BaseServices::SetAttributes#set_attributes`.
2025-06-30 11:47:03 +02:00
ulferts 3ba3e8b74b work in review comments 2025-06-24 11:55:37 +02:00
ulferts 0ecd09b06b rename to allowlist 2025-06-24 11:19:26 +02:00
ulferts 31573972b0 use a BaseContracted service for finishing attachment upload
Those services place a semaphore preventing race conditions on journal creation
2025-06-24 11:19:25 +02:00
Ivan Kuchin bca7db9398 update copyrights 2024-07-31 15:02:50 +02:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
ulferts 3b2121f733 Revert "Merge remote-tracking branch 'origin/release/13.4' into dev"
This reverts commit 40b2bbeb09, reversing
changes made to b4c6cb17cc.
2024-03-21 11:31:17 +01:00
Ivan Kuchin 7787e457a3 Revert "Merge branch 'dev' into release/13.4"
This reverts commit a901541269, reversing
changes made to e573ca00b7.
2024-03-20 20:19:08 +01:00
Ivan Kuchin 9e4934cd0a change quotes using rubocop --only Style/StringLiterals,Style/QuotedSymbols -a 2024-03-20 18:05:22 +01:00
Oliver Günther 1aba59a5ca Ping check on save, warning when disabling scan 2024-02-20 09:36:44 +01:00
Oliver Günther 669a1041bb Extract scanning into service 2024-02-20 09:36:43 +01:00
Oliver Günther 857532e506 Implement attachment statuses and virus scanning 2024-02-20 09:36:41 +01:00
Oliver Günther 731c8937ea Implement attachment status 2024-02-20 09:36:40 +01:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01:00
Christophe Bliard c795874f7f Update copyright year for 2024
command used: `rg -l 'Copyright \(C\) 2012-202\d the OpenProject' | xargs -n 100 sed -i -r 's/Copyright \(C\) 2012-202. the OpenProject/Copyright (C) 2012-2024 the OpenProject/'`
2024-01-02 16:23:54 +01:00
Christophe Bliard 9e865b4f7b lint: Run rubocop safe autocorrect
Command is `rubocop --safe --autocorrect app lib lib_static modules spec`
2023-03-09 10:25:57 +01:00
Christophe Bliard a06e519ed7 Set send_notifications only when not nil
When calling a service with `send_notifications: false`, the
`Journal::NotificationConfiguration.active?` will be set to `false` and
subsequent calls to set it to `true` will have no effect and log a
warning.

For this reason, it's better to use `nil` as default value for
`send_notifications` so that
`Journal::NotificationConfiguration.active?` is changed only when the
value is explicitly `true` or `false`, and ignored when the value is
`nil`.
2023-02-27 17:47:34 +01:00
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01:00
Christophe Bliard b50855a955 Use ServiceResult factory methods where possible
All was automatic through the use of `rubocop --autocorrect --only
OpenProject/UseServiceResultFactoryMethods app lib lib_static modules
spec`.
2022-06-16 10:01:57 +02:00
ulferts b1e453d662 use default update service for wps 2022-06-13 15:41:33 +02:00
Christophe Bliard 48a4f1b6ad lint with rubocop --autocorrect (safe cops only) 2022-06-02 10:40:10 +02:00
Christophe Bliard a33524ef6d remove ruby magic comment for utf-8
ruby interprets source encoding as utf-8 since 2.0.0, making magic comment redundant and useless
2022-03-10 19:36:58 +01:00
Christophe Bliard bc8d423ec2 update copyright information for 2022 2022-03-01 17:05:59 +01:00
Oliver Günther 0ec9db6e96 Fix direct upload with a whitelist present that does not contain binary 2021-11-03 13:22:38 +01:00
Markus Kahl d86e2787c7 Merge branch 'release/11.4' into dev 2021-10-20 13:44:48 +01:00
Markus Kahl 320d1e77de fix direct upload for all content types 2021-10-14 21:00:38 +01:00
Eric Schubert ece686d600 Merge branch 'release/11.4' into feature/38981-merge-changes-of-114 2021-09-30 10:29:19 +02:00
Oliver Günther 0b5da9b9e1 Give access to the issue project when trying to save a viewpoint (#9707) 2021-09-28 15:21:52 +02:00
Oliver Günther 15fc0846e6 Bypass whitelist in internal services when conflicting with user 2021-09-20 09:24:20 +02:00
Oliver Günther 9323b89bac Enforce writing the content type without accepting user input 2021-09-20 09:24:16 +02:00
Oliver Günther 9e1dc1d50e Set snapshot through attachment service 2021-09-20 09:24:13 +02:00
Oliver Günther a59e4dc376 Replace wiki page attach_files with attachable services 2021-09-20 09:24:09 +02:00
Oliver Günther 582579729e Replace ifc models attachment handling with services 2021-09-20 09:24:06 +02:00
Oliver Günther b94b0e630d Fix filesize validation on prepared uploads 2021-09-20 09:22:39 +02:00
Oliver Günther 287111c574 Add prepare service and contract 2021-09-20 09:22:35 +02:00
Oliver Günther c59c57ad76 Make attachments API BaseServices compatible 2021-09-20 09:22:34 +02:00
Oliver Günther 5854a34124 [37866] Add attachment_created event and webhook (#9418)
* [37866] Add attachment_created event and webhook

* Remove other usages of direct attachment creation

* Add attachment webhook spec

* Fix other webhook specs

* Fix attachment adding in mail_handler

* Don't set content_type outside attachment#file=

* Fix unrelated spec

Co-authored-by: ulferts <jens.ulferts@googlemail.com>
(cherry picked from commit d2ce834e23)
2021-09-13 07:10:52 +02:00
Oliver Günther ccfa29c728 Move license and copyright docs to root, fix names and references 2021-09-02 21:50:46 +02:00
Oliver Günther e9d7c374cc [37868] Whitelist for attachment mime types and extensions on upload (#9431)
* Add setting for whitelist

* Make attachments API BaseServices compatible

* Add prepare service and contract

* Correctly pass the filename to the UploadedFile

* Add presence check to filename

* Fix expected validation message

* We no longer raise a multipart error when metadata is empty

* Fix filesize validation on prepared uploads

* Add parser error if invalid metadata json

* When attachment is not saved, use filename property

* Return correct error message on JSON parser erroro

* Fix specs

* Use attachment upload representer

* Fix direct uploads mocks with new service layer

* Lint

* Fix export job using attachment service

* Fix IFC controller using attachment prepare service

* Fix export job

* RenameRename params_getter to params_source

* Fix mail handler using attachment service

* Fix usage of attachment create service in documents

* Reuse shared examples for document attachment spec

* Fix stubbed attachment service in export job spec

* Use admin user in backup spec

* Fix export job for bim

* Fix attachment integration spec

* Fix issues_controller spec

* Make budget resource spec reuse common examples

* Fix attachment parsing representer spec

* Replace prepare part of attachment spec into separate service spec

* Clear cache for login spec

* Convert document create/update into services

* Budget services

* Allow options to be passed to property twin

* Remove setting author on budget initialize

* Replace meetings update with services

* Replace ifc models attachment handling with services

* Don't check uploader if changed by system

* Fix uploader being changed by system

* Replace wiki page attach_files with attachable services

* Replace avatar  saving

* Replace snapshot attach_files

* Skip double validation when container present

* Set snapshot through attachment service

* Remove attach_files

* Validate content type in contract

* Enforce writing the content type without accepting user input

* Expect changed content_type

* Fix content of viewpoint image to get correct content type

* Fix tsv spec

* Add create contract spec

* Bypass whitelist in internal services when conflicting with user

* Fix expects in specs after whitelist bypass

* Render contract errors for wiki

* Add before_hook to bodied to allow to pre-authorize permissions

* Budget errors from contract

* Document errors from contract
2021-07-14 14:43:19 +02:00
Oliver Günther d2ce834e23 [37866] Add attachment_created event and webhook (#9418)
* [37866] Add attachment_created event and webhook

* Remove other usages of direct attachment creation

* Add attachment webhook spec

* Fix other webhook specs

* Fix attachment adding in mail_handler

* Don't set content_type outside attachment#file=

* Fix unrelated spec

Co-authored-by: ulferts <jens.ulferts@googlemail.com>
2021-06-29 09:24:11 +02:00
ulferts 08ce0a5436 Fix/attachment journalizing (#9292)
* update the container timestamp upon attachment creation

That way, the journal subsequently created on the journalized container will bear the expected timestamp

* update container timestamp on attachment deletion

Without it, the journal created after the deletion will bear the wrong timestamp

* avoid bumping lock_version on attachment adding/destroy
2021-05-20 09:23:47 +02:00
ulferts 1bdd2ab9ae safe automatic fixes by rubocop (#8994) 2021-02-11 16:02:18 +01:00
ulferts 6140f4c7e9 update copyright to 2021 (#8925)
Updates the copyright to 2021 for all files that have a copyright. Files in our source code without the copyright header still do not receive one automatically. Additionally, backlisted files are also excluded.

Previously the copyright of chiliproject which references redmine stated a copyright of redmine up to and including 2017 which is not true for the code we have in here. Because of that I changed that to 2013
2021-01-13 17:47:45 +01:00
ulferts 983709db89 rewrite acts as journalized to create journals in sql 2020-05-25 10:43:04 +02:00
ulferts ffc131695a use services/contracts for forum messages 2020-03-02 15:49:31 +01:00
ulferts a895767619 have a delete service for attachments 2020-03-02 15:49:31 +01:00
ulferts 0cda1869a8 employ advisory lock for all update services 2020-03-02 15:49:30 +01:00
ulferts 34ac8c9621 employ advisory lock for journal creation on attachment uploading 2020-03-02 15:49:30 +01:00