mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Merge pull request #68 from globekeeper/daniel/secs2ms-multiroom
♻️ Milliseconds instead of seconds for MR.
This commit is contained in:
commit
958ab5606a
2
.github/workflows/dendrite.yml
vendored
2
.github/workflows/dendrite.yml
vendored
|
|
@ -377,7 +377,7 @@ jobs:
|
||||||
# See https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md specifically GOROOT_1_17_X64
|
# See https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md specifically GOROOT_1_17_X64
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
|
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
|
||||||
go get -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
|
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
|
||||||
- name: Run actions/checkout@v3 for dendrite
|
- name: Run actions/checkout@v3 for dendrite
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ func (s *OutputMultiRoomDataConsumer) onMessage(ctx context.Context, msgs []*nat
|
||||||
|
|
||||||
rooms, err := s.db.SelectMultiRoomVisibilityRooms(ctx, mrd.SelectMultiRoomVisibilityRoomsParams{
|
rooms, err := s.db.SelectMultiRoomVisibilityRooms(ctx, mrd.SelectMultiRoomVisibilityRoomsParams{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ExpireTs: time.Now().Unix(),
|
ExpireTs: time.Now().UnixMilli(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sentry.CaptureException(err)
|
sentry.CaptureException(err)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package mrd
|
package mrd
|
||||||
|
|
||||||
type StateEvent struct {
|
type StateEvent struct {
|
||||||
Hidden bool `json:"hidden"`
|
Hidden bool `json:"hidden"`
|
||||||
ExpireTs int `json:"expire_ts"`
|
ExpireTs int64 `json:"expire_ts"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func (s *multiRoomStatements) SelectMultiRoomData(ctx context.Context, r *types.
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
r := types.MultiRoomDataRow{}
|
r := types.MultiRoomDataRow{}
|
||||||
err = rows.Scan(&r.UserId, &r.Type, &r.Data, &t)
|
err = rows.Scan(&r.UserId, &r.Type, &r.Data, &t)
|
||||||
r.Timestamp = t.Unix()
|
r.Timestamp = t.UnixMilli()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("rows scan: %w", err)
|
return nil, fmt.Errorf("rows scan: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -655,7 +655,7 @@ func (d *Database) UpdateMultiRoomVisibility(ctx context.Context, event *gomatri
|
||||||
UserID: event.Sender(),
|
UserID: event.Sender(),
|
||||||
Type: event.Type(),
|
Type: event.Type(),
|
||||||
RoomID: event.RoomID(),
|
RoomID: event.RoomID(),
|
||||||
ExpireTs: int64(mrdEv.ExpireTs),
|
ExpireTs: mrdEv.ExpireTs,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("insert multiroom visibility failed: %w", err)
|
return fmt.Errorf("insert multiroom visibility failed: %w", err)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ func AddPublicRoutes(
|
||||||
go func() {
|
go func() {
|
||||||
var affected int64
|
var affected int64
|
||||||
for {
|
for {
|
||||||
affected, err = mrq.DeleteMultiRoomVisibilityByExpireTS(context.Background(), time.Now().Unix())
|
affected, err = mrq.DeleteMultiRoomVisibilityByExpireTS(context.Background(), time.Now().UnixMilli())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to expire multiroom visibility")
|
logrus.WithError(err).Error("failed to expire multiroom visibility")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ func TestMarshallMultiRoom(t *testing.T) {
|
||||||
"@3:example.com": map[string]MultiRoomData{
|
"@3:example.com": map[string]MultiRoomData{
|
||||||
"location": {
|
"location": {
|
||||||
Content: MultiRoomContent(`{"foo":"bar"}`),
|
Content: MultiRoomContent(`{"foo":"bar"}`),
|
||||||
OriginServerTs: 123,
|
OriginServerTs: 1234567890000,
|
||||||
}}})
|
}}})
|
||||||
is.NoErr(err)
|
is.NoErr(err)
|
||||||
is.Equal(m, []byte(`{"@3:example.com":{"location":{"content":{"foo":"bar"},"origin_server_ts":123}}}`))
|
is.Equal(m, []byte(`{"@3:example.com":{"location":{"content":{"foo":"bar"},"origin_server_ts":1234567890000}}}`))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue