mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Some new draft functions.
This commit is contained in:
parent
97c4af001b
commit
7286216f14
30
data.c
30
data.c
@ -1658,6 +1658,36 @@ xs_list *pinned_list(snac *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** drafts **/
|
||||||
|
|
||||||
|
int is_draft(snac *user, const char *id)
|
||||||
|
/* returns true if this note is a draft */
|
||||||
|
{
|
||||||
|
return object_user_cache_in(user, id, "draft");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void draft_del(snac *user, const char *id)
|
||||||
|
/* delete a message from the draft cache */
|
||||||
|
{
|
||||||
|
object_user_cache_del(user, id, "draft");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void draft_add(snac *user, const char *id, const xs_dict *msg)
|
||||||
|
/* store the message as a draft */
|
||||||
|
{
|
||||||
|
/* delete from the index, in case it was already there */
|
||||||
|
draft_del(user, id);
|
||||||
|
|
||||||
|
/* overwrite object */
|
||||||
|
object_add_ow(id, msg);
|
||||||
|
|
||||||
|
/* [re]add to the index */
|
||||||
|
object_user_cache_add(user, id, "draft");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** hiding **/
|
/** hiding **/
|
||||||
|
|
||||||
xs_str *_hidden_fn(snac *snac, const char *id)
|
xs_str *_hidden_fn(snac *snac, const char *id)
|
||||||
|
10
html.c
10
html.c
@ -3105,10 +3105,6 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|||||||
|
|
||||||
p_vars = xs_dict_get(req, "p_vars");
|
p_vars = xs_dict_get(req, "p_vars");
|
||||||
|
|
||||||
#if 0
|
|
||||||
xs_json_dump(p_vars, 4, stdout);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (p_path && strcmp(p_path, "admin/note") == 0) { /** **/
|
if (p_path && strcmp(p_path, "admin/note") == 0) { /** **/
|
||||||
/* post note */
|
/* post note */
|
||||||
const xs_str *content = xs_dict_get(p_vars, "content");
|
const xs_str *content = xs_dict_get(p_vars, "content");
|
||||||
@ -3121,6 +3117,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|||||||
const xs_str *edit_id = xs_dict_get(p_vars, "edit_id");
|
const xs_str *edit_id = xs_dict_get(p_vars, "edit_id");
|
||||||
const xs_str *alt_text = xs_dict_get(p_vars, "alt_text");
|
const xs_str *alt_text = xs_dict_get(p_vars, "alt_text");
|
||||||
int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only"));
|
int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only"));
|
||||||
|
int is_draft = !xs_is_null(xs_dict_get(p_vars, "is_draft"));
|
||||||
xs *attach_list = xs_list_new();
|
xs *attach_list = xs_list_new();
|
||||||
|
|
||||||
/* default alt text */
|
/* default alt text */
|
||||||
@ -3199,6 +3196,11 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|||||||
msg = xs_dict_set(msg, "summary", xs_is_null(summary) ? "..." : summary);
|
msg = xs_dict_set(msg, "summary", xs_is_null(summary) ? "..." : summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_draft) {
|
||||||
|
/* don't send; just store for later */
|
||||||
|
draft_add(&snac, xs_dict_get(msg, "id"), msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
if (xs_is_null(edit_id)) {
|
if (xs_is_null(edit_id)) {
|
||||||
/* new message */
|
/* new message */
|
||||||
c_msg = msg_create(&snac, msg);
|
c_msg = msg_create(&snac, msg);
|
||||||
|
4
snac.h
4
snac.h
@ -178,6 +178,10 @@ int is_pinned(snac *user, const char *id);
|
|||||||
int is_pinned_by_md5(snac *user, const char *md5);
|
int is_pinned_by_md5(snac *user, const char *md5);
|
||||||
xs_list *pinned_list(snac *user);
|
xs_list *pinned_list(snac *user);
|
||||||
|
|
||||||
|
int is_draft(snac *user, const char *id);
|
||||||
|
void draft_del(snac *user, const char *id);
|
||||||
|
void draft_add(snac *user, const char *id, const xs_dict *msg);
|
||||||
|
|
||||||
int limited(snac *user, const char *id, int cmd);
|
int limited(snac *user, const char *id, int cmd);
|
||||||
#define is_limited(user, id) limited((user), (id), 0)
|
#define is_limited(user, id) limited((user), (id), 0)
|
||||||
#define limit(user, id) limited((user), (id), 1)
|
#define limit(user, id) limited((user), (id), 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user