[ATTACHMENTS][GSFile] Rename ValidateAndStore functions

This commit is contained in:
Diogo Peralta Cordeiro 2021-05-01 22:14:38 +01:00 committed by Hugo Sales
parent a3860e6257
commit c9090e6cee
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 9 additions and 9 deletions

View File

@ -106,7 +106,7 @@ class Avatar extends Controller
} else {
throw new ClientException('Invalid form');
}
$attachment = GSFile::validateAndStoreAttachment($sfile, Common::config('avatar', 'dir'), $title = null, $is_local = true, $use_unique = $gsactor_id);
$attachment = GSFile::validateAndStoreFileAsAttachment($sfile, Common::config('avatar', 'dir'), $title = null, $is_local = true, $use_unique = $gsactor_id);
$old_attachment = null;
$avatar = DB::find('avatar', ['gsactor_id' => $gsactor_id]);
// Must get old id before inserting another one

View File

@ -115,7 +115,7 @@ END;
$processed_attachments = [];
foreach ($attachments as $f) {
$processed_attachments[] = GSFile::validateAndStoreAttachment(
$processed_attachments[] = GSFile::validateAndStoreFileAsAttachment(
$f, Common::config('attachments', 'dir'),
Security::sanitize($f->getClientOriginalName()),
is_local: true, actor_id: $actor_id
@ -125,7 +125,7 @@ END;
$matched_urls = [];
preg_match_all(self::URL_REGEX, $content, $matched_urls, PREG_SET_ORDER);
foreach ($matched_urls as $match) {
$processed_attachments[] = GSFile::validateAndStoreURL($match[0]);
$processed_attachments[] = GSFile::validateAndStoreURLAsAttachment($match[0]);
}
DB::persist($note);

View File

@ -38,11 +38,11 @@ class GSFile
/**
* Perform file validation (checks and normalization) and store the given file
*/
public static function validateAndStoreAttachment(SymfonyFile $sfile,
string $dest_dir,
?string $title = null,
bool $is_local = true,
int $actor_id = null): Attachment
public static function validateAndStoreFileAsAttachment(SymfonyFile $sfile,
string $dest_dir,
?string $title = null,
bool $is_local = true,
int $actor_id = null): Attachment
{
Event::handle('HashFile', [$sfile->getPathname(), &$hash]);
// The following properly gets the mimetype with `file` or other
@ -69,7 +69,7 @@ class GSFile
*
* @throws \InvalidArgumentException
*/
public static function validateAndStoreURL(string $url): Attachment
public static function validateAndStoreURLAsAttachment(string $url): Attachment
{
if (Common::isValidHttpUrl($url)) {
$head = HTTPClient::head($url);