-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
READY: Channel description and thumbnails #6025
Conversation
Congratulations 🎉. DeepCode analyzed your code in 2.651 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard | Configure the bot |
retest this please |
a052941
to
7641fe0
Compare
dec6395
to
3d31cb8
Compare
This PR enables the user to add thumbnails and Markdown-based descriptions to their channels.
3d31cb8
to
ff7d83a
Compare
src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py
Outdated
Show resolved
Hide resolved
src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py
Show resolved
Hide resolved
src/tribler-core/tribler_core/modules/metadata_store/community/remote_query_community.py
Show resolved
Hide resolved
src/tribler-core/tribler_core/modules/metadata_store/community/remote_query_community.py
Outdated
Show resolved
Hide resolved
src/tribler-core/tribler_core/modules/metadata_store/orm_bindings/binary_node.py
Show resolved
Hide resolved
def from_unpack_list( | ||
cls, metadata_type, reserved_flags, public_key, | ||
id_, origin_id, timestamp, | ||
binary_data, data_type, | ||
**kwargs | ||
): | ||
return cls( | ||
metadata_type, reserved_flags, public_key, | ||
id_, origin_id, timestamp, | ||
binary_data, data_type, | ||
**kwargs | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same here:
def from_unpack_list( | |
cls, metadata_type, reserved_flags, public_key, | |
id_, origin_id, timestamp, | |
binary_data, data_type, | |
**kwargs | |
): | |
return cls( | |
metadata_type, reserved_flags, public_key, | |
id_, origin_id, timestamp, | |
binary_data, data_type, | |
**kwargs | |
) | |
def from_unpack_list(cls, metadata_type, reserved_flags, public_key, id_, | |
origin_id, timestamp, binary_data, data_type, **kwargs): | |
return cls(metadata_type, reserved_flags, public_key, id_, origin_id, | |
timestamp, binary_data, data_type, **kwargs) |
…/gigachannel_community.py Co-authored-by: Andrei Andreev <[email protected]>
Co-authored-by: Andrei Andreev <[email protected]>
Co-authored-by: Andrei Andreev <[email protected]>
PR looks good to me in general. 5 failing checks from 15 is too much for approval. Probably some of them are unnecessary. We can discuss it with the team and (probably) change some of them. |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR enables the user to add thumbnails and Markdown-based descriptions to their channels. The GUI is based on wireframes devised by @drew2a.
Technical details
The feature required extending the whole software stack: GUI -> database -> transport layer.
GUI changes
Thumbnail and description are displayed by the
ChannelDescriptionWidget
(channel_description.ui
). The widget is initialized as a member object ofChannelContentsWidget
.Whenever a channel is opened in
ChannelContentsWidget
, it sends GET requests to a pair of new routes (description
andthumbnail
) in the corresponding channel endpoint (see details below). If at least one of those responds with properly formed data, the description widget is shown. Otherwise, a "Create description" button is shown (for personal channels only).Important dev notes on the GUI side:
.ui
file for the widget lacks any styling. Instead, styles are inherited from themainwindow.ui
. It was especially hard and unintuitive to figure out that PyQT still applies CSS styles to child class widgets if the *base classCSS is defined somewhere in the
.ui` file. Managing to set all the "sizing" stuff properly to make the widget achieve the right size was especially painful, and basically got down to brute-forcing all the possible combinations of parameters of the widget and its parent, together with doing a manual binary search on the widget tree for offending sub-widgets;brain_dead_refresh
🧟 🧠 is back.REST endpoint changes
Two new routes are added to the
channels\<pk>\<id>\...
enpoint, servingGET
andPUT
requests:description
route returns a JSON dict with contents stored in adescription_text
field.thumbnail
route returns a binary HTTP transfer with a setContent-Type
header (e.q.image/png
).Database changes
New subclasses of the
ChannelNode
ORM class are added:ChannelThumbnail
<-BinaryNode
<-ChannelNode
ChannelDescription
<-JsonNode
<-ChannelNode
The purpose of these classes is to store arbitrary binary and JSON-formatted text data, while still using all the transport/signing/updating logic available to ChannelNode class (e.g. serving through RemoteQueryCommunity, packing into
.mdblob
s, dumping into channel torrents on disk, etc.)Each channel can now have child entries of these types, the same way it can have torrent and folder children. A channel is supposed to have only one of these. (Though, nothing in the code prevents distribution of channels with more than a single thumbnail/description entry. Locally, only a single instance of those will be used.)
BinaryNode
andChannelThumbnail
These new classes extend
ChannelNode
by adding two new fields/columns:binary_data
stores arbitrary data in binary formdata_type
stores the MIME type for the data (as a plaintext string)JsonNode
andChannelDescription
These classes extend
ChannelNode
by adding a single new field/column:json_text
stores JSON-encoded dict (as a plaintext string)Important dev notes on the database side:
entries_to_chunk
procedure, which now puts bigger-than-chunk-limit entries into separate chunks instead of raising an exception.Community and transport changes
Big blob transport
RemoteQueryCommunity
now inherits fro theEVAProtocol
mixin (developed by @drew2a), which enables sending bigger-than-UDP-packet blobs reliably.The changes to RQC were minimal and backwards-compatible. It works like this: whenever Alice queries Bob for entries through RQC, if Bob has to respond with an entry that is too big to fit into a single UDP packet, the whole payload is serialized and pushed to Alice through
EVAProtocol
eva_send_binary
. When Alice receives the complete binary transfer, she feeds the received binary raw to the IPv8'son_packet
method, which then triggers the appropriate response from the RQC community. Thus, the transport is completely transparent for RQC (maintaining all the safety checks, etc.).Channel preview logic changes
A couple of new triggers are added to RQC: