mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
New function user_open_by_md5().
This commit is contained in:
parent
2ec58144ba
commit
0240c871f3
3 changed files with 22 additions and 5 deletions
20
data.c
20
data.c
|
@ -232,6 +232,26 @@ d_char *user_list(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int user_open_by_md5(snac *snac, const char *md5)
|
||||||
|
/* iterates all users searching by md5 */
|
||||||
|
{
|
||||||
|
xs *ulist = user_list();
|
||||||
|
xs_list *p = ulist;
|
||||||
|
xs_str *v;
|
||||||
|
|
||||||
|
while (xs_list_iter(&p, &v)) {
|
||||||
|
user_open(snac, v);
|
||||||
|
|
||||||
|
if (strcmp(snac->md5, md5) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
user_free(snac);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double mtime_nl(const char *fn, int *n_link)
|
double mtime_nl(const char *fn, int *n_link)
|
||||||
/* returns the mtime and number of links of a file or directory, or 0.0 */
|
/* returns the mtime and number of links of a file or directory, or 0.0 */
|
||||||
{
|
{
|
||||||
|
|
|
@ -722,12 +722,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *out = NULL;
|
xs *out = NULL;
|
||||||
xs *actor = NULL;
|
xs *actor = NULL;
|
||||||
|
|
||||||
/* if uid it's the md5 of this actor, transform into a real uid */
|
|
||||||
if (strcmp(uid, snac1.md5) == 0)
|
|
||||||
uid = xs_dict_get(snac1.config, "uid");
|
|
||||||
|
|
||||||
/* is it a local user? */
|
/* is it a local user? */
|
||||||
if (user_open(&snac2, uid)) {
|
if (user_open(&snac2, uid) || user_open_by_md5(&snac2, uid)) {
|
||||||
if (opt == NULL) {
|
if (opt == NULL) {
|
||||||
/* account information */
|
/* account information */
|
||||||
actor = msg_actor(&snac2);
|
actor = msg_actor(&snac2);
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -42,6 +42,7 @@ typedef struct _snac {
|
||||||
int user_open(snac *snac, const char *uid);
|
int user_open(snac *snac, const char *uid);
|
||||||
void user_free(snac *snac);
|
void user_free(snac *snac);
|
||||||
d_char *user_list(void);
|
d_char *user_list(void);
|
||||||
|
int user_open_by_md5(snac *snac, const char *md5);
|
||||||
|
|
||||||
void snac_debug(snac *snac, int level, d_char *str);
|
void snac_debug(snac *snac, int level, d_char *str);
|
||||||
#define snac_log(snac, str) snac_debug(snac, 0, str)
|
#define snac_log(snac, str) snac_debug(snac, 0, str)
|
||||||
|
|
Loading…
Reference in a new issue