Skip to content

Commit

Permalink
JMAP PushSubscription: nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmurchison committed Oct 27, 2022
1 parent ce92e57 commit e833ca2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
27 changes: 14 additions & 13 deletions imap/jmap_push_subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <syslog.h>
#include <assert.h>
#include <errno.h>

#include "append.h"
#include "http_jmap.h"
Expand Down Expand Up @@ -155,6 +155,7 @@ HIDDEN int jmap_pushsub_get(jmap_req_t *req)
NULL, NULL, &get, &err);
if (json_object_get(req->args, "accountId")) {
jmap_parser_invalid(&parser, "accountId");

if (err) json_decref(err);
err = json_pack("{s:s s:O}", "type", "invalidArguments",
"arguments", parser.invalid);
Expand Down Expand Up @@ -236,7 +237,7 @@ static int store_pushsub(const char *id, time_t *expires, strarray_t *types,
char *data = json_dumps(jpushsub, JSON_INDENT(2));
size_t datalen = strlen(data);
time_t now = time(0);
FILE *f = NULL;
FILE *f;
char *mimehdr;
int r = 0;

Expand All @@ -246,7 +247,7 @@ static int store_pushsub(const char *id, time_t *expires, strarray_t *types,
return CYRUSDB_IOERROR;
}

/* Create RFC 5322 header for script */
/* Create RFC 5322 header for subscription */
char *userid = mboxname_to_userid(mailbox_name(mailbox));
if (strchr(userid, '@')) {
buf_printf(&buf, "<%s>", userid);
Expand Down Expand Up @@ -412,10 +413,10 @@ static const char *set_create(const char *creation_id, json_t *jpushsub,
json_sprintf("types[%lu]", i));
break;
}
else {
strarray_append(&types, type);
}

strarray_append(&types, type);
}

jtypes = json_incref(arg);
}
}
Expand Down Expand Up @@ -592,12 +593,11 @@ static void set_update(const char *id, json_t *jpushsub,
json_sprintf("types[%lu]", i));
break;
}
else {
r = mailbox_user_flag(mailbox, type, &flagnum, 1);
if (r) goto done;

record.user_flags[flagnum/32] |= 1<<(flagnum&31);
}
r = mailbox_user_flag(mailbox, type, &flagnum, 1);
if (r) goto done;

record.user_flags[flagnum/32] |= 1<<(flagnum&31);
}
}
}
Expand Down Expand Up @@ -702,7 +702,8 @@ HIDDEN int jmap_pushsub_set(struct jmap_req *req)
jmap_set_parse(req, &parser, pushsub_props, NULL, NULL, &set, &jerr);
if ((accountid = json_object_get(req->args, "accountId")) || set.if_in_state) {
if (accountid) jmap_parser_invalid(&parser, "accountId");
if (set.if_in_state) jmap_parser_invalid(&parser, "ifInState");
else jmap_parser_invalid(&parser, "ifInState");

if (jerr) json_decref(jerr);
jerr = json_pack("{s:s s:O}", "type", "invalidArguments",
"arguments", parser.invalid);
Expand Down
4 changes: 2 additions & 2 deletions imap/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -4027,7 +4027,7 @@ static int mailbox_update_pushsub(struct mailbox *mailbox,
struct buf msg_buf = BUF_INITIALIZER;
int isexpunged = (new->internal_flags & FLAG_INTERNAL_EXPUNGED ? 1 : 0);
int isverified = (new->system_flags & FLAG_FLAGGED ? 1 : 0);
int r = 0;
int r;

if (mbtype_isa(mailbox_mbtype(mailbox)) != MBTYPE_JMAPPUSHSUB) return 0;

Expand Down Expand Up @@ -4204,7 +4204,7 @@ static int mailbox_update_sieve(struct mailbox *mailbox,
struct buf msg_buf = BUF_INITIALIZER;
int isexpunged = (new->internal_flags & FLAG_INTERNAL_EXPUNGED ? 1 : 0);
int isactive = (new->system_flags & FLAG_FLAGGED ? 1 : 0);
int r = 0;
int r;

if (mbtype_isa(mailbox_mbtype(mailbox)) != MBTYPE_SIEVE) return 0;

Expand Down
5 changes: 1 addition & 4 deletions imap/pushsub_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,8 @@ EXPORTED int pushsubdb_delete(struct pushsub_db *pushsubdb, unsigned rowid)
struct sqldb_bindval bval[] = {
{ ":rowid", SQLITE_INTEGER, { .i = rowid } },
{ NULL, SQLITE_NULL, { .s = NULL } } };
int r;

r = sqldb_exec(pushsubdb->db, CMD_DELETE, bval, NULL, NULL);

return r;
return sqldb_exec(pushsubdb->db, CMD_DELETE, bval, NULL, NULL);
}

EXPORTED int pushsub_ensure_folder(const char *userid, struct mailbox **mailboxptr)
Expand Down

0 comments on commit e833ca2

Please sign in to comment.