[MODULES] Introduce the concept of abstract modules to V3

Introduce placeholder for abstract upload and thumb modules
Temporarily supress some bugs
This commit is contained in:
Diogo Peralta Cordeiro 2021-04-15 00:30:35 +01:00 committed by Hugo Sales
parent 539f1861a6
commit ccf3aa990a
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
30 changed files with 106 additions and 60 deletions

View File

@ -19,7 +19,7 @@
namespace Component\Bridge;
use App\Core\Module;
use App\Core\Modules\Module;
class Bridge extends Module
{

View File

@ -21,7 +21,7 @@ namespace Component\Left;
use App\Core\Event;
use App\Core\Log;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Util\Common;
use Exception;

View File

@ -21,7 +21,7 @@ namespace Component\Media;
use App\Core\Cache;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Util\Common;
use App\Util\Nickname;

View File

@ -23,7 +23,7 @@ use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Security;
use App\Entity\FileToNote;
use App\Entity\Note;

View File

@ -24,7 +24,7 @@ services:
App\Core\Router\RouteLoader:
tags: ['routing.loader']
# Wrapper arround Doctrine's StaticPHP metadata driver
# Wrapper around Doctrine's StaticPHP metadata driver
app.schemadef_driver:
class: App\DependencyInjection\Compiler\SchemaDefDriver
arguments:

View File

@ -22,7 +22,7 @@ namespace Plugin\Cover;
use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Router\RouteLoader;
use App\Util\Common;

View File

@ -22,7 +22,7 @@
namespace Plugin\Directory;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Router\RouteLoader;
class Directory extends Module

View File

@ -33,7 +33,7 @@
namespace Plugin\EmailNotifications;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
class EmailNotifications extends Module
{

View File

@ -32,7 +32,7 @@
namespace Plugin\Embed;
use App\Core\Module;
use App\Core\Modules\Module;
/**
* Base class for the Embed plugin that does most of the heavy lifting to get

View File

@ -22,10 +22,10 @@ namespace Plugin\Favourite;
use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Form;
use App\Core\Module;
use App\Entity\Favourite as Fave;
use App\Core\Modules\Module;
use App\Entity\Note;
use App\Util\Common;
use Plugin\Favourite\Entity\Favourite as Fave;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;

View File

@ -20,7 +20,7 @@
namespace Plugin\Media;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Router\RouteLoader;
class Media extends Module

View File

@ -24,7 +24,7 @@ use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Router\RouteLoader;
use App\Entity\Note;
use App\Entity\PollResponse;

View File

@ -22,7 +22,7 @@ namespace Plugin\ProfileColor;
use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Core\Router\RouteLoader;
use App\Util\Common;

View File

@ -22,7 +22,7 @@ namespace Plugin\Repeat;
use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Form;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exception\NotFoundException;

View File

@ -25,7 +25,7 @@ use App\Core\DB\DB;
use App\Core\Event;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Module;
use App\Core\Modules\Module;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exceptiion\InvalidFormException;

View File

@ -16,7 +16,7 @@
namespace Plugin\StoreRemoteMedia;
use App\Core\Module;
use App\Core\Modules\Module;
/**
* The StoreRemoteMedia plugin downloads remotely attached files to local server.

View File

@ -19,10 +19,8 @@
namespace Plugin\TreeNotes;
use App\Core\Modules\Module;
use App\Entity\Note;
use App\Core\Event;
use App\Core\Module;
use Functional as F;
class TreeNotes extends Module
{
@ -31,7 +29,7 @@ class TreeNotes extends Module
*/
public function onFormatNoteList(array &$notes_in_trees_out)
{
$roots = array_filter($notes_in_trees_out, function(Note $note) { return $note->getReplyTo() == null; }, ARRAY_FILTER_USE_BOTH);
$roots = array_filter($notes_in_trees_out, function (Note $note) { return $note->getReplyTo() == null; }, ARRAY_FILTER_USE_BOTH);
$notes_in_trees_out = $this->build_tree($roots, $notes_in_trees_out);
}
@ -46,7 +44,7 @@ class TreeNotes extends Module
private function build_subtree(Note $parent, array $notes)
{
$children = array_filter($notes, function(Note $n) use ($parent) { return $parent->getId() == $n->getReplyTo(); }, ARRAY_FILTER_USE_BOTH);
$children = array_filter($notes, function (Note $n) use ($parent) { return $parent->getId() == $n->getReplyTo(); }, ARRAY_FILTER_USE_BOTH);
return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)];
}
}

View File

@ -28,7 +28,7 @@
namespace Plugin\FFmpeg;
use App\Core\Module;
use App\Core\Modules\Module;
use Plugin\Media\Util\ImageFile;
class FFmpeg extends Module

View File

@ -0,0 +1,23 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-13 03:09+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. TRANS: Plugin description.
#: FFmpegPlugin.php:104
msgid "Use PHP-FFMpeg for resizing animated GIFs"
msgstr ""

