3 * @file include/spool_post.php
4 * @brief Posts items that wer spooled because they couldn't be posted.
7 use \Friendica\Core\Config;
9 require_once("include/items.php");
11 function spool_post_run($argv, $argc) {
14 $path = get_spoolpath();
16 if (($path != '') AND is_writable($path)){
17 if ($dh = opendir($path)) {
18 while (($file = readdir($dh)) !== false) {
20 // It is not named like a spool file, so we don't care.
21 if (substr($file, 0, 5) != "item-") {
25 $fullfile = $path."/".$file;
27 // We don't care about directories either
28 if (filetype($fullfile) != "file") {
32 // We can't read or write the file? So we don't care about it.
33 if (!is_writable($fullfile) OR !is_readable($fullfile)) {
37 $arr = json_decode(file_get_contents($fullfile), true);
39 // If it isn't an array then it is no spool file
40 if (!is_array($arr)) {
44 // Skip if it doesn't seem to be an item array
45 if (!isset($arr['uid']) AND !isset($arr['uri']) AND !isset($arr['network'])) {
49 $result = item_store($arr);
51 logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);