mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Add length validation foe caption
This commit is contained in:
parent
1697db9d7f
commit
6faba0f286
|
|
@ -269,7 +269,7 @@ namespace TLSharp.Core
|
||||||
random_id = Helpers.GenerateRandomLong(),
|
random_id = Helpers.GenerateRandomLong(),
|
||||||
background = false,
|
background = false,
|
||||||
clear_draft = false,
|
clear_draft = false,
|
||||||
media = new TLInputMediaUploadedPhoto() { file = file, caption = caption },
|
media = new TLInputMediaUploadedPhoto() { file = file, Caption = caption },
|
||||||
peer = peer
|
peer = peer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
namespace TeleSharp.TL
|
namespace TeleSharp.TL
|
||||||
{
|
{
|
||||||
[TLObject(1661770481)]
|
[TLObject(1661770481)]
|
||||||
public class TLInputMediaUploadedPhoto : TLAbsInputMedia
|
public class TLInputMediaUploadedPhoto : TLAbsInputMedia
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor
|
||||||
|
|
@ -18,41 +18,52 @@ namespace TeleSharp.TL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public TLAbsInputFile file {get;set;}
|
public TLAbsInputFile file { get; set; }
|
||||||
public string caption {get;set;}
|
|
||||||
public TLVector<TLAbsInputDocument> stickers {get;set;}
|
private string caption;
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public string Caption
|
||||||
{
|
{
|
||||||
flags = 0;
|
get { return caption; }
|
||||||
flags = stickers != null ? (flags | 1) : (flags & ~1);
|
set
|
||||||
|
{
|
||||||
|
caption = value.Length > 200 ? value.Remove(199, value.Length - 199) : value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public TLVector<TLAbsInputDocument> stickers { get; set; }
|
||||||
|
|
||||||
}
|
|
||||||
|
public void ComputeFlags()
|
||||||
|
{
|
||||||
|
flags = 0;
|
||||||
|
flags = stickers != null ? (flags | 1) : (flags & ~1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
|
file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
|
||||||
caption = StringUtil.Deserialize(br);
|
caption = StringUtil.Deserialize(br);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
stickers = (TLVector<TLAbsInputDocument>)ObjectUtils.DeserializeVector<TLAbsInputDocument>(br);
|
stickers = (TLVector<TLAbsInputDocument>)ObjectUtils.DeserializeVector<TLAbsInputDocument>(br);
|
||||||
else
|
else
|
||||||
stickers = null;
|
stickers = null;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
ObjectUtils.SerializeObject(file,bw);
|
ObjectUtils.SerializeObject(file, bw);
|
||||||
StringUtil.Serialize(caption,bw);
|
StringUtil.Serialize(caption, bw);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
ObjectUtils.SerializeObject(stickers,bw);
|
ObjectUtils.SerializeObject(stickers, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue