Compare commits
2 commits
develop
...
masto-auth
Author | SHA1 | Date | |
---|---|---|---|
|
e1e8e8e558 | ||
|
69f468f7a7 |
4 changed files with 55 additions and 23 deletions
|
@ -971,6 +971,23 @@ func getRemoteUserFromHandle(app *App, handle string) (*RemoteUser, error) {
|
||||||
return &u, nil
|
return &u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getRemoteUserFromURL retrieves a RemoteUser from their public profile URL.
|
||||||
|
func getRemoteUserFromURL(app *App, urlStr string) (*RemoteUser, error) {
|
||||||
|
u := RemoteUser{URL: urlStr}
|
||||||
|
var urlVal, handle sql.NullString
|
||||||
|
err := app.db.QueryRow("SELECT id, actor_id, inbox, shared_inbox, url, handle FROM remoteusers WHERE url = ?", urlStr).Scan(&u.ID, &u.ActorID, &u.Inbox, &u.SharedInbox, &urlVal, &handle)
|
||||||
|
switch {
|
||||||
|
case err == sql.ErrNoRows:
|
||||||
|
return nil, ErrRemoteUserNotFound
|
||||||
|
case err != nil:
|
||||||
|
log.Error("Couldn't get remote user from URL %s: %v", urlStr, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
u.URL = urlVal.String
|
||||||
|
u.Handle = handle.String
|
||||||
|
return &u, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getActor(app *App, actorIRI string) (*activitystreams.Person, *RemoteUser, error) {
|
func getActor(app *App, actorIRI string) (*activitystreams.Person, *RemoteUser, error) {
|
||||||
log.Info("Fetching actor %s locally", actorIRI)
|
log.Info("Fetching actor %s locally", actorIRI)
|
||||||
actor := &activitystreams.Person{}
|
actor := &activitystreams.Person{}
|
||||||
|
|
|
@ -630,18 +630,19 @@ func fetchCollectionPosts(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
type CollectionPage struct {
|
type CollectionPage struct {
|
||||||
page.StaticPage
|
page.StaticPage
|
||||||
*DisplayCollection
|
*DisplayCollection
|
||||||
IsCustomDomain bool
|
IsCustomDomain bool
|
||||||
IsWelcome bool
|
IsWelcome bool
|
||||||
IsOwner bool
|
IsOwner bool
|
||||||
IsCollLoggedIn bool
|
IsCollLoggedIn bool
|
||||||
Honeypot string
|
Honeypot string
|
||||||
IsSubscriber bool
|
IsSubscriber bool
|
||||||
CanPin bool
|
CanPin bool
|
||||||
Username string
|
Username string
|
||||||
Monetization string
|
Monetization string
|
||||||
Flash template.HTML
|
FediverseAuthor string
|
||||||
Collections *[]Collection
|
Flash template.HTML
|
||||||
PinnedPosts *[]PublicPost
|
Collections *[]Collection
|
||||||
|
PinnedPosts *[]PublicPost
|
||||||
|
|
||||||
IsAdmin bool
|
IsAdmin bool
|
||||||
CanInvite bool
|
CanInvite bool
|
||||||
|
|
33
posts.go
33
posts.go
|
@ -144,16 +144,17 @@ type (
|
||||||
CollectionPostPage struct {
|
CollectionPostPage struct {
|
||||||
*PublicPost
|
*PublicPost
|
||||||
page.StaticPage
|
page.StaticPage
|
||||||
IsOwner bool
|
IsOwner bool
|
||||||
IsPinned bool
|
IsPinned bool
|
||||||
IsCustomDomain bool
|
IsCustomDomain bool
|
||||||
Monetization string
|
Monetization string
|
||||||
Verification string
|
Verification string
|
||||||
PinnedPosts *[]PublicPost
|
FediverseAuthor string
|
||||||
IsFound bool
|
PinnedPosts *[]PublicPost
|
||||||
IsAdmin bool
|
IsFound bool
|
||||||
CanInvite bool
|
IsAdmin bool
|
||||||
Silenced bool
|
CanInvite bool
|
||||||
|
Silenced bool
|
||||||
|
|
||||||
// Helper field for Chorus mode
|
// Helper field for Chorus mode
|
||||||
CollAlias string
|
CollAlias string
|
||||||
|
@ -1614,6 +1615,18 @@ Are you sure it was ever here?`,
|
||||||
tp.IsPinned = len(*tp.PinnedPosts) > 0 && PostsContains(tp.PinnedPosts, p)
|
tp.IsPinned = len(*tp.PinnedPosts) > 0 && PostsContains(tp.PinnedPosts, p)
|
||||||
tp.Monetization = coll.Monetization
|
tp.Monetization = coll.Monetization
|
||||||
tp.Verification = coll.Verification
|
tp.Verification = coll.Verification
|
||||||
|
if tp.Verification != "" {
|
||||||
|
// Fetch info for fediverse:creator tag
|
||||||
|
ru, err := getRemoteUserFromURL(app, coll.Verification)
|
||||||
|
if err != nil {
|
||||||
|
if debugging {
|
||||||
|
log.Info("showing rel=me tag, but no local handle for %s", coll.Verification)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Though we don't store handles with leading @, strip it here just in case
|
||||||
|
tp.FediverseAuthor = "@" + strings.TrimLeft(ru.Handle, "@")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !postFound {
|
if !postFound {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<meta name="monetization" content="{{.DisplayMonetization}}" />
|
<meta name="monetization" content="{{.DisplayMonetization}}" />
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{if .Verification -}}
|
{{if .Verification -}}
|
||||||
|
{{if .FediverseAuthor}}<meta name="fediverse:creator" content="{{.FediverseAuthor}}">{{end}}
|
||||||
<link rel="me" href="{{.Verification}}" />
|
<link rel="me" href="{{.Verification}}" />
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue