diff options
-rw-r--r-- | OutboxPost.go | 5 | ||||
-rw-r--r-- | main.go | 47 | ||||
-rw-r--r-- | static/js/posts.js | 1 |
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 } } @@ -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) + "/") { |