| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "reasonix/internal/sessioninbox" |
| 6 | ) |
| 7 | |
| 8 | var ErrInboxSessionChanged = errors.New("inbox session changed before submission") |
| 9 | |
| 10 | func (c *Controller) LookupInboxReceipt(key string) (sessioninbox.InboxReceipt, bool, error) { |
| 11 | return c.LookupInboxReceiptForSession("", key) |
| 12 | } |
| 13 | |
| 14 | func (c *Controller) LookupInboxReceiptForSession(path, key string) (sessioninbox.InboxReceipt, bool, error) { |
| 15 | store, err := c.ensureInbox() |
| 16 | if err != nil { |
| 17 | return sessioninbox.InboxReceipt{}, false, err |
| 18 | } |
| 19 | if path != "" && store.SessionPath() != path { |
| 20 | return sessioninbox.InboxReceipt{}, false, ErrInboxSessionChanged |
| 21 | } |
| 22 | receipt, found := store.LookupReceipt(key) |
| 23 | return receipt, found, nil |
| 24 | } |
| 25 |