Skip to content

Commit

Permalink
jmap_contact: fall back reading shared importance annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
rsto committed May 5, 2021
1 parent de8f240 commit c7b5b6d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions imap/jmap_contact.c
Expand Up @@ -96,6 +96,7 @@ static int _contact_set_create(jmap_req_t *req, unsigned kind,
static int required_set_rights(json_t *props);
static int _json_to_card(struct jmap_req *req,
struct carddav_data *cdata,
const char *mboxname,
struct vparse_card *card,
json_t *arg, strarray_t *flags,
struct entryattlist **annotsp,
Expand Down Expand Up @@ -1156,7 +1157,8 @@ static void _contacts_set(struct jmap_req *req, unsigned kind)
flags = mailbox_extract_flags(mailbox, &record, req->userid);
annots = mailbox_extract_annots(mailbox, &record);

r = _json_to_card(req, cdata, card, arg, flags, &annots, &blobs, &errors);
r = _json_to_card(req, cdata, mailbox->name, card, arg, flags,
&annots, &blobs, &errors);
if (r == HTTP_NO_CONTENT) {
r = 0;
if (!newmailbox) {
Expand Down Expand Up @@ -1825,7 +1827,7 @@ static json_t *jmap_contact_from_vcard(const char *userid,
// NOTE: using buf_free here because annotatemore_msg_lookup uses
// buf_init_ro on the buffer, which blats the base pointer.
buf_free(&buf);
annotatemore_msg_lookup(mailbox->name, record->uid, annot, userid, &buf);
annotatemore_msg_lookupmask(mailbox->name, record->uid, annot, userid, &buf);
double val = 0;
if (buf.len) val = strtod(buf_cstring(&buf), NULL);

Expand Down Expand Up @@ -3767,6 +3769,7 @@ static void _make_fn(struct vparse_card *card)

static int _json_to_card(struct jmap_req *req,
struct carddav_data *cdata,
const char *mboxname,
struct vparse_card *card,
json_t *arg, strarray_t *flags,
struct entryattlist **annotsp,
Expand Down Expand Up @@ -3845,7 +3848,8 @@ static int _json_to_card(struct jmap_req *req,
has_noncontent = 1;
double dval = json_number_value(jval);
const char *ns = DAV_ANNOT_NS "<" XML_NS_CYRUS ">importance";
const char *attrib = "value.priv";
const char *attrib = mboxname_userownsmailbox(req->userid, mboxname) ?
"value.shared" : "value.priv";
struct buf buf = BUF_INITIALIZER;
if (dval) {
buf_printf(&buf, "%.17g", dval);
Expand Down Expand Up @@ -4159,7 +4163,7 @@ static int _contact_set_create(jmap_req_t *req, unsigned kind,
}
else {
flags = strarray_new();
r = _json_to_card(req, cdata, card, jcard, flags, &annots, &blobs, errors);
r = _json_to_card(req, cdata, mboxname, card, jcard, flags, &annots, &blobs, errors);

logfmt = "jmap: create contact %s/%s (%s)";
}
Expand Down

0 comments on commit c7b5b6d

Please sign in to comment.