Set mentioned flag on mention
authorChip Black <bytex64@bytex64.net>
Mon, 30 Jun 2014 01:01:34 +0000 (20:01 -0500)
committerChip Black <bytex64@bytex64.net>
Tue, 1 Jul 2014 02:46:18 +0000 (21:46 -0500)
database/tags.c

index 3e3b14f..ba7c376 100644 (file)
@@ -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;
 }