|
|
@@ -1347,6 +1347,56 @@ int is_muted(snac *snac, const char *actor)
|
|
|
}
|
|
|
|
|
|
|
|
|
+/** pinning **/
|
|
|
+
|
|
|
+xs_str *_pinned_fn(snac *user, const char *id)
|
|
|
+{
|
|
|
+ xs *md5 = xs_md5_hex(id, strlen(id));
|
|
|
+ return xs_fmt("%s/pinned/%s", user->basedir, md5);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int is_pinned(snac *user, const char *id)
|
|
|
+/* returns true if this note is pinned */
|
|
|
+{
|
|
|
+ xs *fn = _pinned_fn(user, id);
|
|
|
+ return !!(mtime(fn) != 0.0);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int pin(snac *user, const char *id)
|
|
|
+/* pins a message */
|
|
|
+{
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ if (xs_startswith(id, user->actor)) {
|
|
|
+ /* create the subfolder, if it does not exist */
|
|
|
+ xs *fn = xs_fmt("%s/pinned/", user->basedir);
|
|
|
+ mkdirx(fn);
|
|
|
+
|
|
|
+ object_user_cache_add(user, id, "pinned");
|
|
|
+
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void unpin(snac *user, const char *id)
|
|
|
+/* unpin a message */
|
|
|
+{
|
|
|
+ object_user_cache_del(user, id, "pinned");
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+xs_list *pinned_list(snac *user)
|
|
|
+/* return the lists of pinned posts */
|
|
|
+{
|
|
|
+ return object_user_cache_list(user, "pinned", XS_ALL);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
xs_str *_hidden_fn(snac *snac, const char *id)
|
|
|
{
|
|
|
xs *md5 = xs_md5_hex(id, strlen(id));
|