more work on mail flags
This commit is contained in:
parent
cb76fb8b9b
commit
1a0655f34e
@ -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'])
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
);
|
||||
|
@ -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'])
|
||||
|
@ -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'])
|
||||
|
@ -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'),
|
||||
);
|
||||
|
||||
|
@ -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'])
|
||||
);
|
||||
|
||||
|
15
mod/ping.php
15
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)
|
||||
|
Reference in New Issue
Block a user