mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-25 16:53:37 +00:00
Added muted functions.
This commit is contained in:
parent
591613a49e
commit
065773c703
2 changed files with 45 additions and 0 deletions
42
data.c
42
data.c
|
@ -477,3 +477,45 @@ int following_check(snac *snac, char *actor)
|
|||
|
||||
return !!(mtime(fn) != 0.0);
|
||||
}
|
||||
|
||||
|
||||
d_char *_muted_fn(snac *snac, char *actor)
|
||||
{
|
||||
xs *md5 = xs_md5_hex(actor, strlen(actor));
|
||||
return xs_fmt("%s/muted/%s.json", snac->basedir, md5);
|
||||
}
|
||||
|
||||
|
||||
void mute(snac *snac, char *actor)
|
||||
/* mutes a moron */
|
||||
{
|
||||
xs *fn = _muted_fn(snac, actor);
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(fn, "w")) != NULL) {
|
||||
fprintf(f, "%s\n", actor);
|
||||
fclose(f);
|
||||
|
||||
snac_debug(snac, 2, xs_fmt("muted %s %s", actor, fn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unmute(snac *snac, char *actor)
|
||||
/* actor is no longer a moron */
|
||||
{
|
||||
xs *fn = _muted_fn(snac, actor);
|
||||
|
||||
unlink(fn);
|
||||
|
||||
snac_debug(snac, 2, xs_fmt("unmuted %s %s", actor, fn));
|
||||
}
|
||||
|
||||
|
||||
int is_muted(snac *snac, char *actor)
|
||||
/* check if someone is muted */
|
||||
{
|
||||
xs *fn = _muted_fn(snac, actor);
|
||||
|
||||
return !!(mtime(fn) != 0.0);
|
||||
}
|
||||
|
|
3
snac.h
3
snac.h
|
@ -54,3 +54,6 @@ int following_add(snac *snac, char *actor, char *msg);
|
|||
int following_del(snac *snac, char *actor);
|
||||
int following_check(snac *snac, char *actor);
|
||||
|
||||
void mute(snac *snac, char *actor);
|
||||
void unmute(snac *snac, char *actor);
|
||||
int is_muted(snac *snac, char *actor);
|
||||
|
|
Loading…
Reference in a new issue