user.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. Status string
  75. Devices []JID
  76. PictureID string
  77. VerifiedName *VerifiedName // If the phone is a business, the verified business details.
  78. }
  79. // BusinessMessageLinkTarget contains the info that is found using a business message link (see Client.ResolveBusinessMessageLink)
  80. type BusinessMessageLinkTarget struct {
  81. JID JID // The JID of the business.
  82. PushName string // The notify / push name of the business.
  83. VerifiedName string // The verified business name.
  84. IsSigned bool // Some boolean, seems to be true?
  85. VerifiedLevel string // I guess the level of verification, starting from "unknown".
  86. Message string // The message that WhatsApp clients will pre-fill in the input box when clicking the link.
  87. }
  88. // ContactQRLinkTarget contains the info that is found using a contact QR link (see Client.ResolveContactQRLink)
  89. type ContactQRLinkTarget struct {
  90. JID JID // The JID of the user.
  91. Type string // Might always be "contact".
  92. PushName string // The notify / push name of the user.
  93. }
  94. // PrivacySetting is an individual setting value in the user's privacy settings.
  95. type PrivacySetting string
  96. // Possible privacy setting values.
  97. const (
  98. PrivacySettingUndefined PrivacySetting = ""
  99. PrivacySettingAll PrivacySetting = "all"
  100. PrivacySettingContacts PrivacySetting = "contacts"
  101. PrivacySettingContactBlacklist PrivacySetting = "contact_blacklist"
  102. PrivacySettingMatchLastSeen PrivacySetting = "match_last_seen"
  103. PrivacySettingKnown PrivacySetting = "known"
  104. PrivacySettingNone PrivacySetting = "none"
  105. )
  106. // PrivacySettingType is the type of privacy setting.
  107. type PrivacySettingType string
  108. const (
  109. PrivacySettingTypeGroupAdd PrivacySettingType = "groupadd" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  110. PrivacySettingTypeLastSeen PrivacySettingType = "last" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  111. PrivacySettingTypeStatus PrivacySettingType = "status" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  112. PrivacySettingTypeProfile PrivacySettingType = "profile" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  113. PrivacySettingTypeReadReceipts PrivacySettingType = "readreceipts" // Valid values: PrivacySettingAll, PrivacySettingNone
  114. PrivacySettingTypeOnline PrivacySettingType = "online" // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen
  115. PrivacySettingTypeCallAdd PrivacySettingType = "calladd" // Valid values: PrivacySettingAll, PrivacySettingKnown
  116. )
  117. // PrivacySettings contains the user's privacy settings.
  118. type PrivacySettings struct {
  119. GroupAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  120. LastSeen PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  121. Status PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  122. Profile PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone
  123. ReadReceipts PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingNone
  124. CallAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingKnown
  125. Online PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen
  126. }
  127. // StatusPrivacyType is the type of list in StatusPrivacy.
  128. type StatusPrivacyType string
  129. const (
  130. // StatusPrivacyTypeContacts means statuses are sent to all contacts.
  131. StatusPrivacyTypeContacts StatusPrivacyType = "contacts"
  132. // StatusPrivacyTypeBlacklist means statuses are sent to all contacts, except the ones on the list.
  133. StatusPrivacyTypeBlacklist StatusPrivacyType = "blacklist"
  134. // StatusPrivacyTypeWhitelist means statuses are only sent to users on the list.
  135. StatusPrivacyTypeWhitelist StatusPrivacyType = "whitelist"
  136. )
  137. // StatusPrivacy contains the settings for who to send status messages to by default.
  138. type StatusPrivacy struct {
  139. Type StatusPrivacyType
  140. List []JID
  141. IsDefault bool
  142. }
  143. // Blocklist contains the user's current list of blocked users.
  144. type Blocklist struct {
  145. DHash string // TODO is this just a timestamp?
  146. JIDs []JID
  147. }
  148. // BusinessHoursConfig contains business operating hours of a WhatsApp business.
  149. type BusinessHoursConfig struct {
  150. DayOfWeek string
  151. Mode string
  152. OpenTime string
  153. CloseTime string
  154. }
  155. // Category contains a WhatsApp business category.
  156. type Category struct {
  157. ID string
  158. Name string
  159. }
  160. // BusinessProfile contains the profile information of a WhatsApp business.
  161. type BusinessProfile struct {
  162. JID JID
  163. Address string
  164. Email string
  165. Categories []Category
  166. ProfileOptions map[string]string
  167. BusinessHoursTimeZone string
  168. BusinessHours []BusinessHoursConfig
  169. }