start_measure('shorten url ' . $url);
$res = self::_request('shorturl', ['url' => $url], $shortener, $code);
if ($code === 200) {
-
+ ShortLink::touchChangeFile();
}
if (isset($res->shorturl) && $res->shorturl) {
return $res->shorturl;
public static function updateURL($shorturl, $newurl, $shortener)
{
- $res = self::_request('update', ['shorturl' => $shorturl, 'url' => $newurl, 'title' => 'auto'], $shortener, $code);
- if ($code === 200) {
- ShortLink::touchChangeFile();
+ self::_request('update', ['shorturl' => $shorturl, 'url' => $newurl, 'title' => 'auto'], $shortener, $code);
+ $cacheKey = 'shorturl_' . $shortener . '_' . $newurl;
+ if ($code == 200) {
+ cache()->set($cacheKey, $newurl, 3600);
}
}
$this->addField('server', SelectFromArray::class, __('Serveur'), ['type' => 'hidden', 'options' => LinkShortener::getAvaiableShorteners()]);
$this->addField('url', URL::class, __('URL'), ['column' => true]);
- $this->addField('shortlink', URL::class, __('URL courte'), ['type' => 'hidden_visible', 'column' => true, 'column_view_namespace' => CubistBackpackServiceProvider::NAMESPACE . '::columns', 'column_type' => 'url', 'database_unique' => true]);
+ $this->addField('shortlink', URL::class, __('URL courte'), ['type' => 'hidden_visible', 'column' => true, 'column_view_namespace' => CubistBackpackServiceProvider::NAMESPACE . '::columns', 'column_type' => 'url', 'database_unique' => true, 'searchLogic' => 'text']);
$this->addField('http_code', Integer::class, __('Code HTTP'), ['type' => 'hidden_visible', 'column' => true, 'column_label' => '<i class="las la-chevron-circle-down" title="' . __('Résultat du test') . '"></i>', 'column_type' => 'http_code', 'column_view_namespace' => 'columns']);
$this->addField('code_date', \Cubist\Backpack\Magic\Fields\Datetime::class, __('Code observé le'), ['type' => 'hidden_visible', 'column' => true]);
$this->addField('target_code', Integer::class, __('Code final'), ['type' => 'hidden_visible', 'column' => true, 'column_type' => 'http_code', 'column_view_namespace' => 'columns', 'column_label' => '<i class="las la-chevron-circle-right" title="' . __('Résultat du test de la page redirigée') . '"></i>']);
if ($currentLink['type'] == Link::WEBVIDEO && $currentLink['video_service'] == 'youtube') {
$links[$uid]['to'] = WebVideo::_findVideoId($this->url, 'youtube');
} else {
- $links[$uid]['to'] = $this->uid;
+ $links[$uid]['to'] = $this->url;
}
}
LinksData::saveLinksInFile($id, backpack_user()->id, __('Lien court :shortlink édité', ['shortlink' => $this->shortlink]), $links, $rulers, [], [], false);
}
}
- AuditLinkRegister::dispatchSync();
- static::touchChangeFile();
+ AuditLinkRegister::dispatch();
}
return parent::onSaved();
}