|
@@ -3136,6 +3136,8 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|
|
p_vars = xs_dict_get(req, "p_vars");
|
|
|
|
|
|
if (p_path && strcmp(p_path, "admin/note") == 0) {
|
|
|
+ snac_debug(&snac, 1, xs_fmt("web action '%s' received", p_path));
|
|
|
+
|
|
|
|
|
|
const xs_str *content = xs_dict_get(p_vars, "content");
|
|
|
const xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
|
|
@@ -3226,27 +3228,22 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|
|
msg = xs_dict_set(msg, "summary", xs_is_null(summary) ? "..." : summary);
|
|
|
}
|
|
|
|
|
|
- if (store_as_draft) {
|
|
|
-
|
|
|
- draft_add(&snac, xs_is_null(edit_id) ? xs_dict_get(msg, "id") : edit_id, msg);
|
|
|
- }
|
|
|
- else
|
|
|
if (xs_is_null(edit_id)) {
|
|
|
|
|
|
- c_msg = msg_create(&snac, msg);
|
|
|
- timeline_add(&snac, xs_dict_get(msg, "id"), msg);
|
|
|
+ const char *id = xs_dict_get(msg, "id");
|
|
|
+
|
|
|
+ if (store_as_draft) {
|
|
|
+ draft_add(&snac, id, msg);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ c_msg = msg_create(&snac, msg);
|
|
|
+ timeline_add(&snac, id, msg);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
xs *p_msg = NULL;
|
|
|
|
|
|
- if (is_draft(&snac, edit_id)) {
|
|
|
-
|
|
|
- c_msg = msg_create(&snac, msg);
|
|
|
- timeline_add(&snac, edit_id, msg);
|
|
|
- draft_del(&snac, edit_id);
|
|
|
- }
|
|
|
- else
|
|
|
if (valid_status(object_get(edit_id, &p_msg))) {
|
|
|
|
|
|
char *fields[] = { "id", "context", "url", "published",
|
|
@@ -3258,15 +3255,35 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|
|
msg = xs_dict_set(msg, fields[n], v);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- xs *updated = xs_str_utctime(0, ISO_DATE_SPEC);
|
|
|
- msg = xs_dict_set(msg, "updated", updated);
|
|
|
+ if (store_as_draft) {
|
|
|
+ draft_add(&snac, edit_id, msg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ if (is_draft(&snac, edit_id)) {
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- object_add_ow(edit_id, msg);
|
|
|
+
|
|
|
+ xs *published = xs_str_utctime(0, ISO_DATE_SPEC);
|
|
|
+ msg = xs_dict_set(msg, "published", published);
|
|
|
|
|
|
-
|
|
|
- c_msg = msg_update(&snac, msg);
|
|
|
+
|
|
|
+ object_add_ow(edit_id, msg);
|
|
|
+
|
|
|
+ c_msg = msg_create(&snac, msg);
|
|
|
+ timeline_add(&snac, edit_id, msg);
|
|
|
+ draft_del(&snac, edit_id);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ xs *updated = xs_str_utctime(0, ISO_DATE_SPEC);
|
|
|
+ msg = xs_dict_set(msg, "updated", updated);
|
|
|
+
|
|
|
+
|
|
|
+ object_add_ow(edit_id, msg);
|
|
|
+
|
|
|
+
|
|
|
+ c_msg = msg_update(&snac, msg);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
snac_log(&snac, xs_fmt("cannot get object '%s' for editing", edit_id));
|