1
0
Fork 0

Experimental feature to enter a custom creation date

This commit is contained in:
Michael 2022-04-13 05:31:32 +00:00
parent d5f0829cad
commit 0d8cf06e4a
12 changed files with 306 additions and 270 deletions

View file

@ -36,14 +36,12 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
use Friendica\Model\FileTag; use Friendica\Model\FileTag;
use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\ItemURI; use Friendica\Model\ItemURI;
use Friendica\Model\Notification; use Friendica\Model\Notification;
@ -57,7 +55,6 @@ use Friendica\Protocol\Activity;
use Friendica\Security\Security; use Friendica\Security\Security;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Worker\Delivery;
function item_post(App $a) { function item_post(App $a) {
if (!Session::isAuthenticated()) { if (!Session::isAuthenticated()) {
@ -544,11 +541,11 @@ function item_post(App $a) {
$datarray['author-link'] = $author['url']; $datarray['author-link'] = $author['url'];
$datarray['author-avatar'] = $author['thumb']; $datarray['author-avatar'] = $author['thumb'];
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']); $datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['created'] = DateTimeFormat::utcNow(); $datarray['created'] = empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'];
$datarray['edited'] = DateTimeFormat::utcNow(); $datarray['edited'] = $datarray['created'];
$datarray['commented'] = DateTimeFormat::utcNow(); $datarray['commented'] = $datarray['created'];
$datarray['changed'] = $datarray['created'];
$datarray['received'] = DateTimeFormat::utcNow(); $datarray['received'] = DateTimeFormat::utcNow();
$datarray['changed'] = DateTimeFormat::utcNow();
$datarray['extid'] = $extid; $datarray['extid'] = $extid;
$datarray['guid'] = $guid; $datarray['guid'] = $guid;
$datarray['uri'] = $uri; $datarray['uri'] = $uri;

View file

@ -316,6 +316,18 @@ class Conversation
$jotplugins = ''; $jotplugins = '';
Hook::callAll('jot_tool', $jotplugins); Hook::callAll('jot_tool', $jotplugins);
if ($this->config->get('system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
null,
$this->l10n->t('Created at'),
'created_at'
);
} else {
$created_at = '';
}
$tpl = Renderer::getMarkupTemplate("jot.tpl"); $tpl = Renderer::getMarkupTemplate("jot.tpl");
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
@ -352,6 +364,7 @@ class Conversation
$this->l10n->t('Scheduled at'), $this->l10n->t('Scheduled at'),
'scheduled_at' 'scheduled_at'
), ),
'$created_at' => $created_at,
'$wait' => $this->l10n->t('Please wait'), '$wait' => $this->l10n->t('Please wait'),
'$permset' => $this->l10n->t('Permission settings'), '$permset' => $this->l10n->t('Permission settings'),
'$shortpermset' => $this->l10n->t('Permissions'), '$shortpermset' => $this->l10n->t('Permissions'),

View file

@ -869,7 +869,7 @@ class Item
$item["contact-id"] = self::contactId($item); $item["contact-id"] = self::contactId($item);
if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) && if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
self::isTooOld($item)) { empty($item['origin']) &&self::isTooOld($item)) {
Logger::info('Item is too old', ['item' => $item]); Logger::info('Item is too old', ['item' => $item]);
return 0; return 0;
} }

View file

@ -28,6 +28,7 @@ use Friendica\Core\ACL;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -35,7 +36,6 @@ use Friendica\Model\User;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\NotImplementedException; use Friendica\Network\HTTPException\NotImplementedException;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
class Compose extends BaseModule class Compose extends BaseModule
@ -135,6 +135,18 @@ class Compose extends BaseModule
$contact = Contact::getById($a->getContactId()); $contact = Contact::getById($a->getContactId());
if ($this->config->get(local_user(), 'system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
null,
$this->l10n->t('Created at'),
'created_at'
);
} else {
$created_at = '';
}
$tpl = Renderer::getMarkupTemplate('item/compose.tpl'); $tpl = Renderer::getMarkupTemplate('item/compose.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$compose_title'=> $compose_title, '$compose_title'=> $compose_title,
@ -172,7 +184,7 @@ class Compose extends BaseModule
DI::l10n()->t('Scheduled at'), DI::l10n()->t('Scheduled at'),
'scheduled_at' 'scheduled_at'
), ),
'$created_at' => $created_at,
'$title' => $title, '$title' => $title,
'$category' => $category, '$category' => $category,
'$body' => $body, '$body' => $body,

