diff --git a/include/session/client/attachment.hpp b/include/session/client/attachment.hpp index 62532c9b..3305dcc5 100644 --- a/include/session/client/attachment.hpp +++ b/include/session/client/attachment.hpp @@ -35,10 +35,6 @@ struct OutgoingAttachment { /// local file is a temporary whose name means nothing to the recipient. std::optional filename; - /// Text shown with the attachment. Distinct from the message body, which is shown as its own - /// message. - std::optional caption; - /// Marks this as a recorded voice message rather than an ordinary audio file, which clients /// present differently. bool voice_message = false; @@ -149,7 +145,6 @@ struct Attachment { std::optional content_type; std::optional filename; - std::optional caption; /// A recorded voice message rather than an ordinary audio file, which clients present /// differently. diff --git a/proto/SessionProtos.pb.cc b/proto/SessionProtos.pb.cc index e0c6bc4d..a9b6c5e8 100644 --- a/proto/SessionProtos.pb.cc +++ b/proto/SessionProtos.pb.cc @@ -299,7 +299,6 @@ PROTOBUF_CONSTEXPR AttachmentPointer::AttachmentPointer( , /*decltype(_impl_.thumbnail_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.digest_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.filename_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.caption_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.id_)*/uint64_t{0u} , /*decltype(_impl_.size_)*/0u @@ -7234,7 +7233,7 @@ class AttachmentPointer::_Internal { public: using HasBits = decltype(std::declval()._impl_._has_bits_); static void set_has_id(HasBits* has_bits) { - (*has_bits)[0] |= 128u; + (*has_bits)[0] |= 64u; } static void set_has_contenttype(HasBits* has_bits) { (*has_bits)[0] |= 1u; @@ -7243,7 +7242,7 @@ class AttachmentPointer::_Internal { (*has_bits)[0] |= 2u; } static void set_has_size(HasBits* has_bits) { - (*has_bits)[0] |= 256u; + (*has_bits)[0] |= 128u; } static void set_has_thumbnail(HasBits* has_bits) { (*has_bits)[0] |= 4u; @@ -7255,22 +7254,19 @@ class AttachmentPointer::_Internal { (*has_bits)[0] |= 16u; } static void set_has_flags(HasBits* has_bits) { - (*has_bits)[0] |= 512u; + (*has_bits)[0] |= 256u; } static void set_has_width(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; + (*has_bits)[0] |= 512u; } static void set_has_height(HasBits* has_bits) { - (*has_bits)[0] |= 2048u; - } - static void set_has_caption(HasBits* has_bits) { - (*has_bits)[0] |= 32u; + (*has_bits)[0] |= 1024u; } static void set_has_url(HasBits* has_bits) { - (*has_bits)[0] |= 64u; + (*has_bits)[0] |= 32u; } static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000080) ^ 0x00000080) != 0; + return ((has_bits[0] & 0x00000040) ^ 0x00000040) != 0; } }; @@ -7291,7 +7287,6 @@ AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) , decltype(_impl_.thumbnail_){} , decltype(_impl_.digest_){} , decltype(_impl_.filename_){} - , decltype(_impl_.caption_){} , decltype(_impl_.url_){} , decltype(_impl_.id_){} , decltype(_impl_.size_){} @@ -7340,14 +7335,6 @@ AttachmentPointer::AttachmentPointer(const AttachmentPointer& from) _this->_impl_.filename_.Set(from._internal_filename(), _this->GetArenaForAllocation()); } - _impl_.caption_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_caption()) { - _this->_impl_.caption_.Set(from._internal_caption(), - _this->GetArenaForAllocation()); - } _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.url_.Set("", GetArenaForAllocation()); @@ -7374,7 +7361,6 @@ inline void AttachmentPointer::SharedCtor( , decltype(_impl_.thumbnail_){} , decltype(_impl_.digest_){} , decltype(_impl_.filename_){} - , decltype(_impl_.caption_){} , decltype(_impl_.url_){} , decltype(_impl_.id_){uint64_t{0u}} , decltype(_impl_.size_){0u} @@ -7402,10 +7388,6 @@ inline void AttachmentPointer::SharedCtor( #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.filename_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.caption_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.url_.Set("", GetArenaForAllocation()); @@ -7428,7 +7410,6 @@ inline void AttachmentPointer::SharedDtor() { _impl_.thumbnail_.Destroy(); _impl_.digest_.Destroy(); _impl_.filename_.Destroy(); - _impl_.caption_.Destroy(); _impl_.url_.Destroy(); } @@ -7443,7 +7424,7 @@ void AttachmentPointer::Clear() { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { _impl_.contenttype_.ClearNonDefaultToEmpty(); } @@ -7460,17 +7441,18 @@ void AttachmentPointer::Clear() { _impl_.filename_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000020u) { - _impl_.caption_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000040u) { _impl_.url_.ClearNonDefaultToEmpty(); } } - _impl_.id_ = uint64_t{0u}; - if (cached_has_bits & 0x00000f00u) { - ::memset(&_impl_.size_, 0, static_cast( + if (cached_has_bits & 0x000000c0u) { + ::memset(&_impl_.id_, 0, static_cast( + reinterpret_cast(&_impl_.size_) - + reinterpret_cast(&_impl_.id_)) + sizeof(_impl_.size_)); + } + if (cached_has_bits & 0x00000700u) { + ::memset(&_impl_.flags_, 0, static_cast( reinterpret_cast(&_impl_.height_) - - reinterpret_cast(&_impl_.size_)) + sizeof(_impl_.height_)); + reinterpret_cast(&_impl_.flags_)) + sizeof(_impl_.height_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); @@ -7573,15 +7555,6 @@ const char* AttachmentPointer::_InternalParse(const char* ptr, ::_pbi::ParseCont } else goto handle_unusual; continue; - // optional string caption = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 90)) { - auto str = _internal_mutable_caption(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - } else - goto handle_unusual; - continue; // optional string url = 101; case 101: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { @@ -7623,7 +7596,7 @@ uint8_t* AttachmentPointer::_InternalSerialize( cached_has_bits = _impl_._has_bits_[0]; // required fixed64 id = 1; - if (cached_has_bits & 0x00000080u) { + if (cached_has_bits & 0x00000040u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFixed64ToArray(1, this->_internal_id(), target); } @@ -7641,7 +7614,7 @@ uint8_t* AttachmentPointer::_InternalSerialize( } // optional uint32 size = 4; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000080u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_size(), target); } @@ -7665,31 +7638,25 @@ uint8_t* AttachmentPointer::_InternalSerialize( } // optional uint32 flags = 8; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000100u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_flags(), target); } // optional uint32 width = 9; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000200u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(9, this->_internal_width(), target); } // optional uint32 height = 10; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(10, this->_internal_height(), target); } - // optional string caption = 11; - if (cached_has_bits & 0x00000020u) { - target = stream->WriteStringMaybeAliased( - 11, this->_internal_caption(), target); - } - // optional string url = 101; - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000020u) { target = stream->WriteStringMaybeAliased( 101, this->_internal_url(), target); } @@ -7715,7 +7682,7 @@ size_t AttachmentPointer::ByteSizeLong() const { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x0000003fu) { // optional string contentType = 2; if (cached_has_bits & 0x00000001u) { total_size += 1 + @@ -7751,39 +7718,32 @@ size_t AttachmentPointer::ByteSizeLong() const { this->_internal_filename()); } - // optional string caption = 11; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_caption()); - } - // optional string url = 101; - if (cached_has_bits & 0x00000040u) { + if (cached_has_bits & 0x00000020u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_url()); } } - if (cached_has_bits & 0x00000f00u) { - // optional uint32 size = 4; - if (cached_has_bits & 0x00000100u) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_size()); - } + // optional uint32 size = 4; + if (cached_has_bits & 0x00000080u) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_size()); + } + if (cached_has_bits & 0x00000700u) { // optional uint32 flags = 8; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000100u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_flags()); } // optional uint32 width = 9; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000200u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_width()); } // optional uint32 height = 10; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00000400u) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_height()); } @@ -7827,27 +7787,24 @@ void AttachmentPointer::MergeFrom(const AttachmentPointer& from) { _this->_internal_set_filename(from._internal_filename()); } if (cached_has_bits & 0x00000020u) { - _this->_internal_set_caption(from._internal_caption()); + _this->_internal_set_url(from._internal_url()); } if (cached_has_bits & 0x00000040u) { - _this->_internal_set_url(from._internal_url()); + _this->_impl_.id_ = from._impl_.id_; } if (cached_has_bits & 0x00000080u) { - _this->_impl_.id_ = from._impl_.id_; + _this->_impl_.size_ = from._impl_.size_; } _this->_impl_._has_bits_[0] |= cached_has_bits; } - if (cached_has_bits & 0x00000f00u) { + if (cached_has_bits & 0x00000700u) { if (cached_has_bits & 0x00000100u) { - _this->_impl_.size_ = from._impl_.size_; - } - if (cached_has_bits & 0x00000200u) { _this->_impl_.flags_ = from._impl_.flags_; } - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000200u) { _this->_impl_.width_ = from._impl_.width_; } - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00000400u) { _this->_impl_.height_ = from._impl_.height_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -7893,10 +7850,6 @@ void AttachmentPointer::InternalSwap(AttachmentPointer* other) { &_impl_.filename_, lhs_arena, &other->_impl_.filename_, rhs_arena ); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.caption_, lhs_arena, - &other->_impl_.caption_, rhs_arena - ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.url_, lhs_arena, &other->_impl_.url_, rhs_arena diff --git a/proto/SessionProtos.pb.h b/proto/SessionProtos.pb.h index 2a539c83..dffa7c34 100644 --- a/proto/SessionProtos.pb.h +++ b/proto/SessionProtos.pb.h @@ -4141,7 +4141,6 @@ class AttachmentPointer final : kThumbnailFieldNumber = 5, kDigestFieldNumber = 6, kFileNameFieldNumber = 7, - kCaptionFieldNumber = 11, kUrlFieldNumber = 101, kIdFieldNumber = 1, kSizeFieldNumber = 4, @@ -4239,24 +4238,6 @@ class AttachmentPointer final : std::string* _internal_mutable_filename(); public: - // optional string caption = 11; - bool has_caption() const; - private: - bool _internal_has_caption() const; - public: - void clear_caption(); - const std::string& caption() const; - template - void set_caption(ArgT0&& arg0, ArgT... args); - std::string* mutable_caption(); - PROTOBUF_NODISCARD std::string* release_caption(); - void set_allocated_caption(std::string* caption); - private: - const std::string& _internal_caption() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_caption(const std::string& value); - std::string* _internal_mutable_caption(); - public: - // optional string url = 101; bool has_url() const; private: @@ -4355,7 +4336,6 @@ class AttachmentPointer final : ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr thumbnail_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr digest_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr filename_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr caption_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; uint64_t id_; uint32_t size_; @@ -11030,7 +11010,7 @@ ReceiptMessage::mutable_msgid() { // required fixed64 id = 1; inline bool AttachmentPointer::_internal_has_id() const { - bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; return value; } inline bool AttachmentPointer::has_id() const { @@ -11038,7 +11018,7 @@ inline bool AttachmentPointer::has_id() const { } inline void AttachmentPointer::clear_id() { _impl_.id_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000040u; } inline uint64_t AttachmentPointer::_internal_id() const { return _impl_.id_; @@ -11048,7 +11028,7 @@ inline uint64_t AttachmentPointer::id() const { return _internal_id(); } inline void AttachmentPointer::_internal_set_id(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000040u; _impl_.id_ = value; } inline void AttachmentPointer::set_id(uint64_t value) { @@ -11194,7 +11174,7 @@ inline void AttachmentPointer::set_allocated_key(std::string* key) { // optional uint32 size = 4; inline bool AttachmentPointer::_internal_has_size() const { - bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; return value; } inline bool AttachmentPointer::has_size() const { @@ -11202,7 +11182,7 @@ inline bool AttachmentPointer::has_size() const { } inline void AttachmentPointer::clear_size() { _impl_.size_ = 0u; - _impl_._has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000080u; } inline uint32_t AttachmentPointer::_internal_size() const { return _impl_.size_; @@ -11212,7 +11192,7 @@ inline uint32_t AttachmentPointer::size() const { return _internal_size(); } inline void AttachmentPointer::_internal_set_size(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000080u; _impl_.size_ = value; } inline void AttachmentPointer::set_size(uint32_t value) { @@ -11426,7 +11406,7 @@ inline void AttachmentPointer::set_allocated_filename(std::string* filename) { // optional uint32 flags = 8; inline bool AttachmentPointer::_internal_has_flags() const { - bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } inline bool AttachmentPointer::has_flags() const { @@ -11434,7 +11414,7 @@ inline bool AttachmentPointer::has_flags() const { } inline void AttachmentPointer::clear_flags() { _impl_.flags_ = 0u; - _impl_._has_bits_[0] &= ~0x00000200u; + _impl_._has_bits_[0] &= ~0x00000100u; } inline uint32_t AttachmentPointer::_internal_flags() const { return _impl_.flags_; @@ -11444,7 +11424,7 @@ inline uint32_t AttachmentPointer::flags() const { return _internal_flags(); } inline void AttachmentPointer::_internal_set_flags(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000200u; + _impl_._has_bits_[0] |= 0x00000100u; _impl_.flags_ = value; } inline void AttachmentPointer::set_flags(uint32_t value) { @@ -11454,7 +11434,7 @@ inline void AttachmentPointer::set_flags(uint32_t value) { // optional uint32 width = 9; inline bool AttachmentPointer::_internal_has_width() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } inline bool AttachmentPointer::has_width() const { @@ -11462,7 +11442,7 @@ inline bool AttachmentPointer::has_width() const { } inline void AttachmentPointer::clear_width() { _impl_.width_ = 0u; - _impl_._has_bits_[0] &= ~0x00000400u; + _impl_._has_bits_[0] &= ~0x00000200u; } inline uint32_t AttachmentPointer::_internal_width() const { return _impl_.width_; @@ -11472,7 +11452,7 @@ inline uint32_t AttachmentPointer::width() const { return _internal_width(); } inline void AttachmentPointer::_internal_set_width(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000400u; + _impl_._has_bits_[0] |= 0x00000200u; _impl_.width_ = value; } inline void AttachmentPointer::set_width(uint32_t value) { @@ -11482,7 +11462,7 @@ inline void AttachmentPointer::set_width(uint32_t value) { // optional uint32 height = 10; inline bool AttachmentPointer::_internal_has_height() const { - bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool AttachmentPointer::has_height() const { @@ -11490,7 +11470,7 @@ inline bool AttachmentPointer::has_height() const { } inline void AttachmentPointer::clear_height() { _impl_.height_ = 0u; - _impl_._has_bits_[0] &= ~0x00000800u; + _impl_._has_bits_[0] &= ~0x00000400u; } inline uint32_t AttachmentPointer::_internal_height() const { return _impl_.height_; @@ -11500,7 +11480,7 @@ inline uint32_t AttachmentPointer::height() const { return _internal_height(); } inline void AttachmentPointer::_internal_set_height(uint32_t value) { - _impl_._has_bits_[0] |= 0x00000800u; + _impl_._has_bits_[0] |= 0x00000400u; _impl_.height_ = value; } inline void AttachmentPointer::set_height(uint32_t value) { @@ -11508,77 +11488,9 @@ inline void AttachmentPointer::set_height(uint32_t value) { // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.height) } -// optional string caption = 11; -inline bool AttachmentPointer::_internal_has_caption() const { - bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; - return value; -} -inline bool AttachmentPointer::has_caption() const { - return _internal_has_caption(); -} -inline void AttachmentPointer::clear_caption() { - _impl_.caption_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000020u; -} -inline const std::string& AttachmentPointer::caption() const { - // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.caption) - return _internal_caption(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void AttachmentPointer::set_caption(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.caption_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.caption) -} -inline std::string* AttachmentPointer::mutable_caption() { - std::string* _s = _internal_mutable_caption(); - // @@protoc_insertion_point(field_mutable:SessionProtos.AttachmentPointer.caption) - return _s; -} -inline const std::string& AttachmentPointer::_internal_caption() const { - return _impl_.caption_.Get(); -} -inline void AttachmentPointer::_internal_set_caption(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000020u; - _impl_.caption_.Set(value, GetArenaForAllocation()); -} -inline std::string* AttachmentPointer::_internal_mutable_caption() { - _impl_._has_bits_[0] |= 0x00000020u; - return _impl_.caption_.Mutable(GetArenaForAllocation()); -} -inline std::string* AttachmentPointer::release_caption() { - // @@protoc_insertion_point(field_release:SessionProtos.AttachmentPointer.caption) - if (!_internal_has_caption()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000020u; - auto* p = _impl_.caption_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.caption_.IsDefault()) { - _impl_.caption_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void AttachmentPointer::set_allocated_caption(std::string* caption) { - if (caption != nullptr) { - _impl_._has_bits_[0] |= 0x00000020u; - } else { - _impl_._has_bits_[0] &= ~0x00000020u; - } - _impl_.caption_.SetAllocated(caption, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.caption_.IsDefault()) { - _impl_.caption_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:SessionProtos.AttachmentPointer.caption) -} - // optional string url = 101; inline bool AttachmentPointer::_internal_has_url() const { - bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } inline bool AttachmentPointer::has_url() const { @@ -11586,7 +11498,7 @@ inline bool AttachmentPointer::has_url() const { } inline void AttachmentPointer::clear_url() { _impl_.url_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000020u; } inline const std::string& AttachmentPointer::url() const { // @@protoc_insertion_point(field_get:SessionProtos.AttachmentPointer.url) @@ -11595,7 +11507,7 @@ inline const std::string& AttachmentPointer::url() const { template inline PROTOBUF_ALWAYS_INLINE void AttachmentPointer::set_url(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000020u; _impl_.url_.Set(static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:SessionProtos.AttachmentPointer.url) } @@ -11608,11 +11520,11 @@ inline const std::string& AttachmentPointer::_internal_url() const { return _impl_.url_.Get(); } inline void AttachmentPointer::_internal_set_url(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000020u; _impl_.url_.Set(value, GetArenaForAllocation()); } inline std::string* AttachmentPointer::_internal_mutable_url() { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000020u; return _impl_.url_.Mutable(GetArenaForAllocation()); } inline std::string* AttachmentPointer::release_url() { @@ -11620,7 +11532,7 @@ inline std::string* AttachmentPointer::release_url() { if (!_internal_has_url()) { return nullptr; } - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000020u; auto* p = _impl_.url_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING if (_impl_.url_.IsDefault()) { @@ -11631,9 +11543,9 @@ inline std::string* AttachmentPointer::release_url() { } inline void AttachmentPointer::set_allocated_url(std::string* url) { if (url != nullptr) { - _impl_._has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _impl_._has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000020u; } _impl_.url_.SetAllocated(url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING diff --git a/proto/SessionProtos.proto b/proto/SessionProtos.proto index 7694c52f..76a89512 100644 --- a/proto/SessionProtos.proto +++ b/proto/SessionProtos.proto @@ -354,6 +354,9 @@ message AttachmentPointer { VOICE_MESSAGE = 1; } + reserved 11; + reserved "caption"; + // @required required fixed64 id = 1; optional string contentType = 2; @@ -365,7 +368,6 @@ message AttachmentPointer { optional uint32 flags = 8; optional uint32 width = 9; optional uint32 height = 10; - optional string caption = 11; optional string url = 101; } diff --git a/proto/debug_print.cpp b/proto/debug_print.cpp index 1c5108e7..dbe291de 100644 --- a/proto/debug_print.cpp +++ b/proto/debug_print.cpp @@ -425,8 +425,6 @@ namespace { line(out, depth, "width", 9, fmt::format("{}", m.width())); if (m.has_height()) line(out, depth, "height", 10, fmt::format("{}", m.height())); - if (m.has_caption()) - line(out, depth, "caption", 11, quote(m.caption())); if (m.has_url()) line(out, depth, "url", 101, quote(m.url())); unknown(out, depth, m.unknown_fields()); diff --git a/src/client/client.cpp b/src/client/client.cpp index 44265709..94819585 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1461,8 +1461,8 @@ static void load_preview_attachments( // A row per attachment rather than an aggregate, because the names are wanted individually; the // three summary fields are then folded from the same rows instead of being asked for again. - // Only the three columns a preview uses, so a list does not carry the sizes, captions and urls - // that a message view reads. + // Only the three columns a preview uses, so a list does not carry the sizes and urls that a + // message view reads. // // `substr(...) = 'image/'` rather than `LIKE 'image/%'` because LIKE is ASCII-case-insensitive // in SQLite while `gallery_viewable`'s `starts_with` is not, and the two deciding differently @@ -3208,7 +3208,7 @@ void Client::_load_attachments(sqlite::Connection& c, std::vector& msgs auto st = c.prepared_st( R"( - SELECT message, idx, content_type, filename, caption, flags, width, height, + SELECT message, idx, content_type, filename, flags, width, height, size, url, unavailable, cached, saved_at FROM message_attachments WHERE message IN ({}) ORDER BY message, idx )"_format(sqlite::placeholders(msgs.size()))); @@ -3221,7 +3221,6 @@ void Client::_load_attachments(sqlite::Connection& c, std::vector& msgs idx, ctype, fname, - caption, flags, width, height, @@ -3235,7 +3234,6 @@ void Client::_load_attachments(sqlite::Connection& c, std::vector& msgs int64_t, std::optional, std::optional, - std::optional, int, std::optional, std::optional, @@ -3253,7 +3251,6 @@ void Client::_load_attachments(sqlite::Connection& c, std::vector& msgs .index = static_cast(idx), .content_type = std::move(ctype), .filename = std::move(fname), - .caption = std::move(caption), .voice_message = (flags & ATTACHMENT_FLAG_VOICE_MESSAGE) != 0, .width = width ? std::optional{static_cast(*width)} : std::nullopt, .height = height ? std::optional{static_cast(*height)} : std::nullopt, @@ -3896,15 +3893,14 @@ int64_t Client::_send_message( c.prepared_exec( R"( INSERT INTO message_attachments - (message, idx, path, content_type, filename, caption, flags, width, height) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + (message, idx, path, content_type, filename, flags, width, height) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) )", client_id, static_cast(i), a.path.string(), a.content_type ? *a.content_type : infer_content_type(a.path), a.filename ? a.filename : std::optional{a.path.filename().string()}, - a.caption, a.voice_message ? ATTACHMENT_FLAG_VOICE_MESSAGE : 0, a.width ? std::optional{*a.width} : std::nullopt, a.height ? std::optional{*a.height} : std::nullopt); @@ -5067,19 +5063,18 @@ void Client::_finish_attachment_send(int64_t client_id) { .timestamp = from_epoch_ms(*reply_ts), .msgid = reply_msgid}); - for (auto&& [url, key, size, ctype, fname, caption, flags, width, height] : + for (auto&& [url, key, size, ctype, fname, flags, width, height] : c.prepared_results< std::string, sqlite::blobn<32>, int64_t, std::optional, std::optional, - std::optional, int, std::optional, std::optional>( R"( - SELECT url, key, size, content_type, filename, caption, flags, width, height + SELECT url, key, size, content_type, filename, flags, width, height FROM message_attachments WHERE message = ? ORDER BY idx )", client_id)) { @@ -5109,8 +5104,6 @@ void Client::_finish_attachment_send(int64_t client_id) { attach->set_contenttype(*ctype); if (fname) attach->set_filename(*fname); - if (caption) - attach->set_caption(*caption); if (flags != 0) attach->set_flags(static_cast(flags)); if (width) @@ -5221,9 +5214,9 @@ static std::vector store_incoming_attachments( c.prepared_exec( R"( INSERT INTO message_attachments - (message, idx, url, key, digest, size, content_type, filename, caption, flags, + (message, idx, url, key, digest, size, content_type, filename, flags, width, height, cached) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) )", message_id, static_cast(i), @@ -5233,7 +5226,6 @@ static std::vector store_incoming_attachments( ptr.has_size() ? std::optional{ptr.size()} : std::nullopt, ptr.has_contenttype() ? std::optional{ptr.contenttype()} : std::nullopt, ptr.has_filename() ? std::optional{ptr.filename()} : std::nullopt, - ptr.has_caption() ? std::optional{ptr.caption()} : std::nullopt, static_cast(ptr.flags()), ptr.has_width() ? std::optional{ptr.width()} : std::nullopt, ptr.has_height() ? std::optional{ptr.height()} : std::nullopt, diff --git a/src/client/schema/006_drop_attachment_caption.sql b/src/client/schema/006_drop_attachment_caption.sql new file mode 100644 index 00000000..8de793ac --- /dev/null +++ b/src/client/schema/006_drop_attachment_caption.sql @@ -0,0 +1 @@ +ALTER TABLE message_attachments DROP COLUMN caption; diff --git a/src/client/schema/full_schema.sql b/src/client/schema/full_schema.sql index 39f4521a..6ef563a0 100644 --- a/src/client/schema/full_schema.sql +++ b/src/client/schema/full_schema.sql @@ -378,7 +378,6 @@ CREATE TABLE message_attachments ( -- null. On an incoming attachment these are the sender's claims and nothing more. content_type TEXT, filename TEXT, - caption TEXT, flags INTEGER NOT NULL DEFAULT 0, width INTEGER, height INTEGER, diff --git a/tests/test_client/attachments.cpp b/tests/test_client/attachments.cpp index 191647be..5dd3a4b7 100644 --- a/tests/test_client/attachments.cpp +++ b/tests/test_client/attachments.cpp @@ -48,7 +48,6 @@ TEST_CASE("Client: an arriving message records the files it names", "[client][at a->set_size(99); a->set_contenttype("application/pdf"); a->set_filename("invoice.pdf"); - a->set_caption("last month"); a->set_flags(1); }); // A pointer with no url at all: unfetchable, but still one of three files the @@ -74,7 +73,6 @@ TEST_CASE("Client: an arriving message records the files it names", "[client][at // Always true on an incoming attachment: the file server is where it came from. CHECK(m.attachments[0].uploaded); - CHECK(m.attachments[1].caption == "last month"); CHECK(m.attachments[1].voice_message); CHECK(m.attachments[1].uploaded); @@ -107,7 +105,7 @@ TEST_CASE("Client: a message reports the attachments it carries", "[client][send auto id = c->send_message( ConversationId::dm(me), {.attachments = - {OutgoingAttachment{.path = photo, .caption = "on the beach"}, + {OutgoingAttachment{.path = photo}, OutgoingAttachment{ .path = doc, .content_type = "application/x-my-own", .width = 4}, OutgoingAttachment{.path = mystery, .voice_message = true}}}, @@ -129,7 +127,6 @@ TEST_CASE("Client: a message reports the attachments it carries", "[client][send // Inferred from the last extension, case-insensitively, when the caller named none... CHECK(msg->attachments[0].content_type == "image/png"); CHECK(msg->attachments[0].filename == "holiday.snap.PNG"); - CHECK(msg->attachments[0].caption == "on the beach"); CHECK_FALSE(msg->attachments[0].voice_message); // ...and never overriding one the caller did name.