| | | 1 | | using TeleFlow.Telegram.Schema.Types; |
| | | 2 | | |
| | | 3 | | namespace TeleFlow.Telegram.Internal; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Carries either a decoded Telegram update or the evidence required to apply an explicit poison-update policy. |
| | | 7 | | /// </summary> |
| | | 8 | | internal readonly record struct TelegramUpdateDecodeResult( |
| | | 9 | | long UpdateId, |
| | | 10 | | Update? Update, |
| | | 11 | | string? RawPayloadJson, |
| | | 12 | | string? PayloadSha256, |
| | | 13 | | TelegramUpdateDecodeException? Exception) |
| | | 14 | | { |
| | 50 | 15 | | public bool IsSuccess => Update is not null; |
| | | 16 | | |
| | | 17 | | public static TelegramUpdateDecodeResult Success(Update update) |
| | | 18 | | { |
| | 43 | 19 | | ArgumentNullException.ThrowIfNull(update); |
| | 43 | 20 | | return new TelegramUpdateDecodeResult(update.UpdateId, update, null, null, null); |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | public static TelegramUpdateDecodeResult Failure( |
| | | 24 | | long updateId, |
| | | 25 | | string rawPayloadJson, |
| | | 26 | | string payloadSha256, |
| | | 27 | | TelegramUpdateDecodeException exception) |
| | | 28 | | { |
| | 8 | 29 | | ArgumentException.ThrowIfNullOrWhiteSpace(rawPayloadJson); |
| | 8 | 30 | | ArgumentException.ThrowIfNullOrWhiteSpace(payloadSha256); |
| | 8 | 31 | | ArgumentNullException.ThrowIfNull(exception); |
| | 8 | 32 | | return new TelegramUpdateDecodeResult(updateId, null, rawPayloadJson, payloadSha256, exception); |
| | | 33 | | } |
| | | 34 | | } |