Closed NotStatilko closed 2 years ago
comment
will be used for custom file attributes & types, so every developer may add own.
I suggest this standard:
comment
is custom attributes, it must start from the one 0xFF
byte. Otherwise this field will be determined as plain comment.dict()
. Value can be b''
.As delimeters we may use length of Key (not to be confused with keys.Key
) and the length of Value.
I.e we want to add to the RemoteBoxFile
custom attribute key
with value value
. Then:
comment = b'\xff\x03key\x05value'
\x03
, convert it to int (3
) and take three next bytes, receive Key;5
) and take next five bytes, receive Value;So, for example, we may use this to store file hash or signatures, or whatever.
We can also use this to determine file types, if needed. Let's use type
as Key.
Types can be combined, but there is limit in 255 bytes.
Example:
from tgbox.tools import CustomAttributes
# Some random types
cattr = CustomAttributes.make(
sha256 = b'\x00'*32,
never = b'gonna give you up'
)
# Defining text message type
cattr = CustomAttributes.make(
type = b'message'
)
Further will be list of types. You may suggest your own, if interested.
Key | Value | Description |
---|---|---|
sha256 | hash | May be used any hashfunc from hashlib |
reply | message.id |
Reply to the ID |
type | b'message' |
Text message type, can be another Value |
The CustomAttributes
is now a PackedAttributes
. This algorithm is used now for packing metadata attrs. comment
attribute of prepare_file(...)
is now replaced by a cattrs
, user can present a dict with custom file attributes he wants, so all of the previous information on this issue isn't actual as per v1.0.
See new metadata: https://tgbox.readthedocs.io/en/latest/remotebox.html#remoteboxfile See new cattrs attr: https://tgbox.readthedocs.io/en/latest/tgbox.html?highlight=prepare_file#tgbox.api.DecryptedLocalBox.prepare_file
Still, i want to make a standart for cattrs keys that different apps based on tgbox can share. Like "comment" key to define a file commentary or "type" to define a file type, e.g with a "message" value or even "sha256" / "md5" / "sha1" ... to define a file hash. You can propose your ideas here.
We have a 255-byte field called
comment
. I suggest to use it for determining file types.My thoughts about this:
;msg;
determines that this file is Text-message;;rep;5;
determines that this file is Reply to another file with ID=5;;1;alb;{alb_id};
determines that this file is part of Album.1
here is order.alb_id
is unique Album ID. Maybe 4 random bytes?;pubkey;sgn;signature;
determines that this file was signed by pubkey....