Add subscription support to perl lib
[blerg.git] / database / subscription.c
index d3686ad..e55e8f1 100644 (file)
@@ -25,6 +25,8 @@ int subscription_add(const char *from, const char *to) {
        sb = stringbucket_open(filename);
        stringbucket_add(sb, from);
        stringbucket_close(sb);
+
+       return 1;
 }
 
 int subscription_remove(const char *from, const char *to) {
@@ -40,6 +42,8 @@ int subscription_remove(const char *from, const char *to) {
        sb = stringbucket_open(filename);
        stringbucket_delete(sb, from);
        stringbucket_close(sb);
+
+       return 1;
 }
 
 void subscription_notify_add_item(char *to, void *stuff) {
@@ -62,6 +66,8 @@ int subscription_notify(const char *author, uint64_t record) {
        struct stringbucket * sb = stringbucket_open(filename);
        stringbucket_iterate(sb, subscription_notify_add_item, &r);
        stringbucket_close(sb);
+
+       return 1;
 }
 
 struct blergref * subscription_list(const char *author, uint64_t offset, int *count, int direction) {
@@ -142,3 +148,18 @@ int is_subscribed(const char *from, const char *to) {
 
        return ret;
 }
+
+int subscription_count_items(const char *user) {
+       char filename[512];
+       struct stat st;
+
+       if (!valid_name(user))
+               return -1;
+
+       snprintf(filename, 512, "%s/%s/subscription_feed", DATA_PATH, user);
+
+       if (access(filename, R_OK) != 0)
+               return 0;
+       stat(filename, &st);
+       return st.st_size / sizeof(struct blergref);
+}