aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-06-23 21:01:59 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-06-23 21:01:59 -0700
commit1a0655f34ea9979c7a08d21344d3e0eb9eb3246d (patch)
tree5dde4224a3c762bcc1935b2e67464939e57a60d2
parentcb76fb8b9b659c4ec06e359f375a35a534927b99 (diff)
downloadvolse-hubzilla-1a0655f34ea9979c7a08d21344d3e0eb9eb3246d.tar.gz
volse-hubzilla-1a0655f34ea9979c7a08d21344d3e0eb9eb3246d.tar.bz2
volse-hubzilla-1a0655f34ea9979c7a08d21344d3e0eb9eb3246d.zip
more work on mail flags
-rwxr-xr-xinclude/diaspora.php10
-rwxr-xr-xinclude/items.php8
-rw-r--r--include/message.php16
-rw-r--r--include/text.php5
-rw-r--r--include/zot.php2
-rw-r--r--mod/mail.php5
-rw-r--r--mod/manage.php3
-rw-r--r--mod/ping.php15
8 files changed, 26 insertions, 38 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 997cbb187..ef02b5fc0 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -1723,14 +1723,14 @@ function diaspora_conversation($importer,$xml,$msg) {
if($body)
$body = str_rot47(base64url_encode($body));
- q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s')",
+ q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_obscured`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s')",
intval($importer['channel_id']),
intval($conversation['id']),
dbesc($person['xchan_hash']),
dbesc($importer['channel_hash']),
dbesc($subject),
dbesc($body),
- intval(MAIL_OBSCURED),
+ intval(1),
dbesc($msg_guid),
dbesc($parent_uri),
dbesc($msg_created_at)
@@ -1855,14 +1855,14 @@ function diaspora_message($importer,$xml,$msg) {
if($body)
$body = str_rot47(base64url_encode($body));
- q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', '%d','%s','%s','%s')",
+ q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_obscured`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', '%d','%s','%s','%s')",
intval($importer['channel_id']),
intval($conversation['id']),
dbesc($person['xchan_hash']),
dbesc($importer['xchan_hash']),
dbesc($subject),
dbesc($body),
- intval(MAIL_OBSCURED),
+ intval(1),
dbesc($msg_guid),
dbesc($parent_uri),
dbesc($msg_created_at)
@@ -2897,7 +2897,7 @@ function diaspora_send_mail($item,$owner,$contact) {
'participant_handles' => xmlify($cnv['recips'])
);
- if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
+ if(array_key_exists('mail_obscured',$item) && intval($item['mail_obscured'])) {
if($item['title'])
$item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
diff --git a/include/items.php b/include/items.php
index ee8ce5575..cf7e28daa 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1473,7 +1473,7 @@ function encode_mail($item) {
$x['type'] = 'mail';
$x['encoding'] = 'zot';
- if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
+ if(array_key_exists('mail_obscured',$item) && intval($item['mail_obscured'])) {
if($item['title'])
$item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
@@ -1495,7 +1495,7 @@ function encode_mail($item) {
$x['flags'] = array();
- if($item['mail_flags'] & MAIL_RECALLED) {
+ if(intval($item['mail_recalled'])) {
$x['flags'][] = 'recalled';
$x['title'] = '';
$x['body'] = '';
@@ -1523,12 +1523,12 @@ function get_mail_elements($x) {
if($x['flags'] && is_array($x['flags'])) {
if(in_array('recalled',$x['flags'])) {
- $arr['mail_flags'] |= MAIL_RECALLED;
+ $arr['mail_recalled'] = 1;
}
}
$key = get_config('system','pubkey');
- $arr['mail_flags'] |= MAIL_OBSCURED;
+ $arr['mail_obscured'] = 1;
if($arr['body']) {
$arr['body'] = str_rot47(base64url_encode($arr['body']));
$arr['body'] = htmlspecialchars($arr['body'],ENT_COMPAT,'UTF-8',false);
diff --git a/include/message.php b/include/message.php
index 8f1430e64..46f113cf4 100644
--- a/include/message.php
+++ b/include/message.php
@@ -283,8 +283,8 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
foreach($r as $k => $rr) {
$r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c);
$r[$k]['to'] = find_xchan_in_array($rr['to_xchan'],$c);
- $r[$k]['seen'] = (($rr['mail_flags'] & MAIL_SEEN) ? 1 : 0);
- if($r[$k]['mail_flags'] & MAIL_OBSCURED) {
+ $r[$k]['seen'] = intval($rr['mail_seen']);
+ if(intval($r[$k]['mail_obscured'])) {
if($r[$k]['title'])
$r[$k]['title'] = base64url_decode(str_rot47($r[$k]['title']));
if($r[$k]['body'])
@@ -322,7 +322,7 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee
foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
$messages[$k]['to'] = find_xchan_in_array($message['to_xchan'],$c);
- if($messages[$k]['mail_flags'] & MAIL_OBSCURED) {
+ if(intval($messages[$k]['mail_obscured'])) {
if($messages[$k]['title'])
$messages[$k]['title'] = base64url_decode(str_rot47($messages[$k]['title']));
if($messages[$k]['body'])
@@ -331,9 +331,7 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee
}
if($updateseen) {
- $r = q("UPDATE `mail` SET mail_flags = (mail_flags | %d) where not (mail_flags & %d)>0 and id = %d AND channel_id = %d",
- intval(MAIL_SEEN),
- intval(MAIL_SEEN),
+ $r = q("UPDATE `mail` SET mail_seen = 1 where mail_seen = 0 and id = %d AND channel_id = %d",
dbesc($messageitem_id),
intval($channel_id)
);
@@ -409,7 +407,7 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
$messages[$k]['to'] = find_xchan_in_array($message['to_xchan'],$c);
- if($messages[$k]['mail_flags'] & MAIL_OBSCURED) {
+ if(intval($messages[$k]['mail_obscured'])) {
if($messages[$k]['title'])
$messages[$k]['title'] = base64url_decode(str_rot47($messages[$k]['title']));
if($messages[$k]['body'])
@@ -419,9 +417,7 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
if($updateseen) {
- $r = q("UPDATE `mail` SET mail_flags = (mail_flags | %d) where not (mail_flags & %d)>0 and parent_mid = '%s' AND channel_id = %d",
- intval(MAIL_SEEN),
- intval(MAIL_SEEN),
+ $r = q("UPDATE `mail` SET mail_seen = 1 where mail_seen = 0 and parent_mid = '%s' AND channel_id = %d",
dbesc($r[0]['parent_mid']),
intval($channel_id)
);
diff --git a/include/text.php b/include/text.php
index 377c1c46f..33562a69f 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1251,10 +1251,9 @@ function unobscure(&$item) {
if($item['body'])
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
if(get_config('system','item_cache')) {
- q("update item set title = '%s', body = '%s', item_flags = %d where id = %d",
+ q("update item set title = '%s', body = '%s', item_obscured = 0 where id = %d",
dbesc($item['title']),
dbesc($item['body']),
- intval($item['item_flags'] - ITEM_OBSCURED),
intval($item['id'])
);
}
@@ -1262,7 +1261,7 @@ function unobscure(&$item) {
}
function unobscure_mail(&$item) {
- if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
+ if(array_key_exists('mail_obscured',$item) && intval($item['mail_obscured'])) {
if($item['title'])
$item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
diff --git a/include/zot.php b/include/zot.php
index 2187f3103..568049237 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1926,7 +1926,7 @@ function process_mail_delivery($sender, $arr, $deliveries) {
intval($channel['channel_id'])
);
if($r) {
- if($arr['mail_flags'] & MAIL_RECALLED) {
+ if(intval($arr['mail_recalled'])) {
$x = q("delete from mail where id = %d and channel_id = %d",
intval($r[0]['id']),
intval($channel['channel_id'])
diff --git a/mod/mail.php b/mod/mail.php
index 1b0ea17c4..152db3231 100644
--- a/mod/mail.php
+++ b/mod/mail.php
@@ -145,8 +145,7 @@ function mail_content(&$a) {
if(! intval(argv(2)))
return;
$cmd = argv(1);
- $r = q("update mail set mail_flags = mail_flags | %d where id = %d and channel_id = %d",
- intval(MAIL_RECALLED),
+ $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d",
intval(argv(2)),
intval(local_channel())
);
@@ -312,7 +311,7 @@ function mail_content(&$a) {
'delete' => t('Delete message'),
'recall' => t('Recall message'),
'can_recall' => (($channel['channel_hash'] == $message['from_xchan']) ? true : false),
- 'is_recalled' => (($message['mail_flags'] & MAIL_RECALLED) ? t('Message has been recalled.') : ''),
+ 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
);
diff --git a/mod/manage.php b/mod/manage.php
index c86db55e8..a7327697d 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -78,9 +78,8 @@ function manage_content(&$a) {
$channels[$x]['intros'] = intval($intr[0]['total']);
- $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND not (mail_flags & %d)>0 and from_xchan != '%s' ",
+ $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval($channels[$x]['channel_id']),
- intval(MAIL_SEEN),
dbesc($channels[$x]['channel_hash'])
);
diff --git a/mod/ping.php b/mod/ping.php
index b093c1cab..719183388 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -163,10 +163,8 @@ function ping_init(&$a) {
);
break;
case 'messages':
- $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d) > 0",
- intval(MAIL_SEEN),
- intval(local_channel()),
- intval(MAIL_SEEN)
+ $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ",
+ intval(local_channel())
);
break;
case 'all_events':
@@ -244,11 +242,9 @@ function ping_init(&$a) {
if(argc() > 1 && argv(1) === 'messages') {
$channel = $a->get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
- where channel_id = %d and not ( mail_flags & %d ) > 0 and not (mail_flags & %d ) > 0
+ where channel_id = %d and mail_seen = 0 and mail_deleted = 0
and from_xchan != '%s' order by created desc limit 50",
intval(local_channel()),
- intval(MAIL_SEEN),
- intval(MAIL_DELETED),
dbesc($channel['channel_hash'])
);
@@ -260,7 +256,7 @@ function ping_init(&$a) {
'url' => $zz['xchan_url'],
'photo' => $zz['xchan_photo_s'],
'when' => relative_date($zz['created']),
- 'hclass' => (($zz['mail_flags'] & MAIL_SEEN) ? 'notify-seen' : 'notify-unseen'),
+ 'hclass' => (intval($zz['mail_seen']) ? 'notify-seen' : 'notify-unseen'),
'message' => t('sent you a private message'),
);
}
@@ -420,9 +416,8 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d) > 0 and from_xchan != '%s' ",
+ WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval(local_channel()),
- intval(MAIL_SEEN),
dbesc($channel['channel_hash'])
);
if($mails)