View File

@ -33,7 +33,7 @@
namespace Plugin\XMPPNotifications;
use App\Core\Event;
use App\Core\Module;
use App\Core\Modules\Module;
class XMPPNotifications extends Module
{

View File

@ -17,7 +17,7 @@
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Core;
namespace App\Core\Modules;
use App\Entity\Note;
use App\Util\Common;

View File

@ -0,0 +1,12 @@
<?php
namespace App\Core\Modules;
// Remote Download allow to create a file or to download directly as a thumbnail; same plugins as for upload will validate
// as validation event will be the same as that of upload - same logic
abstract class RemoteAttachmentDownload
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Core\Modules;
// an interface that specifies how thumbs shall be created, allowing for generation of image, video, pdf, wtv by plugin
abstract class Thumbnail
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Core\Modules;
// used by avatar and attachment in note creation; plugins will be able to validate certain filetypes such as images
abstract class Upload
{
}

View File

@ -154,17 +154,6 @@ class File extends Entity
return $this->is_local;
}
public function setIsNsfw(?bool $is_nsfw): self
{
$this->is_nsfw = $is_nsfw;
return $this;
}
public function getIsNsfw(): ?bool
{
return $this->is_nsfw;
}
public function setIsUrlProtected(?bool $is_url_protected): self
{
$this->is_url_protected = $is_url_protected;
@ -233,18 +222,17 @@ class File extends Entity
return [
'name' => 'file',
'fields' => [
'id' => ['type' => 'serial', 'not null' => true],
'url' => ['type' => 'text', 'description' => 'URL after following possible redirections'],
'url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'],
'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'description' => 'If set, used so each actor can have a version of this file (for avatars, for instance)'],
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
'title' => ['type' => 'text', 'description' => 'title of resource when available'],
'filename' => ['type' => 'varchar', 'length' => 191, 'description' => 'title of resource when available'],
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
'is_nsfw' => ['type' => 'bool', 'default' => false, 'description' => 'whether the file is NSFW'],
'is_url_protected' => ['type' => 'bool', 'default' => false, 'description' => 'true when URL is private (needs login)'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
'id' => ['type' => 'serial', 'not null' => true],
'remote_url' => ['type' => 'text', 'description' => 'URL after following possible redirections'],
'remote_url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'],
'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'description' => 'If set, used so each actor can have a version of this file (for avatars, for instance)'],
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
'title' => ['type' => 'text', 'description' => 'title of resource when available'],
'filename' => ['type' => 'varchar', 'length' => 191, 'description' => 'title of resource when available'],
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
'source' => ['type' => 'int', 'default' => null, 'description' => 'Source of the Attachment (upload, TFN, embed)'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
],
'primary key' => ['id'],
'unique keys' => [

View File

@ -96,7 +96,7 @@ class Authenticator extends AbstractFormLoginAuthenticator
$user = DB::findOneBy('local_user', ['or' => ['nickname' => $nick, 'outgoing_email' => $nick]]);
} catch (Exception $e) {
throw new CustomUserMessageAuthenticationException(
_m('\'{nickname}\' doesn\'t match any registered nickname or email.', ['{nickname}' => $credentials['nickname']]));
_m('\'{nickname}\' doesn\'t match any registered nickname or email.', ['nickname' => $credentials['nickname']]));
}
return $user;

View File

@ -25,9 +25,10 @@
{% for attachment in note.getAttachments() %}
{% if attachment.mimetype starts with 'image/' %}
<div>
<img src="{{ path('attachment_inline', {'id': attachment.getId()}) }}" alt="{{ attachment.getTitle() }}">
<i> {{ attachment.getTitle() }} </i>
</img>
<figure>
<img src="{{ path('attachment_inline', {'id': attachment.getId()}) }}" alt="{{ attachment.getTitle() }}">
<figcaption> {{ attachment.getTitle() }} </figcaption>
</figure>
</div>
{% elseif attachment.mimetype starts with 'video/' %}
<div>
@ -45,14 +46,16 @@
</div>
<div class="note-actions">
{% if have_user %}
{% for act in get_note_actions(note) %}
{{ form(act) }}
{% endfor %}
{#{% for act in get_note_actions(note) %}#}
{#{{ form(act) }}#}
{#{% endfor %}#}
{% endif %}
</div>
<div class="replies">
{% for conversation in replies %}
{% include '/note/view.html.twig' with {'note': conversation['note'], 'skip_reply_to': true, 'have_user': have_user, 'replies': conversation['replies']} only %}
{% endfor %}
</div>
{% if replies is defined %}
<div class="replies">
{% for conversation in replies %}
{% include '/note/view.html.twig' with {'note': conversation['note'], 'skip_reply_to': true, 'have_user': have_user, 'replies': conversation['replies']} only %}
{% endfor %}
</div>
{% endif %}
</div>