mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Check that db actually returned json blob for requested nid
This commit is contained in:
parent
d440223e04
commit
7c692e7eda
|
|
@ -116,6 +116,7 @@ func (d *Database) GetTransaction(
|
||||||
if len(nids) == 0 {
|
if len(nids) == 0 {
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
firstNID := nids[0]
|
||||||
|
|
||||||
txns := map[int64][]byte{}
|
txns := map[int64][]byte{}
|
||||||
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||||
|
|
@ -127,12 +128,16 @@ func (d *Database) GetTransaction(
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction := &gomatrixserverlib.Transaction{}
|
transaction := &gomatrixserverlib.Transaction{}
|
||||||
err = json.Unmarshal(txns[nids[0]], transaction)
|
if _, ok := txns[firstNID]; !ok {
|
||||||
|
return nil, nil, fmt.Errorf("Failed retrieving json blob for transaction: %d", firstNID)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(txns[firstNID], transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("Unmarshal transaction: %w", err)
|
return nil, nil, fmt.Errorf("Unmarshal transaction: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
receipt := receipt.NewReceipt(nids[0])
|
receipt := receipt.NewReceipt(firstNID)
|
||||||
return transaction, &receipt, nil
|
return transaction, &receipt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue