aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/hook/collect_public_recipients.bb42
-rw-r--r--doc/hooklist.bb3
-rwxr-xr-xinclude/items.php19
-rw-r--r--include/queue_fn.php4
-rw-r--r--include/zot.php2
5 files changed, 65 insertions, 5 deletions
diff --git a/doc/hook/collect_public_recipients.bb b/doc/hook/collect_public_recipients.bb
new file mode 100644
index 000000000..de3f4049e
--- /dev/null
+++ b/doc/hook/collect_public_recipients.bb
@@ -0,0 +1,42 @@
+[h2]collect_public_recipients[/h2]
+
+Replace the default list of public recipients (i.e., all contacts).
+
+Allow plugins to create a list of recipients for public messages instead of the default
+of all channel connections.
+
+Called with the following array:
+ [
+ 'recipients' => [],
+ 'item' => $item,
+ 'private_envelope' => $private_envelope,
+ 'include_groups' => $include_groups
+ ];
+
+[code]
+ if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') {
+
+ $hookinfo = [
+ 'recipients' => [],
+ 'item' => $item,
+ 'private_envelope' => $private_envelope,
+ 'include_groups' => $include_groups
+ ];
+
+ call_hooks('collect_public_recipients',$hookinfo);
+
+ if ($hookinfo['recipients']) {
+ $r = $hookinfo['recipients'];
+ } else {
+ $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ",
+ intval($item['uid'])
+ );
+ }
+
+ if($r) {
+
+ . . .
+
+[/code]
+
+see: include/item.php
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index 298da5659..6d56d5e71 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -136,6 +136,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/check_siteallowed]check_siteallowed[/zrl]
Used to over-ride or bypass the site black/white block lists
+[zrl=[baseurl]/help/hook/collect_public_recipients]collect_public_recipients[/zrl]
+ Used to establish a list of recipients to send a public message to.
+
[zrl=[baseurl]/help/hook/comment_buttons]comment_buttons[/zrl]
Called when rendering the edit buttons for comments
diff --git a/include/items.php b/include/items.php
index 02d31fcb5..e5f2be003 100755
--- a/include/items.php
+++ b/include/items.php
@@ -95,9 +95,24 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
//$sys = get_sys_channel();
if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') {
- $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ",
+
+ $hookinfo = [
+ 'recipients' => [],
+ 'item' => $item,
+ 'private_envelope' => $private_envelope,
+ 'include_groups' => $include_groups
+ ];
+
+ call_hooks('collect_public_recipients',$hookinfo);
+
+ if ($hookinfo['recipients']) {
+ $r = $hookinfo['recipients'];
+ } else {
+ $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ",
intval($item['uid'])
- );
+ );
+ }
+
if($r) {
// filter out restrictive public_policy settings from remote networks
diff --git a/include/queue_fn.php b/include/queue_fn.php
index f7e2922c6..85f98aaf9 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -13,7 +13,7 @@ function update_queue_item($id, $add_priority = 0) {
return;
- $y = q("select min(outq_created) as earliest from outq where outq_posturl = '%s'",
+ $y = q("select outq_created as earliest from outq where outq_posturl = '%s' order by earliest limit 1",
dbesc($x[0]['outq_posturl'])
);
@@ -311,4 +311,4 @@ function queue_deliver($outq, $immediate = false) {
return;
}
-} \ No newline at end of file
+}
diff --git a/include/zot.php b/include/zot.php
index 6d9b6aeec..df54f2b27 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -4959,7 +4959,7 @@ function zot_reply_pickup($data) {
// It's possible that we have more than 100 messages waiting to be sent.
// See if there are any more messages in the queue.
- $x = q("select *,min(outq_created) as earliest from outq where outq_posturl = '%s'",
+ $x = q("select * from outq where outq_posturl = '%s' order by outq_created limit 1",
dbesc($data['callback'])
);