From e78a9f68aca6f9f9b759fc49b18bee2269b7a889 Mon Sep 17 00:00:00 2001 From: omarm Date: Thu, 13 Apr 2017 13:52:03 +0300 Subject: [PATCH] Add caption length validation --- TLSharp.Core/TelegramClient.cs | 2 +- TeleSharp.TL/TL/TLInputMediaUploadedDocument.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index a4fa06a..036ae8d 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -285,7 +285,7 @@ namespace TLSharp.Core media = new TLInputMediaUploadedDocument() { file = file, - caption = caption, + Caption = caption, mime_type = mimeType, attributes = attributes }, diff --git a/TeleSharp.TL/TL/TLInputMediaUploadedDocument.cs b/TeleSharp.TL/TL/TLInputMediaUploadedDocument.cs index 23a57a8..3347ef8 100644 --- a/TeleSharp.TL/TL/TLInputMediaUploadedDocument.cs +++ b/TeleSharp.TL/TL/TLInputMediaUploadedDocument.cs @@ -22,7 +22,8 @@ namespace TeleSharp.TL public TLAbsInputFile file {get;set;} public string mime_type {get;set;} public TLVector attributes {get;set;} - public string caption {get;set;} + private string caption; + public string Caption { get { return caption; } set { caption = value.Length > 200 ? value.Remove(199, value.Length - 199) : value; } } public TLVector stickers {get;set;} @@ -39,7 +40,7 @@ flags = stickers != null ? (flags | 1) : (flags & ~1); file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br); mime_type = StringUtil.Deserialize(br); attributes = (TLVector)ObjectUtils.DeserializeVector(br); -caption = StringUtil.Deserialize(br); +Caption = StringUtil.Deserialize(br); if ((flags & 1) != 0) stickers = (TLVector)ObjectUtils.DeserializeVector(br); else @@ -56,7 +57,7 @@ bw.Write(flags); ObjectUtils.SerializeObject(file,bw); StringUtil.Serialize(mime_type,bw); ObjectUtils.SerializeObject(attributes,bw); -StringUtil.Serialize(caption,bw); +StringUtil.Serialize(Caption,bw); if ((flags & 1) != 0) ObjectUtils.SerializeObject(stickers,bw);