mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Missing files
This commit is contained in:
parent
5d320dc1ab
commit
9fb3de50e0
37
syncapi/storage/shared/syncserver.go
Normal file
37
syncapi/storage/shared/syncserver.go
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
package shared
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||||
|
"github.com/matrix-org/dendrite/syncapi/types"
|
||||||
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Database is a temporary struct until we have made syncserver.go the same for both pq/sqlite
|
||||||
|
// For now this contains the shared functions
|
||||||
|
type Database struct {
|
||||||
|
DB *sql.DB
|
||||||
|
Invites tables.Invites
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Database) AddInviteEvent(
|
||||||
|
ctx context.Context, inviteEvent gomatrixserverlib.HeaderedEvent,
|
||||||
|
) (sp types.StreamPosition, err error) {
|
||||||
|
err = common.WithTransaction(d.DB, func(txn *sql.Tx) error {
|
||||||
|
sp, err = d.Invites.InsertInviteEvent(ctx, txn, inviteEvent)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Database) RetireInviteEvent(
|
||||||
|
ctx context.Context, inviteEventID string,
|
||||||
|
) error {
|
||||||
|
// TODO: Record that invite has been retired in a stream so that we can
|
||||||
|
// notify the user in an incremental sync.
|
||||||
|
err := d.Invites.DeleteInviteEvent(ctx, inviteEventID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
16
syncapi/storage/tables/interface.go
Normal file
16
syncapi/storage/tables/interface.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package tables
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/syncapi/types"
|
||||||
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Invites interface {
|
||||||
|
InsertInviteEvent(ctx context.Context, txn *sql.Tx, inviteEvent gomatrixserverlib.HeaderedEvent) (streamPos types.StreamPosition, err error)
|
||||||
|
DeleteInviteEvent(ctx context.Context, inviteEventID string) error
|
||||||
|
SelectInviteEventsInRange(ctx context.Context, txn *sql.Tx, targetUserID string, startPos, endPos types.StreamPosition) (map[string]gomatrixserverlib.HeaderedEvent, error)
|
||||||
|
SelectMaxInviteID(ctx context.Context, txn *sql.Tx) (id int64, err error)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue