Michael Demetriou 4 лет назад
Родитель
Сommit
b9d2689828
6 измененных файлов: 21 добавлений и 14 удалений
  1. +0
    -5
      activitypub.go
  2. +1
    -4
      collections.go
  3. +3
    -1
      routes.go
  4. +0
    -1
      schema.sql
  5. +0
    -1
      sqlite.sql
  6. +17
    -2
      webfinger.go

+ 0
- 5
activitypub.go Просмотреть файл

@@ -637,16 +637,11 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error {
// much logic to catch this at the expense of the odd extra request.
// I don't believe we'd ever have too many mentions in a single post that this
// could become a burden.

fmt.Println(tag.HRef)
fmt.Println("aaa")
remoteUser, err := getRemoteUser(app, tag.HRef)
err = makeActivityPost(app.cfg.App.Host, actor, remoteUser.Inbox, activity)
if err != nil {
log.Error("Couldn't post! %v", err)
}
// log.Info("Activity", activity)

}
}



+ 1
- 4
collections.go Просмотреть файл

@@ -830,10 +830,7 @@ func handleViewMention(app *App, w http.ResponseWriter, r *http.Request) error {
return nil
}

http.Redirect(w, r, remoteUser, http.StatusSeeOther)
w.Write([]byte("go to " + remoteUser))

return nil
return impart.HTTPError{Status: http.StatusFound, Message: remoteUser}
}

func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) error {


+ 3
- 1
routes.go Просмотреть файл

@@ -70,6 +70,9 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
write.HandleFunc(nodeinfo.NodeInfoPath, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfoDiscover)))
write.HandleFunc(niCfg.InfoURL, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfo)))

// handle mentions
write.HandleFunc("/mention:{handle}", handler.Web(handleViewMention, UserLevelReader))

// Set up dyamic page handlers
// Handle auth
auth := write.PathPrefix("/api/auth/").Subrouter()
@@ -184,7 +187,6 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {

func RouteCollections(handler *Handler, r *mux.Router) {
r.HandleFunc("/page/{page:[0-9]+}", handler.Web(handleViewCollection, UserLevelReader))
r.HandleFunc("/mention:{handle}", handler.Web(handleViewMention, UserLevelReader))
r.HandleFunc("/tag:{tag}", handler.Web(handleViewCollectionTag, UserLevelReader))
r.HandleFunc("/tag:{tag}/feed/", handler.Web(ViewFeed, UserLevelReader))
r.HandleFunc("/tags/{tag}", handler.Web(handleViewCollectionTag, UserLevelReader))


+ 0
- 1
schema.sql Просмотреть файл

@@ -181,7 +181,6 @@ CREATE TABLE IF NOT EXISTS `remoteusers` (
`actor_id` varchar(255) NOT NULL,
`inbox` varchar(255) NOT NULL,
`shared_inbox` varchar(255) NOT NULL,
`handle` varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `collection_id` (`actor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


+ 0
- 1
sqlite.sql Просмотреть файл

@@ -172,7 +172,6 @@ CREATE TABLE IF NOT EXISTS `remoteusers` (
actor_id TEXT NOT NULL,
inbox TEXT NOT NULL,
shared_inbox TEXT NOT NULL,
handle TEXT DEFAULT '' NOT NULL,
CONSTRAINT collection_id UNIQUE (actor_id)
);



+ 17
- 2
webfinger.go Просмотреть файл

@@ -106,7 +106,22 @@ func RemoteLookup(handle string) string {
var result map[string]interface{}
json.Unmarshal(body, &result)

aliases := result["aliases"].([]interface{})
var href string
for _, link := range result["links"].([]interface{}) {
if link.(map[string]interface{})["rel"] == "self" {
href = link.(map[string]interface{})["href"].(string)
}
}

// if we didn't find it with the above then
// try using aliases
if href == "" {
aliases := result["aliases"].([]interface{})
// take the last alias because mastodon has the
// https://instance.tld/@user first which
// doesn't work as an href
href = aliases[len(aliases)-1].(string)
}

return aliases[len(aliases)-1].(string)
return href
}

Загрузка…
Отмена
Сохранить