commit:767693caf2b41c2e857688d10d2c71bc77c0bbad
author:Chip Black
committer:Chip Black
date:Sun Jun 2 19:25:35 2013 -0500
parents:142c00ad296af327d5d1718d60f23c0807033f15
Add support for "muting" accounts

Muted accounts do not update reference or subscription indexes, making
them effectively invisible, but unaware of the fact.
diff --git a/database/database.c b/database/database.c
line changes: +20/-3
index c8b9b58..618c0d3
--- a/database/database.c
+++ b/database/database.c
@@ -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;
+}

diff --git a/database/database.h b/database/database.h
line changes: +5/-0
index 412d6c7..aa2403a
--- a/database/database.h
+++ b/database/database.h
@@ -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