Remove /unsubscribe from htaccess config
[blerg.git] / database / tags.c
index 07aa0e9..ba7c376 100644 (file)
@@ -59,11 +59,13 @@ tag_scan_start:
                tag_add(author, taglist[i], record);
                free(taglist[i]);
        }
+       return 1;
 }
 
 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);
@@ -71,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);
@@ -95,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;
 }