mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 23:23:10 -06:00
Merge main, fix issues
This commit is contained in:
parent
e6fd65b8fc
commit
4406c85c98
|
|
@ -341,6 +341,7 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
|
|||
}
|
||||
|
||||
if len(filename) == 0 {
|
||||
w.Header().Set("Content-Disposition", "attachment")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -376,13 +377,13 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
|
|||
// that would otherwise be parsed as a control character in the
|
||||
// Content-Disposition header
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(
|
||||
`inline; filename=%s%s%s`,
|
||||
`attachment; filename=%s%s%s`,
|
||||
quote, unescaped, quote,
|
||||
))
|
||||
} else {
|
||||
// For UTF-8 filenames, we quote always, as that's the standard
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(
|
||||
`inline; filename*=utf-8''%s`,
|
||||
`attachment; filename*=utf-8''%s`,
|
||||
url.QueryEscape(unescaped),
|
||||
))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1029,7 +1029,7 @@ func (r *Queryer) QueryUserIDForSender(ctx context.Context, roomID spec.RoomID,
|
|||
}
|
||||
|
||||
if userKeys, ok := result[roomID]; ok {
|
||||
if userID, ok := userKeys[string(bytes)]; ok {
|
||||
if userID, ok := userKeys[string(senderID)]; ok {
|
||||
return spec.NewUserID(userID, true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
const userRoomKeysSchema = `
|
||||
|
|
@ -145,7 +146,7 @@ func (s *userRoomKeysStatements) BulkSelectUserNIDs(ctx context.Context, txn *sq
|
|||
if err = rows.Scan(&userRoomKeyPair.EventStateKeyNID, &userRoomKeyPair.RoomNID, &publicKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[string(publicKey)] = userRoomKeyPair
|
||||
result[spec.Base64Bytes(publicKey).Encode()] = userRoomKeyPair
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func TestUserRoomKeys(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
wantKeys := map[spec.RoomID]map[string]string{
|
||||
*roomID: {
|
||||
string(key.Public().(ed25519.PublicKey)): userID.String(),
|
||||
spec.Base64Bytes(key.Public().(ed25519.PublicKey)).Encode(): userID.String(),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, wantKeys, userIDs)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
const userRoomKeysSchema = `
|
||||
|
|
@ -159,7 +160,7 @@ func (s *userRoomKeysStatements) BulkSelectUserNIDs(ctx context.Context, txn *sq
|
|||
if err = rows.Scan(&userRoomKeyPair.EventStateKeyNID, &userRoomKeyPair.RoomNID, &publicKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[string(publicKey)] = userRoomKeyPair
|
||||
result[spec.Base64Bytes(publicKey).Encode()] = userRoomKeyPair
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/matrix-org/dendrite/test"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
"github.com/stretchr/testify/assert"
|
||||
ed255192 "golang.org/x/crypto/ed25519"
|
||||
)
|
||||
|
|
@ -101,8 +102,8 @@ func TestUserRoomKeysTable(t *testing.T) {
|
|||
assert.NotNil(t, gotKeys)
|
||||
|
||||
wantKeys := map[string]types.UserRoomKeyPair{
|
||||
string(key2.Public().(ed25519.PublicKey)): {RoomNID: roomNID, EventStateKeyNID: userNID},
|
||||
string(key3.Public().(ed25519.PublicKey)): {RoomNID: roomNID, EventStateKeyNID: userNID2},
|
||||
string(spec.Base64Bytes(key2.Public().(ed25519.PublicKey)).Encode()): {RoomNID: roomNID, EventStateKeyNID: userNID},
|
||||
string(spec.Base64Bytes(key3.Public().(ed25519.PublicKey)).Encode()): {RoomNID: roomNID, EventStateKeyNID: userNID2},
|
||||
}
|
||||
assert.Equal(t, wantKeys, gotKeys)
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ func TestSearch(t *testing.T) {
|
|||
stateEvents = append(stateEvents, x)
|
||||
stateEventIDs = append(stateEventIDs, x.EventID())
|
||||
}
|
||||
|
||||
x.StateKeyResolved = x.StateKey()
|
||||
sp, err = db.WriteEvent(processCtx.Context(), x, stateEvents, stateEventIDs, nil, nil, false, gomatrixserverlib.HistoryVisibilityShared)
|
||||
assert.NoError(t, err)
|
||||
if x.Type() != "m.room.message" {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func (s *membershipsStatements) UpsertMembership(
|
|||
_, err = sqlutil.TxStmt(txn, s.upsertMembershipStmt).ExecContext(
|
||||
ctx,
|
||||
event.RoomID(),
|
||||
event.UserID.String(),
|
||||
event.StateKeyResolved,
|
||||
membership,
|
||||
event.EventID(),
|
||||
streamPos,
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ func (s *membershipsStatements) UpsertMembership(
|
|||
_, err = sqlutil.TxStmt(txn, s.upsertMembershipStmt).ExecContext(
|
||||
ctx,
|
||||
event.RoomID(),
|
||||
event.UserID.String(),
|
||||
event.StateKeyResolved,
|
||||
membership,
|
||||
event.EventID(),
|
||||
streamPos,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ func TestMembershipsTable(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
for _, ev := range userEvents {
|
||||
ev.StateKeyResolved = ev.StateKey()
|
||||
if err := table.UpsertMembership(ctx, nil, ev, types.StreamPosition(ev.Depth()), 1); err != nil {
|
||||
t.Fatalf("failed to upsert membership: %s", err)
|
||||
}
|
||||
|
|
@ -134,6 +135,7 @@ func testUpsert(t *testing.T, ctx context.Context, table tables.Memberships, mem
|
|||
ev := room.CreateAndInsert(t, user, spec.MRoomMember, map[string]interface{}{
|
||||
"membership": spec.Join,
|
||||
}, test.WithStateKey(user.ID))
|
||||
ev.StateKeyResolved = ev.StateKey()
|
||||
// Insert the same event again, but with different positions, which should get updated
|
||||
if err = table.UpsertMembership(ctx, nil, ev, 2, 2); err != nil {
|
||||
t.Fatalf("failed to upsert membership: %s", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue