Add support for "muting" accounts
[blerg.git] / database / database.c
index c8b9b58..618c0d3 100644 (file)
@@ -283,9 +283,11 @@ int blerg_store(struct blerg *blerg, const char *data, int len) {
        flock(blerg->data_fd, LOCK_UN);
        flock(blerg->index_fd, LOCK_UN);
 
-       /* Now do those dirty microblogging deeds */
-       tag_scan(blerg->name, data, len, record);
-       subscription_notify(blerg->name, record);
+       if (!blerg_get_mute(blerg)) {
+               /* Now do those dirty microblogging deeds */
+               tag_scan(blerg->name, data, len, record);
+               subscription_notify(blerg->name, record);
+       }
 
        return record;
 }
@@ -368,3 +370,18 @@ uint64_t blerg_get_subscription_mark(struct blerg *blerg) {
        CHECK_VALID_BLERG(0)
        return blerg->meta->subscription_mark;
 }
+
+int blerg_set_mute(struct blerg *blerg, int v) {
+       CHECK_VALID_BLERG(0)
+       if (v) {
+               blerg->meta->status |= BLERGMETA_MUTED;
+       } else {
+               blerg->meta->status &= ~BLERGMETA_MUTED;
+       }
+       return 1;
+}
+
+int blerg_get_mute(struct blerg *blerg) {
+       CHECK_VALID_BLERG(0)
+       return (blerg->meta->status & BLERGMETA_MUTED) > 0;
+}