View file

@ -1229,6 +1229,7 @@ class Transmitter
if (in_array($data['type'], ['Create', 'Update', 'Delete'])) { if (in_array($data['type'], ['Create', 'Update', 'Delete'])) {
$data['object'] = $object ?? self::createNote($item); $data['object'] = $object ?? self::createNote($item);
$data['published'] = DateTimeFormat::utcNow(DateTimeFormat::ATOM);
} elseif ($data['type'] == 'Add') { } elseif ($data['type'] == 'Add') {
$data = self::createAddTag($item, $data); $data = self::createAddTag($item, $data);
} elseif ($data['type'] == 'Announce') { } elseif ($data['type'] == 'Announce') {

View file

@ -505,6 +505,10 @@ return [
// Set to false if your non-sendmail agent is incompatible, or to restore old behavior of using the host address. // Set to false if your non-sendmail agent is incompatible, or to restore old behavior of using the host address.
'sendmail_params' => true, 'sendmail_params' => true,
// set_creation_date (Boolean)
// When enabled, the user can enter a creation date when composing a post.
'set_creation_date' => false,
// show_global_community_hint (Boolean) // show_global_community_hint (Boolean)
// When the global community page is enabled, use this option to display a hint above the stream, that this is a collection of all public top-level postings that arrive on your node. // When the global community page is enabled, use this option to display a hint above the stream, that this is a collection of all public top-level postings that arrive on your node.
'show_global_community_hint' => false, 'show_global_community_hint' => false,

File diff suppressed because it is too large Load diff

View file

@ -83,6 +83,7 @@
</div> </div>
{{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}} {{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}}
{{if $created_at}}{{$created_at nofilter}}{{/if}}
{{else}} {{else}}
<input type="hidden" name="group_allow" value="{{$group_allow}}"/> <input type="hidden" name="group_allow" value="{{$group_allow}}"/>
<input type="hidden" name="contact_allow" value="{{$contact_allow}}"/> <input type="hidden" name="contact_allow" value="{{$contact_allow}}"/>

View file

@ -80,6 +80,7 @@
<div id="profile-jot-acl-wrapper" style="width:auto;height:auto;overflow:auto;"> <div id="profile-jot-acl-wrapper" style="width:auto;height:auto;overflow:auto;">
{{$acl nofilter}} {{$acl nofilter}}
{{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}} {{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}}
{{if $created_at}}{{$created_at nofilter}}{{/if}}
</div> </div>
</div> </div>

View file

@ -134,6 +134,7 @@
<div id="profile-jot-acl-wrapper" class="minimize" aria-labelledby="jot-perms-lnk" role="tabpanel" aria-hidden="true"> <div id="profile-jot-acl-wrapper" class="minimize" aria-labelledby="jot-perms-lnk" role="tabpanel" aria-hidden="true">
{{$acl nofilter}} {{$acl nofilter}}
{{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}} {{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}}
{{if $created_at}}{{$created_at nofilter}}{{/if}}
</div> </div>
<div id="jot-preview-content" class="minimize" aria-labelledby="jot-preview-lnk" role="tabpanel" aria-hidden="true"></div> <div id="jot-preview-content" class="minimize" aria-labelledby="jot-preview-lnk" role="tabpanel" aria-hidden="true"></div>

View file

@ -48,6 +48,7 @@
<div id="profile-jot-acl-wrapper" style="width:auto;height:auto;overflow:auto;"> <div id="profile-jot-acl-wrapper" style="width:auto;height:auto;overflow:auto;">
{{$acl nofilter}} {{$acl nofilter}}
{{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}} {{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}}
{{if $created_at}}{{$created_at nofilter}}{{/if}}
</div> </div>
</div> </div>

View file

@ -72,6 +72,7 @@
{{$acl nofilter}} {{$acl nofilter}}
{{$jotnets nofilter}} {{$jotnets nofilter}}
{{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}} {{if $scheduled_at}}{{$scheduled_at nofilter}}{{/if}}
{{if $created_at}}{{$created_at nofilter}}{{/if}}
</div> </div>
</div> </div>