mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
New API for hidden threads.
This commit is contained in:
parent
ea94a479f1
commit
4553528507
2 changed files with 34 additions and 0 deletions
31
data.c
31
data.c
|
@ -1106,6 +1106,37 @@ int is_muted(snac *snac, char *actor)
|
|||
}
|
||||
|
||||
|
||||
d_char *_hidden_fn(snac *snac, const char *id)
|
||||
{
|
||||
xs *md5 = xs_md5_hex(id, strlen(id));
|
||||
return xs_fmt("%s/hidden/%s.json", snac->basedir, md5);
|
||||
}
|
||||
|
||||
|
||||
void hide(snac *snac, const char *id)
|
||||
/* hides a message tree */
|
||||
{
|
||||
xs *fn = _hidden_fn(snac, id);
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(fn, "w")) != NULL) {
|
||||
fprintf(f, "%s\n", id);
|
||||
fclose(f);
|
||||
|
||||
snac_debug(snac, 2, xs_fmt("hidden %s %s", id, fn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int is_hidden(snac *snac, const char *id)
|
||||
/* check is id is hidden */
|
||||
{
|
||||
xs *fn = _hidden_fn(snac, id);
|
||||
|
||||
return !!(mtime(fn) != 0.0);
|
||||
}
|
||||
|
||||
|
||||
int actor_add(snac *snac, const char *actor, d_char *msg)
|
||||
/* adds an actor */
|
||||
{
|
||||
|
|
3
snac.h
3
snac.h
|
@ -85,6 +85,9 @@ void mute(snac *snac, char *actor);
|
|||
void unmute(snac *snac, char *actor);
|
||||
int is_muted(snac *snac, char *actor);
|
||||
|
||||
void hide(snac *snac, const char *id);
|
||||
int is_hidden(snac *snac, const char *id);
|
||||
|
||||
int actor_add(snac *snac, const char *actor, d_char *msg);
|
||||
int actor_get(snac *snac, const char *actor, d_char **data);
|
||||
|
||||
|
|
Loading…
Reference in a new issue