mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Use functions
This commit is contained in:
parent
a6aaa5aa52
commit
f31be26df4
|
|
@ -121,7 +121,7 @@ func (oqs *OutgoingQueues) SendEvent(
|
||||||
"destinations": destinations, "event": ev.EventID(),
|
"destinations": destinations, "event": ev.EventID(),
|
||||||
}).Info("Sending event")
|
}).Info("Sending event")
|
||||||
|
|
||||||
nid, err := oqs.db.StoreJSON(context.TODO(), ev.JSON())
|
nid, err := oqs.db.StoreJSON(context.TODO(), string(ev.JSON()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("sendevent: oqs.db.StoreJSON: %w", err)
|
return fmt.Errorf("sendevent: oqs.db.StoreJSON: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ type Database interface {
|
||||||
internal.PartitionStorer
|
internal.PartitionStorer
|
||||||
UpdateRoom(ctx context.Context, roomID, oldEventID, newEventID string, addHosts []types.JoinedHost, removeHosts []string) (joinedHosts []types.JoinedHost, err error)
|
UpdateRoom(ctx context.Context, roomID, oldEventID, newEventID string, addHosts []types.JoinedHost, removeHosts []string) (joinedHosts []types.JoinedHost, err error)
|
||||||
GetJoinedHosts(ctx context.Context, roomID string) ([]types.JoinedHost, error)
|
GetJoinedHosts(ctx context.Context, roomID string) ([]types.JoinedHost, error)
|
||||||
StoreJSON(ctx context.Context, js []byte) (int64, error)
|
StoreJSON(ctx context.Context, js string) (int64, error)
|
||||||
AssociatePDUWithDestination(ctx context.Context, transactionID gomatrixserverlib.TransactionID, serverName gomatrixserverlib.ServerName, nids []int64) error
|
AssociatePDUWithDestination(ctx context.Context, transactionID gomatrixserverlib.TransactionID, serverName gomatrixserverlib.ServerName, nids []int64) error
|
||||||
GetNextTransactionPDUs(ctx context.Context, serverName gomatrixserverlib.ServerName, limit int) (gomatrixserverlib.TransactionID, []*gomatrixserverlib.HeaderedEvent, error)
|
GetNextTransactionPDUs(ctx context.Context, serverName gomatrixserverlib.ServerName, limit int) (gomatrixserverlib.TransactionID, []*gomatrixserverlib.HeaderedEvent, error)
|
||||||
CleanTransactionPDUs(ctx context.Context, serverName gomatrixserverlib.ServerName, transactionID gomatrixserverlib.TransactionID) error
|
CleanTransactionPDUs(ctx context.Context, serverName gomatrixserverlib.ServerName, transactionID gomatrixserverlib.TransactionID) error
|
||||||
|
|
|
||||||
|
|
@ -138,15 +138,11 @@ func (d *Database) GetJoinedHosts(
|
||||||
// a NID. The NID will then be used when inserting the per-destination
|
// a NID. The NID will then be used when inserting the per-destination
|
||||||
// metadata entries.
|
// metadata entries.
|
||||||
func (d *Database) StoreJSON(
|
func (d *Database) StoreJSON(
|
||||||
ctx context.Context, js []byte,
|
ctx context.Context, js string,
|
||||||
) (int64, error) {
|
) (int64, error) {
|
||||||
res, err := d.insertJSONStmt.ExecContext(ctx, js)
|
nid, err := d.insertQueueJSON(ctx, nil, js)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("d.insertRetryJSONStmt: %w", err)
|
return 0, fmt.Errorf("d.insertQueueJSON: %w", err)
|
||||||
}
|
|
||||||
nid, err := res.LastInsertId()
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("res.LastInsertID: %w", err)
|
|
||||||
}
|
}
|
||||||
return nid, nil
|
return nid, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,15 +144,11 @@ func (d *Database) GetJoinedHosts(
|
||||||
// a NID. The NID will then be used when inserting the per-destination
|
// a NID. The NID will then be used when inserting the per-destination
|
||||||
// metadata entries.
|
// metadata entries.
|
||||||
func (d *Database) StoreJSON(
|
func (d *Database) StoreJSON(
|
||||||
ctx context.Context, js []byte,
|
ctx context.Context, js string,
|
||||||
) (int64, error) {
|
) (int64, error) {
|
||||||
res, err := d.insertJSONStmt.ExecContext(ctx, js)
|
nid, err := d.insertQueueJSON(ctx, nil, js)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("d.insertRetryJSONStmt: %w", err)
|
return 0, fmt.Errorf("d.insertQueueJSON: %w", err)
|
||||||
}
|
|
||||||
nid, err := res.LastInsertId()
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("res.LastInsertID: %w", err)
|
|
||||||
}
|
}
|
||||||
return nid, nil
|
return nid, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue