commit 0240c87
default
·
2023-04-16 05:43:41 +0000 UTC
parent 2ec5814
New function user_open_by_md5().
3 files changed,
+22,
-5
M
data.c
+20,
-0
1@@ -232,6 +232,26 @@ d_char *user_list(void)
2 }
3
4
5+int user_open_by_md5(snac *snac, const char *md5)
6+/* iterates all users searching by md5 */
7+{
8+ xs *ulist = user_list();
9+ xs_list *p = ulist;
10+ xs_str *v;
11+
12+ while (xs_list_iter(&p, &v)) {
13+ user_open(snac, v);
14+
15+ if (strcmp(snac->md5, md5) == 0)
16+ return 1;
17+
18+ user_free(snac);
19+ }
20+
21+ return 0;
22+}
23+
24+
25 double mtime_nl(const char *fn, int *n_link)
26 /* returns the mtime and number of links of a file or directory, or 0.0 */
27 {
+1,
-5
1@@ -722,12 +722,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 xs *out = NULL;
3 xs *actor = NULL;
4
5- /* if uid it's the md5 of this actor, transform into a real uid */
6- if (strcmp(uid, snac1.md5) == 0)
7- uid = xs_dict_get(snac1.config, "uid");
8-
9 /* is it a local user? */
10- if (user_open(&snac2, uid)) {
11+ if (user_open(&snac2, uid) || user_open_by_md5(&snac2, uid)) {
12 if (opt == NULL) {
13 /* account information */
14 actor = msg_actor(&snac2);
M
snac.h
+1,
-0
1@@ -42,6 +42,7 @@ typedef struct _snac {
2 int user_open(snac *snac, const char *uid);
3 void user_free(snac *snac);
4 d_char *user_list(void);
5+int user_open_by_md5(snac *snac, const char *md5);
6
7 void snac_debug(snac *snac, int level, d_char *str);
8 #define snac_log(snac, str) snac_debug(snac, 0, str)