Skip to content

Display service messages, fixes and cleanups

Matti Viljanen requested to merge display-service-messages into main

I played FIXME routette and landed on service messages. Long story short, this MR spiraled into QML layout madness and Rust model cleanup. All very related, however. I'd call it 70% business and 30% QoL.

  • Always save expiresIn data for service messages
    • Never delete/expire service messages though
    • → Trivial to generate translated expiry change messages!
    • → Don't save any text to service messages, not needed any more (maybe later as JSON?)
  • Update ServiceMessageDelegate logic to work upon Message.flags Message.messageType
    • Currently uses 1 << 8 for "custom" purposes, but the protocol only uses up to 1 << 2 and these are never sent
      • Use message.message_type column for any and all "custom purposes"
      • message.flags is only relevant when sending and receiving, not for formatting
    • Probably has a lot of extra messages still, let's clean them up when we get there (missed/made audio/video calls from/to rcpt, anyone?)
    • Buncha new translation strings along the way
  • Update MessagesView so it shows ServiceMessageDelegate when a service message is detected (flags > 0) message_type != null
    • Also fix the logic "a bit", i.e. use switch-case instead of if-elif-elif-elif-elif...
  • For CoverPage simply display a service message placeholder text so we don't have to instantiate ServiceMessageDelegates there too

And then the cleanup part:

  • Remove all Message, Recipient and Group related getters from Session, except ID's, and move a few
  • Use Message, Recipient and Group objects in QML instead
  • More cleanup may be possible between Group/Message/Recipient and Group
  • Helps mitigating property pollution, increases logic and order
  • Should prepare things for Qt model system rewrite

Other remarks:

  • SessionDelegate was touched quite a bit, but it's quite simple still
  • ServiceMessageDelegate was reworked to take the same Message model data
    • Rust doesn't have to get involved - it's all in the view now
  • GroupInfoPage got almost fully rewritten to fix a layout issue
    • No more dynamic elements to headers... Height hack fixed the issue.
    • Lots of minor layout how-to changes (more anchors use, basically)
    • Recipient list item now spreads correctly to screen edges

While testing I also found and fixed this:

  • Sharing a file to Whisperfish worked, but sending it as attachment didn't (ShareDestinationV1/V2) (oversight from !570 (merged))
    • Next: Supporting multiple attachments at once is now a trivial change (requires plugin updates too)
  • Don't auto-fill the image/video file name to the chat text input field (we now deliver the filename properly)
  • Prevent QML log spam when recipient has missing fields or session has no message (no lastMessage)

AFAICT this MR is complete and fully functional, but because it's so invasive, I'm going to give it a little more time on my daily driver.

  • Run the branch to make sure there are no issues
  • Sending messages in expiring chat don't expire for self
  • Check CoverPage for flags → messageType
  • Make sure outgoing "service" messages are flagged and typed correctly
  • Verify/update the message expiry database index
  • Update snake_case strings to QML
  • Mimic Aci/Pni enum <--> database design
  • Fix incoming messages getting typed as Unsupported
  • Restore RecipientProfilePage debug menu items' functionality
  • Insert "fake" service messages when user does a debug action
  • Decide what to do with sticker (and payment) types (keep as (service) message types, split the types into two, something else?)
  • Check for more service message migrations
  • Review migration string criteria, possibly add more
  • Try to figure out something better for expiry timer time formatting w.r.t. locale
Edited by Matti Viljanen

Merge request reports