aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/sqlite3
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-07-07 12:51:55 +0100
committerGitHub <noreply@github.com>2020-07-07 12:51:55 +0100
commit99ea1f9b4875e9458e640daa3358c3e9ad4fe065 (patch)
treefab2f5ccf12241cdfa4323525590957276e23c8c /roomserver/storage/sqlite3
parentd7a8bbff72194ea41d33aba49bfa3caf9a40e721 (diff)
Emit redacted_event from the roomserver when redactions are validated (#1186)
* Emit redacted_event from the roomserver when redactions are validated - Consume them in the currentstateserver and act accordingly. - Add integration test for the roomserver to check that injecting `m.room.redaction` events result in `redacted_event` being emitted. * Linting * Ignore events that redact themselves
Diffstat (limited to 'roomserver/storage/sqlite3')
-rw-r--r--roomserver/storage/sqlite3/redactions_table.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/roomserver/storage/sqlite3/redactions_table.go b/roomserver/storage/sqlite3/redactions_table.go
index 9910892c..1cddb9b4 100644
--- a/roomserver/storage/sqlite3/redactions_table.go
+++ b/roomserver/storage/sqlite3/redactions_table.go
@@ -40,11 +40,11 @@ const insertRedactionSQL = "" +
"INSERT INTO roomserver_redactions (redaction_event_id, redacts_event_id, validated)" +
" VALUES ($1, $2, $3)"
-const selectRedactedEventSQL = "" +
+const selectRedactionInfoByRedactionEventIDSQL = "" +
"SELECT redaction_event_id, redacts_event_id, validated FROM roomserver_redactions" +
" WHERE redaction_event_id = $1"
-const selectRedactionEventSQL = "" +
+const selectRedactionInfoByEventBeingRedactedSQL = "" +
"SELECT redaction_event_id, redacts_event_id, validated FROM roomserver_redactions" +
" WHERE redacts_event_id = $1"
@@ -52,10 +52,10 @@ const markRedactionValidatedSQL = "" +
" UPDATE roomserver_redactions SET validated = $2 WHERE redaction_event_id = $1"
type redactionStatements struct {
- insertRedactionStmt *sql.Stmt
- selectRedactedEventStmt *sql.Stmt
- selectRedactionEventStmt *sql.Stmt
- markRedactionValidatedStmt *sql.Stmt
+ insertRedactionStmt *sql.Stmt
+ selectRedactionInfoByRedactionEventIDStmt *sql.Stmt
+ selectRedactionInfoByEventBeingRedactedStmt *sql.Stmt
+ markRedactionValidatedStmt *sql.Stmt
}
func NewSqliteRedactionsTable(db *sql.DB) (tables.Redactions, error) {
@@ -67,8 +67,8 @@ func NewSqliteRedactionsTable(db *sql.DB) (tables.Redactions, error) {
return s, shared.StatementList{
{&s.insertRedactionStmt, insertRedactionSQL},
- {&s.selectRedactedEventStmt, selectRedactedEventSQL},
- {&s.selectRedactionEventStmt, selectRedactionEventSQL},
+ {&s.selectRedactionInfoByRedactionEventIDStmt, selectRedactionInfoByRedactionEventIDSQL},
+ {&s.selectRedactionInfoByEventBeingRedactedStmt, selectRedactionInfoByEventBeingRedactedSQL},
{&s.markRedactionValidatedStmt, markRedactionValidatedSQL},
}.Prepare(db)
}
@@ -81,11 +81,11 @@ func (s *redactionStatements) InsertRedaction(
return err
}
-func (s *redactionStatements) SelectRedactedEvent(
+func (s *redactionStatements) SelectRedactionInfoByRedactionEventID(
ctx context.Context, txn *sql.Tx, redactionEventID string,
) (info *tables.RedactionInfo, err error) {
info = &tables.RedactionInfo{}
- stmt := sqlutil.TxStmt(txn, s.selectRedactedEventStmt)
+ stmt := sqlutil.TxStmt(txn, s.selectRedactionInfoByRedactionEventIDStmt)
err = stmt.QueryRowContext(ctx, redactionEventID).Scan(
&info.RedactionEventID, &info.RedactsEventID, &info.Validated,
)
@@ -96,12 +96,12 @@ func (s *redactionStatements) SelectRedactedEvent(
return
}
-func (s *redactionStatements) SelectRedactionEvent(
- ctx context.Context, txn *sql.Tx, redactedEventID string,
+func (s *redactionStatements) SelectRedactionInfoByEventBeingRedacted(
+ ctx context.Context, txn *sql.Tx, eventID string,
) (info *tables.RedactionInfo, err error) {
info = &tables.RedactionInfo{}
- stmt := sqlutil.TxStmt(txn, s.selectRedactionEventStmt)
- err = stmt.QueryRowContext(ctx, redactedEventID).Scan(
+ stmt := sqlutil.TxStmt(txn, s.selectRedactionInfoByEventBeingRedactedStmt)
+ err = stmt.QueryRowContext(ctx, eventID).Scan(
&info.RedactionEventID, &info.RedactsEventID, &info.Validated,
)
if err == sql.ErrNoRows {