mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Added muted functions.
This commit is contained in:
parent
591613a49e
commit
065773c703
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user