Add support for "muting" accounts
authorChip Black <bytex64@bytex64.net>
Mon, 3 Jun 2013 00:25:35 +0000 (19:25 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 3 Jun 2013 00:25:35 +0000 (19:25 -0500)
Muted accounts do not update reference or subscription indexes, making
them effectively invisible, but unaware of the fact.

database/database.c
database/database.h

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;
+}
index 412d6c7..aa2403a 100644 (file)
@@ -20,8 +20,11 @@ struct record {
 struct meta {
        uint64_t sequence;
        uint64_t subscription_mark;
+       uint32_t status;
 };
 
+#define BLERGMETA_MUTED 0x00000001
+
 struct blerg {
        int meta_fd;
        int index_fd;
@@ -44,5 +47,7 @@ uint64_t blerg_get_record_count(struct blerg *);
 time_t blerg_get_timestamp(struct blerg *blerg, int record);
 int blerg_set_subscription_mark(struct blerg *blerg);
 uint64_t blerg_get_subscription_mark(struct blerg *blerg);
+int blerg_set_mute(struct blerg *blerg, int v);
+int blerg_get_mute(struct blerg *blerg);
 
 #endif //_DATABASE_H