Commit Graph

33 Commits

Author SHA1 Message Date
Hugo Sales af3531f1c7
[CORE][GSFile] Add type annotation to the `$encoders` used in attachment handling 2021-09-23 14:54:21 +01:00
Diogo Peralta Cordeiro 7beb5c2995
[GSFile] Fix sanitize configuration 2021-09-22 15:13:46 +01:00
Hugo Sales 4e30e5aad9
[TOOLS] Fix all issues found by PHPStan level 2 2021-09-14 13:13:44 +01:00
Diogo Peralta Cordeiro bc1fb007aa
[Core][GSFile] Improve the way EncoderPlugins participate in the file sanitization process 2021-09-14 13:13:34 +01:00
Hugo Sales 2351e7c6d1
[CORE][GSFile] Use pathinfo rather than regular expressions and don't attempt to persist an already persisted entity 2021-09-14 13:13:28 +01:00
Hugo Sales c3db2f60d2
[UTIL][EXCEPTIONS] Introduce NotStoredLocallyException 2021-09-14 13:13:28 +01:00
Hugo Sales 6445a616a8
[ENTITY][Attachment] Raise mimetype max length to 64 characters and ensure we don't attempt to store more than that 2021-09-14 13:13:28 +01:00
Diogo Peralta Cordeiro b4a03b814f
[CORE][GSFile] ensureFilenameWithProperExtension: extension isn't an I/O param 2021-09-14 13:13:26 +01:00
Diogo Peralta Cordeiro 968e3431e1
[Attachment] Sometimes we can't provide download of original file 2021-09-14 13:13:26 +01:00
Diogo Peralta Cordeiro 4cc4523632
[Posting] Re-add original file to attachment on upload, if it was previously removed 2021-09-14 13:13:26 +01:00
Diogo Peralta Cordeiro f5175cc59d
[ATTACHMENTS] Always store in the same location 2021-09-14 13:13:24 +01:00
Diogo Peralta Cordeiro 3f61537140
[ENTITY] Split Attachment in various new entities
Remove Attachment Scope
Fixed some minor bugs

Scope will be implemented later in v3. It doesn't make sense to have
the scope handling being per attachment. Different actors can post
the same attachment with different scopes. The attachment controller
will assume the highest level of scope applied to the attachment and
the rest will be handled at the note level.

Motivation:
* Remove title from attachment, as it's part of the relation between attachment and note.
* Remove actor from attachment, many actors may publish the same attachment.
* Remove is_local from attachment,  as it's part of the relation between attachment and note.
* Remove remote_url from attachment, different urls can return the same attachment.

Addition:
* Attachment now has a lives attribute,  it's a reference counter with a nicer name
* GSActorToAttachment
* GSActorToRemoteURL
* RemoteURL
* RemoteURLToNote
* RemoteURLToAttachment
* AttachmentToNote now has a title attribute
2021-09-14 13:13:24 +01:00
Hugo Sales 2851b899b8
[TESTS] Add test annotations to core classes 2021-09-14 13:13:23 +01:00
Diogo Peralta Cordeiro fb6aa78ae8
[CORE][GSFile] Allow storing files under /file 2021-09-14 13:13:20 +01:00
Hugo Sales 647e4c03b3
[CORE][GSFile] Ensure files are stored inside the configured storage folder, with a relative filename in the database 2021-09-14 13:13:19 +01:00
Hugo Sales dc2b9f940e
[CORE][GSFile] Assert that the destination folder where to store the attachment is inside the INSTALLDIR and store the filepath in the database 2021-09-14 13:13:18 +01:00
Hugo Sales 88dd9e542f
[CORE][GSFile] Change actor_id paramenter of validateAndStoreFileAsAttachment to optional and reorder them and their usages 2021-09-14 13:13:17 +01:00
Hugo Sales f5fb4ed3c3
[TESTS] Add tests for GSFile 2021-09-14 13:13:15 +01:00
Diogo Peralta Cordeiro 861732176e
[Media] Support any kind of thumbnails in the Core
Sanitize Attachments instead of Validate (part 1)
Ensure the intended filetypes and mimetypes during Vips conversions (part 1)
Various bug fixes
2021-09-14 13:13:03 +01:00
Diogo Peralta Cordeiro c8cf8c3f13
[FILE][TemporaryFile] Fix various issues now that we also have Symfony's file abstractions 2021-09-14 13:13:03 +01:00
Hugo Sales 4f936108a1
[ATTACHMENTS] Don't store an attachment if it's a dupplicate, reuse it 2021-09-14 13:12:58 +01:00
Diogo Peralta Cordeiro 1e7d8cac9a
[ATTACHMENTS] Follow URL redirects and don't duplicate attachments 2021-09-14 13:12:57 +01:00
Diogo Peralta Cordeiro 1c9f807595
[Embed] Fix some bugs and change AttachmentEmbed::url to ::media_url 2021-09-14 13:12:56 +01:00
Diogo Peralta Cordeiro c9090e6cee
[ATTACHMENTS][GSFile] Rename ValidateAndStore functions 2021-09-14 13:12:56 +01:00
Hugo Sales 6d31945401
[ATTACHMENTS] In sendFile, check that file exists or show a custom exception 2021-09-14 13:12:56 +01:00
Hugo Sales 7509913fcf
[ENTITY] Add field size to attachments, used for quota calculations 2021-09-14 13:12:54 +01:00
Hugo Sales be91fb754d
[CORE] Typo in GSFile and slight Twig weirdness in base template 2021-09-14 13:12:52 +01:00
Hugo Sales 2adb3c3521
[ATTACHMENTS] Add event 'AttachmentFileInfo' to allow a plugin to override the file displayed 2021-09-14 13:12:52 +01:00
Hugo Sales 34059a8d3d
[ATTACHMENTS][EVENT] Add onHashFile event, which can be used to deduplicate files
Currently, we simply hash the contents of the file with sha256, but in the future we can use something smarter,
which could find visual feature similarity between images
2021-09-14 13:12:51 +01:00
Hugo Sales e94df546c3
[Posting] Extract and store URLs from note content. Introduce 'AttachmentStoreNew' event 2021-09-14 13:12:23 +01:00
Hugo Sales e1995f44ce
[ATTACHMENTS] Move thumbnail controller to core and cleanup 2021-09-14 13:12:22 +01:00
Diogo Peralta Cordeiro e385a9ac29
[ATTACHMENTS] Even more further refactoring
Introduce Encoder plugins Instead of abstract upload and thumb modules

Ported attachment routes. In v3 thumbnail depends on existing attachment
so route updated accordingly.
2021-09-14 13:12:18 +01:00
Diogo Peralta Cordeiro 0eaccc32fe
[ATTACHMENTS] Further refactoring
Some key points:
- Components and Plugins shouldn't extend Module directly
- Avatars should be fetched via GSActor ID, not by nickname as that isn't unique
- Avatar now is a separate Component
- Common file utilities are now to be placed in Core\GSFile, this will
  handle storage and trigger validation
- Some bug fixes
2021-09-14 13:11:51 +01:00