aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Daemon/Cron.php5
-rw-r--r--Zotlabs/Module/Sharedwithme.php94
-rw-r--r--Zotlabs/Module/Sse_bs.php5
-rw-r--r--include/attach.php19
4 files changed, 74 insertions, 49 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 9cdfa9a0f..46f4e4071 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -38,11 +38,6 @@ class Cron {
Master::Summon(array('Poller'));
- // maintenance for mod sharedwithme - check for updated items and remove them
-
- require_once('include/sharedwithme.php');
- apply_updates();
-
/**
* Chatpresence: if somebody hasn't pinged recently, they've most likely left the page
* and shouldn't count as online anymore. We allow an expection for bots.
diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php
index f9d242dd3..4211a3af8 100644
--- a/Zotlabs/Module/Sharedwithme.php
+++ b/Zotlabs/Module/Sharedwithme.php
@@ -23,81 +23,80 @@ class Sharedwithme extends Controller {
$channel = \App::get_channel();
$is_owner = (local_channel() && (local_channel() == $channel['channel_id']));
-
- //check for updated items and remove them
- require_once('include/sharedwithme.php');
- apply_updates();
+
+ $item_normal = item_normal();
//drop single file - localuser
if((argc() > 2) && (argv(2) === 'drop')) {
-
+
$id = intval(argv(1));
-
- q("DELETE FROM item WHERE id = %d AND uid = %d",
- intval($id),
- intval(local_channel())
- );
-
+
+ drop_item($id);
+
goaway(z_root() . '/sharedwithme');
+
}
//drop all files - localuser
if((argc() > 1) && (argv(1) === 'dropall')) {
-
- q("DELETE FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d",
+
+ $r = q("SELECT id FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal",
dbesc(ACTIVITY_POST),
- dbesc(ACTIVITY_OBJ_FILE),
- intval(local_channel())
+ intval(local_channel()),
+ dbesc($channel['channel_hash'])
);
-
+
+ $ids = ids_to_array($r);
+
+ if($ids)
+ drop_items($ids);
+
goaway(z_root() . '/sharedwithme');
+
}
-
+
//list files
- $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'",
+ $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal",
dbesc(ACTIVITY_POST),
- dbesc(ACTIVITY_OBJ_FILE),
intval(local_channel()),
dbesc($channel['channel_hash'])
);
-
- $items =array();
- $ids = '';
-
+
+ $items = [];
+ $ids = [];
+
if($r) {
foreach($r as $rr) {
$object = json_decode($rr['obj'],true);
-
- $item = array();
+ $meta = self::get_meta($object);
+
+ $item = [];
$item['id'] = $rr['id'];
- $item['objfiletype'] = $object['filetype'];
- $item['objfiletypeclass'] = getIconFromType($object['filetype']);
- $item['objurl'] = rawurldecode(get_rel_link($object['link'],'alternate')) . '?f=&zid=' . $channel['xchan_addr'];
- $item['objfilename'] = $object['filename'];
- $item['objfilesize'] = userReadableSize($object['filesize']);
- $item['objedited'] = $object['edited'];
+ $item['objfiletype'] = $meta['type'];
+ $item['objfiletypeclass'] = getIconFromType($meta['type']);
+ $item['objurl'] = $meta['path'] . '?f=&zid=' . $channel['xchan_addr'];
+ $item['objfilename'] = $object['name'];
+ $item['objfilesize'] = userReadableSize($meta['size']);
+ $item['objedited'] = $meta['edited'];
$item['unseen'] = $rr['item_unseen'];
$items[] = $item;
- if($item['unseen'] > 0) {
- $ids .= " '" . $rr['id'] . "',";
+ if($item['unseen']) {
+ $ids[] = $rr['id'];
}
}
}
-
+
+ $ids = implode(',', $ids);
+
if($ids) {
-
- //remove trailing ,
- $ids = rtrim($ids, ",");
-
q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d",
intval(local_channel())
);
-
}
$o = '';
@@ -117,5 +116,22 @@ class Sharedwithme extends Controller {
}
+ function get_meta($object) {
+
+ $ret = [];
+
+ if(! is_array($object['attachment']))
+ return;
+
+ foreach($object['attachment'] as $a) {
+ if($a['name'] === 'zot.attach.meta') {
+ $ret = $a['value'];
+ break;
+ }
+ }
+
+ return $ret;
+
+ }
}
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 290c616a9..cb4c54961 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -453,11 +453,12 @@ class Sse_bs extends Controller {
$r = q("SELECT * FROM item
WHERE verb = '%s'
- AND obj_type in ('Document', 'Video', 'Audio', 'Image')
+ AND obj_type IN ('Document', 'Video', 'Audio', 'Image')
AND uid = %d
AND author_xchan != '%s'
AND item_unseen = 1
- $item_normal",
+ $item_normal
+ ORDER BY created DESC",
dbesc(ACTIVITY_POST),
intval(self::$uid),
dbesc(self::$ob_hash)
diff --git a/include/attach.php b/include/attach.php
index 7149be735..fbf131fb3 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -12,6 +12,7 @@
*/
use Zotlabs\Lib\Libsync;
+use Zotlabs\Lib\Activity;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Daemon\Master;
@@ -1940,6 +1941,7 @@ function attach_store_item($channel, $observer, $file) {
$uuid = new_uuid();
$mid = z_root() . '/item/' . $uuid;
+ $path = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path'];
$arr = []; // Initialize the array of parameters for the post
$arr['aid'] = $channel['channel_account_id'];
@@ -1951,8 +1953,6 @@ function attach_store_item($channel, $observer, $file) {
$arr['resource_id'] = $resource_id;
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['author_xchan'] = $observer['xchan_hash'];
- $arr['plink'] = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path'];
- $arr['llink'] = $arr['plink'];
$arr['title'] = $file['filename'];
$arr['allow_cid'] = $file['allow_cid'];
$arr['allow_gid'] = $file['allow_gid'];
@@ -1965,9 +1965,22 @@ function attach_store_item($channel, $observer, $file) {
$arr['verb'] = ACTIVITY_CREATE;
$arr['obj_type'] = $type;
$arr['title'] = $file['filename'];
- $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $arr['plink'] . ']' . t('file') . '[/zrl]');
+ $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . t('file') . '[/zrl]');
$arr['body'] = $body_str;
+ $meta = [
+ 'name' => $file['filename'],
+ 'type' => $file['filetype'],
+ 'size' => $file['filesize'],
+ 'revision' => $file['revision'],
+ 'size' => $file['filesize'],
+ 'created' => $file['created'],
+ 'edited' => $file['edited'],
+ 'path' => $path
+ ];
+
+ set_iconfig($arr, 'attach', 'meta' , $meta, true);
+
post_activity_item($arr);
}