presence.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) 2021 Tulir Asokan
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. package types
  7. import (
  8. "fmt"
  9. )
  10. type Presence string
  11. const (
  12. PresenceAvailable Presence = "available"
  13. PresenceUnavailable Presence = "unavailable"
  14. )
  15. type ChatPresence string
  16. const (
  17. ChatPresenceComposing ChatPresence = "composing"
  18. ChatPresencePaused ChatPresence = "paused"
  19. )
  20. type ChatPresenceMedia string
  21. const (
  22. ChatPresenceMediaText ChatPresenceMedia = ""
  23. ChatPresenceMediaAudio ChatPresenceMedia = "audio"
  24. )
  25. // ReceiptType represents the type of a Receipt event.
  26. type ReceiptType string
  27. const (
  28. // ReceiptTypeDelivered means the message was delivered to the device (but the user might not have noticed).
  29. ReceiptTypeDelivered ReceiptType = ""
  30. // ReceiptTypeSender is sent by your other devices when a message you sent is delivered to them.
  31. ReceiptTypeSender ReceiptType = "sender"
  32. // ReceiptTypeRetry means the message was delivered to the device, but decrypting the message failed.
  33. ReceiptTypeRetry ReceiptType = "retry"
  34. // ReceiptTypeRead means the user opened the chat and saw the message.
  35. ReceiptTypeRead ReceiptType = "read"
  36. // ReceiptTypeReadSelf means the current user read a message from a different device, and has read receipts disabled in privacy settings.
  37. ReceiptTypeReadSelf ReceiptType = "read-self"
  38. // ReceiptTypePlayed means the user opened a view-once media message.
  39. //
  40. // This is dispatched for both incoming and outgoing messages when played. If the current user opened the media,
  41. // it means the media should be removed from all devices. If a recipient opened the media, it's just a notification
  42. // for the sender that the media was viewed.
  43. ReceiptTypePlayed ReceiptType = "played"
  44. // ReceiptTypePlayedSelf probably means the current user opened a view-once media message from a different device,
  45. // and has read receipts disabled in privacy settings.
  46. ReceiptTypePlayedSelf ReceiptType = "played-self"
  47. ReceiptTypeServerError ReceiptType = "server-error"
  48. ReceiptTypeInactive ReceiptType = "inactive"
  49. ReceiptTypePeerMsg ReceiptType = "peer_msg"
  50. ReceiptTypeHistorySync ReceiptType = "hist_sync"
  51. )
  52. // GoString returns the name of the Go constant for the ReceiptType value.
  53. func (rt ReceiptType) GoString() string {
  54. switch rt {
  55. case ReceiptTypeRead:
  56. return "types.ReceiptTypeRead"
  57. case ReceiptTypeReadSelf:
  58. return "types.ReceiptTypeReadSelf"
  59. case ReceiptTypeDelivered:
  60. return "types.ReceiptTypeDelivered"
  61. case ReceiptTypePlayed:
  62. return "types.ReceiptTypePlayed"
  63. default:
  64. return fmt.Sprintf("types.ReceiptType(%#v)", string(rt))
  65. }
  66. }