GitHost.io will be shut down on June 1, 2019. At that point this instance will be unreachable and all data will be irrevocably deleted. More details at https://about.gitlab.com/gitlab-hosted/#githost-is-shutting-down-on-june-1st-2019

Commit cba85a12 authored by hannes's avatar hannes

remove the cache_remote_attachments qvitter-feature, since the...

remove the cache_remote_attachments qvitter-feature, since the StoreRemoteMedia plugin is now available
parent f2efe7bb
......@@ -97,11 +97,6 @@ class QvitterPlugin extends Plugin {
// LINKIFY DOMAINS WITHOUT PROTOCOL AS DEFAULT
$settings['linkify_bare_domains'] = true;
// CACHE REMOTE ATTACHMENT LOCALLY
// This will make image attachments from remote instances appear in the
// timeline just like local image attachments, but will require more disk space
$settings['cache_remote_attachments'] = false;
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
· ·
......@@ -866,80 +861,6 @@ class QvitterPlugin extends Plugin {
}
/**
* Maybe cache remote attachments
*
* @return boolean hook flag
*/
public function onEndHandleFeedEntryWithProfile($activity,$ostatus_profile, $notice) {
if(self::settings('cache_remote_attachments') && count($activity->enclosures)>0) {
foreach($activity->enclosures as $enclosure) {
// only proceed if this enclosure exists in a title-attribute in the content-field,
// that's how we know it's probably an image attachment
$enclosure_in_title_attr_pos = strpos($activity->content,'title="'.$enclosure.'"');
if($enclosure_in_title_attr_pos) {
$link_text_start = strpos($activity->content,'>',$enclosure_in_title_attr_pos)+1;
$link_text_end = strpos($activity->content,'</a>',$enclosure_in_title_attr_pos);
$link_text = substr($activity->content,$link_text_start,$link_text_end-$link_text_start);
$extension = pathinfo(parse_url($enclosure, PHP_URL_PATH),PATHINFO_EXTENSION);
if(count($link_text)>0 && ($extension == 'png' || $extension == 'jpg' || $extension == 'gif' || $extension == 'jpeg')) {
// First we download the file to memory and test whether it's actually an image file
$client = new HTTPClient();
$response = $client->get($enclosure);
if (!$response->isOk()) {
common_debug(sprintf(_m('Could not GET URL %s.'), $enclosure), $response->getStatus());
}
$imgData = $response->getBody();
$info = @getimagesizefromstring($imgData);
if ($info === false || !$info[0] || !$info[1]) {
common_debug(sprintf('The remote file was not a valid image file, URL: %s', $enclosure));
}
$filehash = hash('sha256', $imgData);
$file = new File();
$file->filehash = strtolower($filehash);
// file already exist
if ($file->find(true)) {
$filename = $file->filename;
$mimetype = $file->mimetype;
// file doesn't exist
} else {
$mimetype = $info['mime'];
$filename = strtolower($filehash) . '.' . File::guessMimeExtension($mimetype);
$filepath = File::path($filename);
if (!file_exists($filepath) && file_put_contents($filepath, $imgData) === false) {
common_debug(sprintf('Could not write downloaded file to disk, URL: %s', $enclosure));
} else {
$profile = Profile::getKV('uri',$activity->actor->id);
$mediafile = new MediaFile($profile, $filename, $mimetype, $filehash);
$mediafile->attachToNotice($notice);
$file_redir = new File_redirection;
$file_redir->urlhash = File::hashurl($link_text);
$file_redir->url = $link_text;
$file_redir->file_id = $mediafile->fileRecord->id;
$result = $file_redir->insert();
}
}
}
}
}
}
return true;
}
......
......@@ -28,7 +28,9 @@ Setup
3. Add `addPlugin('Qvitter');` to your /config.php file.
4. There are settings in QvitterPlugin.php, but for easy updates, put them in config.php instead. Example:
4. It's highly recommended to use the StoreRemoteMedia plugin. It will cache attachments from remote instances locally and make them appear in the streams. Add `addPlugin('StoreRemoteMedia');` to your /config.php file. (Only available in newer GNU social)
5. There are settings in QvitterPlugin.php, but for easy updates, put them in config.php instead. Example:
````
// Qvitter-settings
......@@ -43,7 +45,6 @@ $config['site']['qvitter']['sitebackground'] = 'img/vagnsmossen.jpg';
$config['site']['qvitter']['favicon'] = 'img/favicon.ico?v=4';
$config['site']['qvitter']['sprite'] = Plugin::staticPath('Qvitter', '').'img/sprite.png?v=40';
$config['site']['qvitter']['enablewelcometext'] = true;
$config['site']['qvitter']['cache_remote_attachments'] = false;
// $config['site']['qvitter']['customwelcometext']['sv'] = '<h1>Välkommen till Quitter.se – en federerad<sup>1</sup> mikrobloggsallmänning!</h1><p>Etc etc...</p>';
// $config['site']['qvitter']['customwelcometext']['en'] = '<h1>Welcome to Quitter.se – a federated microblog common!</h1><p>Etc etc...</p>';
$config['site']['qvitter']['blocked_ips'] = array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment