commit:fa435b6b28d6e700b517f59940e5781451132b9e
author:Chip Black
committer:Chip Black
date:Sun Jun 29 20:01:34 2014 -0500
parents:d72ebf451ae43b53e6f14f9a614cc714b06431d4
Set mentioned flag on mention
diff --git a/database/tags.c b/database/tags.c
line changes: +12/-2
index 3e3b14f..ba7c376
--- a/database/tags.c
+++ b/database/tags.c
@@ -65,6 +65,7 @@ tag_scan_start:
 int tag_add(const char *author, const char *tag, uint64_t record) {
 	char filename[FILENAME_MAX];
 	struct blergref t;
+	const char *tagval = tag + 1;
 
 	memset(t.author, 0, 32);
 	strncpy(t.author, author, 32);
@@ -72,10 +73,10 @@ int tag_add(const char *author, const char *tag, uint64_t record) {
 
 	switch(tag[0]) {
 	case '#':
-		snprintf(filename, FILENAME_MAX, "%s/%s", blergconf.hash_tags_path, tag + 1);
+		snprintf(filename, FILENAME_MAX, "%s/%s", blergconf.hash_tags_path, tagval);
 		break;
 	case '@':
-		snprintf(filename, FILENAME_MAX, "%s/%s", blergconf.ref_tags_path, tag + 1);
+		snprintf(filename, FILENAME_MAX, "%s/%s", blergconf.ref_tags_path, tagval);
 		break;
 	default:
 		fprintf(stderr, "Invalid tag type: %s\n", tag);
@@ -96,6 +97,15 @@ int tag_add(const char *author, const char *tag, uint64_t record) {
 	flock(tag_fd, LOCK_UN);
 	close(tag_fd);
 
+	/* Set a flag for mentioned users */
+	if (tag[0] == '@' && blerg_exists(tagval)) {
+		struct blerg *b = blerg_open(tagval);
+		if (b != NULL) {
+			blerg_set_status(b, BLERGSTATUS_MENTIONED, 1);
+			blerg_close(b);
+		}
+	}
+
 	return 1;
 }