Update API scheme, pass privacy info to viewer.
This commit is contained in:
parent
585bbd45f4
commit
ffd691e556
|
@ -330,6 +330,7 @@ void DocumentData::setattributes(
|
||||||
_flags &= ~(Flag::ImageType
|
_flags &= ~(Flag::ImageType
|
||||||
| Flag::HasAttachedStickers
|
| Flag::HasAttachedStickers
|
||||||
| Flag::UseTextColor
|
| Flag::UseTextColor
|
||||||
|
| Flag::SilentVideo
|
||||||
| kStreamingSupportedMask);
|
| kStreamingSupportedMask);
|
||||||
_flags |= kStreamingSupportedUnknown;
|
_flags |= kStreamingSupportedUnknown;
|
||||||
|
|
||||||
|
@ -402,6 +403,9 @@ void DocumentData::setattributes(
|
||||||
_duration = crl::time(
|
_duration = crl::time(
|
||||||
base::SafeRound(data.vduration().v * 1000));
|
base::SafeRound(data.vduration().v * 1000));
|
||||||
setMaybeSupportsStreaming(data.is_supports_streaming());
|
setMaybeSupportsStreaming(data.is_supports_streaming());
|
||||||
|
if (data.is_nosound()) {
|
||||||
|
_flags |= Flag::SilentVideo;
|
||||||
|
}
|
||||||
dimensions = QSize(data.vw().v, data.vh().v);
|
dimensions = QSize(data.vw().v, data.vh().v);
|
||||||
}, [&](const MTPDdocumentAttributeAudio &data) {
|
}, [&](const MTPDdocumentAttributeAudio &data) {
|
||||||
if (type == FileDocument) {
|
if (type == FileDocument) {
|
||||||
|
@ -1542,6 +1546,10 @@ bool DocumentData::isVideoFile() const {
|
||||||
return (type == VideoDocument);
|
return (type == VideoDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DocumentData::isSilentVideo() const {
|
||||||
|
return _flags & Flag::SilentVideo;
|
||||||
|
}
|
||||||
|
|
||||||
crl::time DocumentData::duration() const {
|
crl::time DocumentData::duration() const {
|
||||||
return std::max(_duration, crl::time());
|
return std::max(_duration, crl::time());
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ public:
|
||||||
[[nodiscard]] bool isSongWithCover() const;
|
[[nodiscard]] bool isSongWithCover() const;
|
||||||
[[nodiscard]] bool isAudioFile() const;
|
[[nodiscard]] bool isAudioFile() const;
|
||||||
[[nodiscard]] bool isVideoFile() const;
|
[[nodiscard]] bool isVideoFile() const;
|
||||||
|
[[nodiscard]] bool isSilentVideo() const;
|
||||||
[[nodiscard]] bool isAnimation() const;
|
[[nodiscard]] bool isAnimation() const;
|
||||||
[[nodiscard]] bool isGifv() const;
|
[[nodiscard]] bool isGifv() const;
|
||||||
[[nodiscard]] bool isTheme() const;
|
[[nodiscard]] bool isTheme() const;
|
||||||
|
|
|
@ -255,12 +255,16 @@ bool Story::pinned() const {
|
||||||
return _pinned;
|
return _pinned;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::isPublic() const {
|
StoryPrivacy Story::privacy() const {
|
||||||
return _isPublic;
|
return _privacyPublic
|
||||||
}
|
? StoryPrivacy::Public
|
||||||
|
: _privacyCloseFriends
|
||||||
bool Story::closeFriends() const {
|
? StoryPrivacy::CloseFriends
|
||||||
return _closeFriends;
|
: _privacyContacts
|
||||||
|
? StoryPrivacy::Contacts
|
||||||
|
: _privacySelectedContacts
|
||||||
|
? StoryPrivacy::SelectedContacts
|
||||||
|
: StoryPrivacy::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::forbidsForward() const {
|
bool Story::forbidsForward() const {
|
||||||
|
@ -276,7 +280,7 @@ bool Story::canDownload() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::canShare() const {
|
bool Story::canShare() const {
|
||||||
return isPublic() && !forbidsForward() && (pinned() || !expired());
|
return _privacyPublic && !forbidsForward() && (pinned() || !expired());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::canDelete() const {
|
bool Story::canDelete() const {
|
||||||
|
@ -288,7 +292,7 @@ bool Story::canReport() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::hasDirectLink() const {
|
bool Story::hasDirectLink() const {
|
||||||
if (!_isPublic || (!_pinned && expired())) {
|
if (!_privacyPublic || (!_pinned && expired())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto user = _peer->asUser();
|
const auto user = _peer->asUser();
|
||||||
|
@ -410,8 +414,15 @@ void Story::applyFields(
|
||||||
|
|
||||||
const auto pinned = data.is_pinned();
|
const auto pinned = data.is_pinned();
|
||||||
const auto edited = data.is_edited();
|
const auto edited = data.is_edited();
|
||||||
const auto isPublic = data.is_public();
|
const auto privacy = data.is_public()
|
||||||
const auto closeFriends = data.is_close_friends();
|
? StoryPrivacy::Public
|
||||||
|
: data.is_close_friends()
|
||||||
|
? StoryPrivacy::CloseFriends
|
||||||
|
: data.is_contacts()
|
||||||
|
? StoryPrivacy::Contacts
|
||||||
|
: data.is_selected_contacts()
|
||||||
|
? StoryPrivacy::SelectedContacts
|
||||||
|
: StoryPrivacy::Other;
|
||||||
const auto noForwards = data.is_noforwards();
|
const auto noForwards = data.is_noforwards();
|
||||||
auto caption = TextWithEntities{
|
auto caption = TextWithEntities{
|
||||||
data.vcaption().value_or_empty(),
|
data.vcaption().value_or_empty(),
|
||||||
|
@ -443,13 +454,13 @@ void Story::applyFields(
|
||||||
const auto viewsChanged = (_views != views)
|
const auto viewsChanged = (_views != views)
|
||||||
|| (_recentViewers != viewers);
|
|| (_recentViewers != viewers);
|
||||||
|
|
||||||
_isPublic = isPublic;
|
_privacyPublic = (privacy == StoryPrivacy::Public);
|
||||||
_closeFriends = closeFriends;
|
_privacyCloseFriends = (privacy == StoryPrivacy::CloseFriends);
|
||||||
|
_privacyContacts = (privacy == StoryPrivacy::Contacts);
|
||||||
|
_privacySelectedContacts = (privacy == StoryPrivacy::SelectedContacts);
|
||||||
_noForwards = noForwards;
|
_noForwards = noForwards;
|
||||||
_edited = edited;
|
_edited = edited;
|
||||||
_pinned = pinned;
|
_pinned = pinned;
|
||||||
_isPublic = isPublic;
|
|
||||||
_closeFriends = closeFriends;
|
|
||||||
_noForwards = noForwards;
|
_noForwards = noForwards;
|
||||||
if (viewsChanged) {
|
if (viewsChanged) {
|
||||||
_views = views;
|
_views = views;
|
||||||
|
|
|
@ -23,6 +23,14 @@ class Session;
|
||||||
class Thread;
|
class Thread;
|
||||||
class PhotoMedia;
|
class PhotoMedia;
|
||||||
|
|
||||||
|
enum class StoryPrivacy : uchar {
|
||||||
|
Public,
|
||||||
|
CloseFriends,
|
||||||
|
Contacts,
|
||||||
|
SelectedContacts,
|
||||||
|
Other,
|
||||||
|
};
|
||||||
|
|
||||||
struct StoryIdDates {
|
struct StoryIdDates {
|
||||||
StoryId id = 0;
|
StoryId id = 0;
|
||||||
TimeId date = 0;
|
TimeId date = 0;
|
||||||
|
@ -88,8 +96,7 @@ public:
|
||||||
|
|
||||||
void setPinned(bool pinned);
|
void setPinned(bool pinned);
|
||||||
[[nodiscard]] bool pinned() const;
|
[[nodiscard]] bool pinned() const;
|
||||||
[[nodiscard]] bool isPublic() const;
|
[[nodiscard]] StoryPrivacy privacy() const;
|
||||||
[[nodiscard]] bool closeFriends() const;
|
|
||||||
[[nodiscard]] bool forbidsForward() const;
|
[[nodiscard]] bool forbidsForward() const;
|
||||||
[[nodiscard]] bool edited() const;
|
[[nodiscard]] bool edited() const;
|
||||||
|
|
||||||
|
@ -138,8 +145,10 @@ private:
|
||||||
const TimeId _expires = 0;
|
const TimeId _expires = 0;
|
||||||
TimeId _lastUpdateTime = 0;
|
TimeId _lastUpdateTime = 0;
|
||||||
bool _pinned : 1 = false;
|
bool _pinned : 1 = false;
|
||||||
bool _isPublic : 1 = false;
|
bool _privacyPublic : 1 = false;
|
||||||
bool _closeFriends : 1 = false;
|
bool _privacyCloseFriends : 1 = false;
|
||||||
|
bool _privacyContacts : 1 = false;
|
||||||
|
bool _privacySelectedContacts : 1 = false;
|
||||||
bool _noForwards : 1 = false;
|
bool _noForwards : 1 = false;
|
||||||
bool _edited : 1 = false;
|
bool _edited : 1 = false;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_document.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_message_reactions.h"
|
#include "data/data_message_reactions.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -795,12 +796,16 @@ void Controller::show(
|
||||||
|
|
||||||
_captionText = story->caption();
|
_captionText = story->caption();
|
||||||
_captionFullView = nullptr;
|
_captionFullView = nullptr;
|
||||||
|
const auto document = story->document();
|
||||||
_header->show({
|
_header->show({
|
||||||
.user = user,
|
.user = user,
|
||||||
.date = story->date(),
|
.date = story->date(),
|
||||||
.fullIndex = _sliderCount ? _index : 0,
|
.fullIndex = _sliderCount ? _index : 0,
|
||||||
.fullCount = _sliderCount ? shownCount() : 0,
|
.fullCount = _sliderCount ? shownCount() : 0,
|
||||||
|
.privacy = story->privacy(),
|
||||||
.edited = story->edited(),
|
.edited = story->edited(),
|
||||||
|
.video = (document != nullptr),
|
||||||
|
.silent = (document && document->isSilentVideo()),
|
||||||
});
|
});
|
||||||
if (!changeShown(story)) {
|
if (!changeShown(story)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "ui/userpic_view.h"
|
#include "ui/userpic_view.h"
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
enum class StoryPrivacy : uchar;
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RpWidget;
|
class RpWidget;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
|
@ -24,7 +28,10 @@ struct HeaderData {
|
||||||
TimeId date = 0;
|
TimeId date = 0;
|
||||||
int fullIndex = 0;
|
int fullIndex = 0;
|
||||||
int fullCount = 0;
|
int fullCount = 0;
|
||||||
|
Data::StoryPrivacy privacy = {};
|
||||||
bool edited = false;
|
bool edited = false;
|
||||||
|
bool video = false;
|
||||||
|
bool silent = false;
|
||||||
|
|
||||||
friend inline auto operator<=>(HeaderData, HeaderData) = default;
|
friend inline auto operator<=>(HeaderData, HeaderData) = default;
|
||||||
friend inline bool operator==(HeaderData, HeaderData) = default;
|
friend inline bool operator==(HeaderData, HeaderData) = default;
|
||||||
|
|
|
@ -1530,7 +1530,7 @@ storyViews#d36760cf flags:# views_count:int recent_viewers:flags.0?Vector<long>
|
||||||
|
|
||||||
storyItemDeleted#51e6ee4f id:int = StoryItem;
|
storyItemDeleted#51e6ee4f id:int = StoryItem;
|
||||||
storyItemSkipped#ffadc913 flags:# close_friends:flags.8?true id:int date:int expire_date:int = StoryItem;
|
storyItemSkipped#ffadc913 flags:# close_friends:flags.8?true id:int date:int expire_date:int = StoryItem;
|
||||||
storyItem#562aa637 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true id:int date:int expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews = StoryItem;
|
storyItem#562aa637 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true id:int date:int expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews = StoryItem;
|
||||||
|
|
||||||
userStories#8611a200 flags:# user_id:long max_read_id:flags.0?int stories:Vector<StoryItem> = UserStories;
|
userStories#8611a200 flags:# user_id:long max_read_id:flags.0?int stories:Vector<StoryItem> = UserStories;
|
||||||
|
|
||||||
|
@ -1677,6 +1677,7 @@ account.invalidateSignInCodes#ca8ae8ba codes:Vector<string> = Bool;
|
||||||
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
||||||
users.getFullUser#b60f5918 id:InputUser = users.UserFull;
|
users.getFullUser#b60f5918 id:InputUser = users.UserFull;
|
||||||
users.setSecureValueErrors#90c894b5 id:InputUser errors:Vector<SecureValueError> = Bool;
|
users.setSecureValueErrors#90c894b5 id:InputUser errors:Vector<SecureValueError> = Bool;
|
||||||
|
users.getStoriesMaxIDs#ca1cb9ab id:Vector<InputUser> = Vector<int>;
|
||||||
|
|
||||||
contacts.getContactIDs#7adc669d hash:long = Vector<int>;
|
contacts.getContactIDs#7adc669d hash:long = Vector<int>;
|
||||||
contacts.getStatuses#c4a353ee = Vector<ContactStatus>;
|
contacts.getStatuses#c4a353ee = Vector<ContactStatus>;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user