aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <=>2021-01-26 13:05:12 -0800
committerFChannel <=>2021-01-26 13:05:12 -0800
commita589c58ed85eece34a8e3938219bd0264238b2a8 (patch)
tree3001c531561ff69d2a48b05e1d03e5fb522db477
parent2868cbabf7c394c637fc8568c6981da6eb5370ca (diff)
fixed noko
-rw-r--r--OutboxPost.go5
-rw-r--r--main.go47
-rw-r--r--static/js/posts.js1
3 files changed, 46 insertions, 7 deletions
diff --git a/OutboxPost.go b/OutboxPost.go
index fc96866..60fa769 100644
--- a/OutboxPost.go
+++ b/OutboxPost.go
@@ -53,13 +53,12 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
MakeActivityRequest(activity)
var id string
- re := regexp.MustCompile("\\w+$")
op := len(nObj.InReplyTo) - 1
if op >= 0 {
if nObj.InReplyTo[op].Id == "" {
- id = re.FindString(nObj.Id)
+ id = nObj.Id
} else {
- id = re.FindString(nObj.InReplyTo[op].Id)
+ id = nObj.InReplyTo[op].Id
}
}
diff --git a/main.go b/main.go
index 605314e..5eab686 100644
--- a/main.go
+++ b/main.go
@@ -331,7 +331,7 @@ func main() {
we.Close()
req, err := http.NewRequest("POST", r.FormValue("sendTo"), &b)
-
+
CheckError(err, "error with post form req")
req.Header.Set("Content-Type", we.FormDataContentType())
@@ -348,11 +348,12 @@ func main() {
body, _ := ioutil.ReadAll(resp.Body)
var obj ObjectBase
+
obj = ParseOptions(r, obj)
for _, e := range obj.Option {
if(e == "noko" || e == "nokosage"){
- http.Redirect(w, r, TP + "" + Domain + "/" + r.FormValue("boardName") + "/" + string(body) , http.StatusMovedPermanently)
- break
+ http.Redirect(w, r, Domain + "/" + r.FormValue("boardName") + "/" + shortURL(r.FormValue("sendTo"), string(body)) , http.StatusMovedPermanently)
+ return
}
}
@@ -1898,3 +1899,43 @@ func GetActorCollectionReq(r *http.Request, collection string) Collection {
return nCollection
}
+
+func shortURL(actorName string, url string) string {
+
+ re := regexp.MustCompile(`outbox`)
+
+ actor := re.ReplaceAllString(actorName, "")
+
+ re = regexp.MustCompile(`\w+$`)
+ temp := re.ReplaceAllString(url, "")
+
+ if(temp == actor){
+ short := StripTransferProtocol(url)
+
+ re := regexp.MustCompile(`\w+$`)
+
+ id := re.FindString(short);
+
+ return id;
+ }else{
+ short := StripTransferProtocol(url)
+
+ re := regexp.MustCompile(`\w+$`)
+
+ id := re.FindString(short);
+
+ re = regexp.MustCompile(`.+/.+/`)
+
+ actorurl := re.FindString(short)
+
+ re = regexp.MustCompile(`/.+/`)
+
+ actorname := re.FindString(actorurl)
+
+ actorname = strings.Replace(actorname, "/", "", -1)
+
+ id = "f" + actorname + "-" + id
+
+ return id;
+ }
+}
diff --git a/static/js/posts.js b/static/js/posts.js
index 69c451a..e9feefe 100644
--- a/static/js/posts.js
+++ b/static/js/posts.js
@@ -27,7 +27,6 @@ function shortURL(actorName, url)
var check = url.replace(actorName + "/", "")
re = /.+\//g;
temp = re.exec(url)
-
if(stripTransferProtocol(temp[0]) == stripTransferProtocol(actorName) + "/")
{