aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <>2021-04-26 12:24:14 -0700
committerFChannel <>2021-04-26 12:24:14 -0700
commit4bd1944ae847a44ec8cd1996dc26145f6af08ead (patch)
treebdb4b836187ed46d5f0dffc76b26e68562450ff3
parenta07341569819f7f55d9e8b86db02c7e5ae9e8ba4 (diff)
noko fix
-rw-r--r--OutboxPost.go4
-rw-r--r--main.go59
2 files changed, 47 insertions, 16 deletions
diff --git a/OutboxPost.go b/OutboxPost.go
index 61175be..cb0f988 100644
--- a/OutboxPost.go
+++ b/OutboxPost.go
@@ -55,9 +55,9 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
op := len(nObj.InReplyTo) - 1
if op >= 0 {
if nObj.InReplyTo[op].Id == "" {
- id = nObj.Id
+ id = nObj.Id
} else {
- id = nObj.InReplyTo[op].Id
+ id = nObj.InReplyTo[0].Id + "|" + nObj.Id
}
}
diff --git a/main.go b/main.go
index 5fe0346..2e2bc0f 100644
--- a/main.go
+++ b/main.go
@@ -1930,31 +1930,65 @@ func GetActorCollectionReq(r *http.Request, collection string) Collection {
func shortURL(actorName string, url string) string {
- re := regexp.MustCompile(`outbox`)
+ re := regexp.MustCompile(`.+\/`)
+
+ actor := re.FindString(actorName)
+
+ urlParts := strings.Split(url, "|")
+
+ op := urlParts[0]
+
+ var reply string
+
+ if len(urlParts) > 1 {
+ reply = urlParts[1]
+ }
- actor := re.ReplaceAllString(actorName, "")
-
re = regexp.MustCompile(`\w+$`)
- temp := re.ReplaceAllString(url, "")
+ temp := re.ReplaceAllString(op, "")
if(temp == actor){
- short := StripTransferProtocol(url)
+ id := localShort(op)
- re := regexp.MustCompile(`\w+$`)
+ re := regexp.MustCompile(`.+\/`)
+ replyCheck := re.FindString(reply)
- id := re.FindString(short);
+ if(reply != "" && replyCheck == actor){
+ id = id + "#" + localShort(reply)
+ } else if reply != "" {
+ id = id + "#" + remoteShort(reply)
+ }
return id;
}else{
- short := StripTransferProtocol(url)
+ id := remoteShort(op)
+
+ re := regexp.MustCompile(`.+\/`)
+ replyCheck := re.FindString(reply)
+
+ if(reply != "" && replyCheck == actor){
+ id = id + "#" + localShort(reply)
+ } else if reply != "" {
+ id = id + "#" + remoteShort(reply)
+ }
+
+ return id;
+ }
+}
+func localShort(url string) string {
re := regexp.MustCompile(`\w+$`)
+ return re.FindString(StripTransferProtocol(url));
+}
- id := re.FindString(short);
+func remoteShort(url string) string {
+ re := regexp.MustCompile(`\w+$`)
+
+ id := re.FindString(StripTransferProtocol(url));
re = regexp.MustCompile(`.+/.+/`)
- actorurl := re.FindString(short)
+ actorurl := re.FindString(StripTransferProtocol(url))
re = regexp.MustCompile(`/.+/`)
@@ -1962,8 +1996,5 @@ func shortURL(actorName string, url string) string {
actorname = strings.Replace(actorname, "/", "", -1)
- id = "f" + actorname + "-" + id
-
- return id;
- }
+ return "f" + actorname + "-" + id
}