aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-04-18 21:18:49 -0700
committerMario Vavti <mario@mariovavti.com>2017-06-10 00:00:31 +0200
commit3389df77cc01cb7527623efebc9a640ad1454eb3 (patch)
tree6e50176c8856bfc12da7515fa18273a631ce71b3
parent97732f70063325ac875498a413e9ac1b6fca51f5 (diff)
downloadvolse-hubzilla-3389df77cc01cb7527623efebc9a640ad1454eb3.tar.gz
volse-hubzilla-3389df77cc01cb7527623efebc9a640ad1454eb3.tar.bz2
volse-hubzilla-3389df77cc01cb7527623efebc9a640ad1454eb3.zip
give the item_obscured flag a new lease on life by using it to designate third party client-side e2ee or binary content which can only be downloaded and not viewed directly on the web (as a side effect this also allows binary files to be submitted as activities/content). The content display is suppressed and replaced with a download button. This is unfinished but harmless to backport while work is in progress unless told otherwise. Future development will take care of the remaining loose ends.
-rw-r--r--include/conversation.php8
-rw-r--r--include/text.php18
-rw-r--r--view/tpl/item_binary.tpl3
3 files changed, 20 insertions, 9 deletions
diff --git a/include/conversation.php b/include/conversation.php
index c325a516f..3f9ee5cfa 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -353,14 +353,6 @@ function localize_item(&$item){
}
*/
- // if item body was obscured and we changed it, re-obscure it
- // FIXME - we need a better filter than just the string 'data'; try and
- // match the fact that it's json encoded
-
- if(intval($item['item_obscured'])
- && strlen($item['body']) && (! strpos($item['body'],'data'))) {
- $item['body'] = z_obscure($item['body']);
- }
}
diff --git a/include/text.php b/include/text.php
index 6f5c48679..b8914c44b 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1562,7 +1562,12 @@ function prepare_body(&$item,$attach = false) {
}
}
- $s .= prepare_text($item['body'],$item['mimetype'], false);
+ if($item['item_obscured']) {
+ $s .= prepare_binary($item);
+ }
+ else {
+ $s .= prepare_text($item['body'],$item['mimetype'], false);
+ }
$event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false);
@@ -1625,6 +1630,17 @@ function prepare_body(&$item,$attach = false) {
return $prep_arr;
}
+
+function prepare_binary($item) {
+ return replace_macros(get_markup_template('item_binary.tpl'), [
+ '$download' => t('Download binary/encrypted content'),
+ '$url' => z_root() . '/viewsrc/' . $item['id'] . '/download'
+ ]);
+}
+
+
+
+
/**
* @brief Given a text string, convert from bbcode to html and add smilie icons.
*
diff --git a/view/tpl/item_binary.tpl b/view/tpl/item_binary.tpl
new file mode 100644
index 000000000..b19f7e7dd
--- /dev/null
+++ b/view/tpl/item_binary.tpl
@@ -0,0 +1,3 @@
+<p>
+<center><a class="zrl" href="{{$url}}"><button class="btn btn-warning fakelink">{{$download}}</button></a></center>
+</p>