user.go 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // Copyright (c) 2022 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. "time"
  9. "git.bobomao.top/joey/testwh/proto/waVnameCert"
  10. )
  11. // VerifiedName contains verified WhatsApp business details.
  12. type VerifiedName struct {
  13. Certificate *waVnameCert.VerifiedNameCertificate
  14. Details *waVnameCert.VerifiedNameCertificate_Details
  15. }
  16. // UserInfo contains info about a WhatsApp user.
  17. type UserInfo struct {
  18. VerifiedName *VerifiedName
  19. Status string
  20. PictureID string
  21. Devices []JID
  22. LID JID
  23. }
  24. type BotListInfo struct {
  25. BotJID JID
  26. PersonaID string
  27. }
  28. type BotProfileInfo struct {
  29. JID JID
  30. Name string
  31. Attributes string
  32. Description string
  33. Category string
  34. IsDefault bool
  35. Prompts []string
  36. PersonaID string
  37. Commands []BotProfileCommand
  38. CommandsDescription string
  39. }
  40. type BotProfileCommand struct {
  41. Name string
  42. Description string
  43. }
  44. // ProfilePictureInfo contains the ID and URL for a WhatsApp user's profile picture or group's photo.
  45. type ProfilePictureInfo struct {
  46. URL string `json:"url"` // The full URL for the image, can be downloaded with a simple HTTP request.
  47. ID string `json:"id"` // The ID of the image. This is the same as UserInfo.PictureID.
  48. Type string `json:"type"` // The type of image. Known types include "image" (full res) and "preview" (thumbnail).
  49. DirectPath string `json:"direct_path"` // The path to the image, probably not very useful
  50. Hash []byte `json:"hash"` // Some kind of hash (format is unknown)
  51. }
  52. // ContactInfo contains the cached names of a WhatsApp user.
  53. type ContactInfo struct {
  54. Found bool
  55. FirstName string
  56. FullName string
  57. PushName string
  58. BusinessName string
  59. // Only for LID members encountered in groups, the phone number in the form "+1∙∙∙∙∙∙∙∙80"
  60. RedactedPhone string
  61. }
  62. // LocalChatSettings contains the cached local settings for a chat.
  63. type LocalChatSettings struct {
  64. Found bool
  65. MutedUntil time.Time
  66. Pinned bool
  67. Archived bool
  68. }
  69. // IsOnWhatsAppResponse contains information received in response to checking if a phone number is on WhatsApp.
  70. type IsOnWhatsAppResponse struct {
  71. Query string // The query string used
  72. JID JID // The canonical user ID
  73. IsIn bool // Whether the phone is registered or not.
  74. VerifiedName *VerifiedName // If the phone is a business, the verified business details.
  75. }
  76. // BusinessMessageLinkTarget contains the info that is found using a business message link (see Client.ResolveBusinessMessageLink)
  77. type BusinessMessageLinkTarget struct {
  78. JID JID // The JID of the business.
  79. PushName string // The notify / push name of the business.
  80. VerifiedName string // The verified business name.
  81. IsSigned bool // Some boolean, seems to be true?
  82. VerifiedLevel string // I guess the level of verification, starting from "unknown".
  83. Message string // The message that WhatsApp clients will pre-fill in the input box when clicking the link.
  84. }
  85. // ContactQRLinkTarget contains the info that is found using a contact QR link (see Client.ResolveContactQRLink)
  86. type ContactQRLinkTarget struct {
  87. JID JID // The JID of the user.
  88. Type string // Might always be "contact".
  89. PushName string // The notify / push name of the user.
  90. }
  91. // PrivacySetting is an individual setting value in the user's privacy settings.
  92. type PrivacySetting string
  93. // Possible privacy setting values.
  94. const (
  95. PrivacySettingUndefined PrivacySetting = ""
  96. PrivacySettingAll PrivacySetting = "all"
  97. PrivacySettingContacts PrivacySetting = "contacts"
  98. PrivacySettingContactBlacklist PrivacySetting = "contact_blacklist"
  99. PrivacySettingMatchLastSeen PrivacySetting = "match_last_seen"
  100. PrivacySettingKnown PrivacySetting = "known"
  101. PrivacySettingNone PrivacySetting = "none"
  102. )
  103. // PrivacySettingType is the type of privacy setting.
  104. type PrivacySettingType string
  105. const (
  106. PrivacySettingTypeGroupAdd PrivacySettingType = "groupadd" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  107. PrivacySettingTypeLastSeen PrivacySettingType = "last" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  108. PrivacySettingTypeStatus PrivacySettingType = "status" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  109. PrivacySettingTypeProfile PrivacySettingType = "profile" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  110. PrivacySettingTypeReadReceipts PrivacySettingType = "readreceipts" // Valid values: PrivacySettingAll, PrivacySettingNone
  111. PrivacySettingTypeOnline PrivacySettingType = "online" // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen
  112. PrivacySettingTypeCallAdd PrivacySettingType = "calladd" // Valid values: PrivacySettingAll, PrivacySettingKnown
  113. )
  114. // PrivacySettings contains the user's privacy settings.
  115. type PrivacySettings struct {
  116. GroupAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  117. LastSeen PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  118. Status PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  119. Profile PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  120. ReadReceipts PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingNone
  121. CallAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingKnown
  122. Online PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen
  123. }
  124. // StatusPrivacyType is the type of list in StatusPrivacy.
  125. type StatusPrivacyType string
  126. const (
  127. // StatusPrivacyTypeContacts means statuses are sent to all contacts.
  128. StatusPrivacyTypeContacts StatusPrivacyType = "contacts"
  129. // StatusPrivacyTypeBlacklist means statuses are sent to all contacts, except the ones on the list.
  130. StatusPrivacyTypeBlacklist StatusPrivacyType = "blacklist"
  131. // StatusPrivacyTypeWhitelist means statuses are only sent to users on the list.
  132. StatusPrivacyTypeWhitelist StatusPrivacyType = "whitelist"
  133. )
  134. // StatusPrivacy contains the settings for who to send status messages to by default.
  135. type StatusPrivacy struct {
  136. Type StatusPrivacyType
  137. List []JID
  138. IsDefault bool
  139. }
  140. // Blocklist contains the user's current list of blocked users.
  141. type Blocklist struct {
  142. DHash string // TODO is this just a timestamp?
  143. JIDs []JID
  144. }
  145. // BusinessHoursConfig contains business operating hours of a WhatsApp business.
  146. type BusinessHoursConfig struct {
  147. DayOfWeek string
  148. Mode string
  149. OpenTime string
  150. CloseTime string
  151. }
  152. // Category contains a WhatsApp business category.
  153. type Category struct {
  154. ID string
  155. Name string
  156. }
  157. // BusinessProfile contains the profile information of a WhatsApp business.
  158. type BusinessProfile struct {
  159. JID JID
  160. Address string
  161. Email string
  162. Categories []Category
  163. ProfileOptions map[string]string
  164. BusinessHoursTimeZone string
  165. BusinessHours []BusinessHoursConfig
  166. }