Validate ensures the query uses sane bounds and one cursor direction.
()
| 1695 | |
| 1696 | // Validate ensures the query uses sane bounds and one cursor direction. |
| 1697 | func (q NetworkConversationMessageQuery) Validate() error { |
| 1698 | if strings.TrimSpace(q.BeforeMessageID) != "" && strings.TrimSpace(q.AfterMessageID) != "" { |
| 1699 | return fmt.Errorf("store: network conversation message query cannot specify both before and after cursors") |
| 1700 | } |
| 1701 | if strings.TrimSpace(q.Kind) != "" { |
| 1702 | if err := validateNetworkMessageKind(q.Kind); err != nil { |
| 1703 | return err |
| 1704 | } |
| 1705 | } |
| 1706 | if strings.TrimSpace(q.WorkID) != "" { |
| 1707 | if err := validateNetworkConversationID(q.WorkID, "work_id"); err != nil { |
| 1708 | return err |
| 1709 | } |
| 1710 | } |
| 1711 | return requirePositiveLimit(q.Limit, "network conversation message limit") |
| 1712 | } |
| 1713 | |
| 1714 | // NormalizeNetworkDirectRoomPeers validates and orders a two-party room pair. |
| 1715 | func NormalizeNetworkDirectRoomPeers(peerA string, peerB string) (string, string, error) { |