소스 검색

Fixed bug when following by @user@host.

default 3 년 전
부모
커밋
dbe60be4f3
2개의 변경된 파일17개의 추가작업 그리고 6개의 파일을 삭제
  1. 11 2
      activitypub.c
  2. 6 4
      html.c

+ 11 - 2
activitypub.c

@@ -484,13 +484,22 @@ d_char *msg_delete(snac *snac, char *id)
 }
 }
 
 
 
 
-d_char *msg_follow(snac *snac, char *actor)
+d_char *msg_follow(snac *snac, char *url_or_uid)
 /* creates a 'Follow' message */
 /* creates a 'Follow' message */
 {
 {
-    d_char *actor_o = NULL;
+    xs *actor_o = NULL;
+    xs *actor   = NULL;
     d_char *msg = NULL;
     d_char *msg = NULL;
     int status;
     int status;
 
 
+    if (xs_startswith(url_or_uid, "https:/"))
+        actor = xs_dup(url_or_uid);
+    else
+    if (!valid_status(webfinger_request(url_or_uid, &actor, NULL))) {
+        snac_log(snac, xs_fmt("cannot resolve user %s to follow", url_or_uid));
+        return NULL;
+    }
+
     /* request the actor */
     /* request the actor */
     status = actor_request(snac, actor, &actor_o);
     status = actor_request(snac, actor, &actor_o);
 
 

+ 6 - 4
html.c

@@ -1197,12 +1197,14 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
         if (strcmp(action, L("Follow")) == 0) {
         if (strcmp(action, L("Follow")) == 0) {
             xs *msg = msg_follow(&snac, actor);
             xs *msg = msg_follow(&snac, actor);
 
 
-            /* reload the actor from the message, in may be different */
-            actor = xs_dict_get(msg, "object");
+            if (msg != NULL) {
+                /* reload the actor from the message, in may be different */
+                actor = xs_dict_get(msg, "object");
 
 
-            following_add(&snac, actor, msg);
+                following_add(&snac, actor, msg);
 
 
-            enqueue_output(&snac, msg, actor, 0);
+                enqueue_output(&snac, msg, actor, 0);
+            }
         }
         }
         else
         else
         if (strcmp(action, L("Unfollow")) == 0) {
         if (strcmp(action, L("Unfollow")) == 0) {