kopia lustrzana https://codeberg.org/nmkj/audon
fix an issue that remote accounts cannot be added as cohosts
rodzic
7028f5834c
commit
abfb2f62f4
|
@ -10,7 +10,7 @@ export const validators = {
|
|||
export function webfinger(user) {
|
||||
if (!user) return "";
|
||||
const url = new URL(user.url);
|
||||
const finger = user.acct.split("@");
|
||||
const finger = user.username.split("@");
|
||||
return `${finger[0]}@${url.host}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,8 +176,7 @@ export default {
|
|||
title: this.title,
|
||||
description: this.description,
|
||||
cohosts: map(this.cohosts, (u) => ({
|
||||
remote_id: u.id,
|
||||
remote_url: u.url,
|
||||
webfinger: webfinger(u),
|
||||
})),
|
||||
restriction: this.relationship,
|
||||
advertise:
|
||||
|
@ -333,7 +332,7 @@ export default {
|
|||
<v-list lines="two">
|
||||
<v-list-item
|
||||
:key="0"
|
||||
:value="searchResult.acct"
|
||||
:value="webfinger(searchResult)"
|
||||
:title="searchResult.displayName"
|
||||
@click="onResultClick"
|
||||
>
|
||||
|
|
|
@ -562,7 +562,7 @@ export default {
|
|||
const resp = await axios.get(`/app/user/${identity}`);
|
||||
const account = this.roomInfo.accounts[identity];
|
||||
const info = {
|
||||
acct: account.acct,
|
||||
username: account.username,
|
||||
displayName: account.displayName,
|
||||
avatar: account.avatar,
|
||||
url: account.url,
|
||||
|
|
9
auth.go
9
auth.go
|
@ -138,7 +138,10 @@ func oauthHandler(c echo.Context) (err error) {
|
|||
}
|
||||
|
||||
coll := mainDB.Collection(COLLECTION_USER)
|
||||
if result, dbErr := findUserByRemote(c.Request().Context(), string(acc.ID), acc.URL); dbErr == mongo.ErrNoDocuments {
|
||||
acctUrl, _ := url.Parse(acc.URL)
|
||||
finger := strings.Split(acc.Username, "@")
|
||||
webfinger := fmt.Sprintf("%s@%s", finger[0], acctUrl.Host)
|
||||
if result, dbErr := findUserByWebfinger(c.Request().Context(), webfinger); dbErr == mongo.ErrNoDocuments {
|
||||
entropy := ulid.Monotonic(rand.Reader, 0)
|
||||
id, err := ulid.New(ulid.Timestamp(time.Now().UTC()), entropy)
|
||||
if err != nil {
|
||||
|
@ -146,13 +149,11 @@ func oauthHandler(c echo.Context) (err error) {
|
|||
return echo.NewHTTPError(http.StatusInternalServerError)
|
||||
}
|
||||
data.AudonID = id.String()
|
||||
acctUrl, _ := url.Parse(acc.URL)
|
||||
finger := strings.Split(acc.Username, "@")
|
||||
newUser := AudonUser{
|
||||
AudonID: data.AudonID,
|
||||
RemoteID: string(acc.ID),
|
||||
RemoteURL: acc.URL,
|
||||
Webfinger: fmt.Sprintf("%s@%s", finger[0], acctUrl.Host),
|
||||
Webfinger: webfinger,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
if _, insertErr := coll.InsertOne(c.Request().Context(), newUser); insertErr != nil {
|
||||
|
|
2
room.go
2
room.go
|
@ -103,7 +103,7 @@ func createRoomHandler(c echo.Context) error {
|
|||
|
||||
// if cohosts are already registered, retrieve their data from DB
|
||||
for i, cohost := range room.CoHosts {
|
||||
cohostUser, err := findUserByRemote(c.Request().Context(), cohost.RemoteID, cohost.RemoteURL)
|
||||
cohostUser, err := findUserByWebfinger(c.Request().Context(), cohost.Webfinger)
|
||||
if err == nil {
|
||||
room.CoHosts[i] = cohostUser
|
||||
}
|
||||
|
|
11
schema.go
11
schema.go
|
@ -187,20 +187,15 @@ func createIndexes(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if len(userIndexes) < 3 {
|
||||
if len(userIndexes) < 4 {
|
||||
_, err := userColl.Indexes().CreateMany(ctx, []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{{Key: "audon_id", Value: 1}},
|
||||
Options: options.Index().SetUnique(true),
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: "remote_url", Value: 1},
|
||||
{Key: "remote_id", Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "webfinger", Value: 1}},
|
||||
Keys: bson.D{{Key: "webfinger", Value: 1}},
|
||||
Options: options.Index().SetUnique(true),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
|
2
user.go
2
user.go
|
@ -105,7 +105,7 @@ func (a *AudonUser) Equal(u *AudonUser) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
return a.AudonID == u.AudonID || (a.RemoteID == u.RemoteID && a.RemoteURL == u.RemoteURL)
|
||||
return a.AudonID == u.AudonID || a.Webfinger == u.Webfinger
|
||||
}
|
||||
|
||||
func (a *AudonUser) InLivekit(ctx context.Context) (bool, error) {
|
||||
|
|
Ładowanie…
Reference in New Issue