mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 08:27:44 +00:00
Update dependencies (#1851)
This commit is contained in:
3598
vendor/go.mau.fi/whatsmeow/binary/proto/def.pb.go
vendored
3598
vendor/go.mau.fi/whatsmeow/binary/proto/def.pb.go
vendored
File diff suppressed because it is too large
Load Diff
BIN
vendor/go.mau.fi/whatsmeow/binary/proto/def.pb.raw
vendored
BIN
vendor/go.mau.fi/whatsmeow/binary/proto/def.pb.raw
vendored
Binary file not shown.
158
vendor/go.mau.fi/whatsmeow/binary/proto/def.proto
vendored
158
vendor/go.mau.fi/whatsmeow/binary/proto/def.proto
vendored
@ -31,10 +31,10 @@ message ADVDeviceIdentity {
|
||||
optional uint32 keyIndex = 3;
|
||||
}
|
||||
|
||||
message CompanionProps {
|
||||
message DeviceProps {
|
||||
optional string os = 1;
|
||||
optional AppVersion version = 2;
|
||||
enum CompanionPropsPlatformType {
|
||||
enum DevicePropsPlatformType {
|
||||
UNKNOWN = 0;
|
||||
CHROME = 1;
|
||||
FIREFOX = 2;
|
||||
@ -50,7 +50,7 @@ message CompanionProps {
|
||||
CATALINA = 12;
|
||||
TCL_TV = 13;
|
||||
}
|
||||
optional CompanionPropsPlatformType platformType = 3;
|
||||
optional DevicePropsPlatformType platformType = 3;
|
||||
optional bool requireFullSync = 4;
|
||||
}
|
||||
|
||||
@ -62,39 +62,6 @@ message AppVersion {
|
||||
optional uint32 quinary = 5;
|
||||
}
|
||||
|
||||
message ProtocolMessage {
|
||||
optional MessageKey key = 1;
|
||||
enum ProtocolMessageType {
|
||||
REVOKE = 0;
|
||||
EPHEMERAL_SETTING = 3;
|
||||
EPHEMERAL_SYNC_RESPONSE = 4;
|
||||
HISTORY_SYNC_NOTIFICATION = 5;
|
||||
APP_STATE_SYNC_KEY_SHARE = 6;
|
||||
APP_STATE_SYNC_KEY_REQUEST = 7;
|
||||
MSG_FANOUT_BACKFILL_REQUEST = 8;
|
||||
INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC = 9;
|
||||
APP_STATE_FATAL_EXCEPTION_NOTIFICATION = 10;
|
||||
}
|
||||
optional ProtocolMessageType type = 2;
|
||||
optional uint32 ephemeralExpiration = 4;
|
||||
optional int64 ephemeralSettingTimestamp = 5;
|
||||
optional HistorySyncNotification historySyncNotification = 6;
|
||||
optional AppStateSyncKeyShare appStateSyncKeyShare = 7;
|
||||
optional AppStateSyncKeyRequest appStateSyncKeyRequest = 8;
|
||||
optional InitialSecurityNotificationSettingSync initialSecurityNotificationSettingSync = 9;
|
||||
optional AppStateFatalExceptionNotification appStateFatalExceptionNotification = 10;
|
||||
optional DisappearingMode disappearingMode = 11;
|
||||
}
|
||||
|
||||
message ProductMessage {
|
||||
optional ProductSnapshot product = 1;
|
||||
optional string businessOwnerJid = 2;
|
||||
optional CatalogSnapshot catalog = 4;
|
||||
optional string body = 5;
|
||||
optional string footer = 6;
|
||||
optional ContextInfo contextInfo = 17;
|
||||
}
|
||||
|
||||
message ProductSnapshot {
|
||||
optional ImageMessage productImage = 1;
|
||||
optional string productId = 2;
|
||||
@ -123,6 +90,10 @@ message PollVoteMessage {
|
||||
message PollUpdateMessage {
|
||||
optional MessageKey pollCreationMessageKey = 1;
|
||||
optional PollEncValue vote = 2;
|
||||
optional PollUpdateMessageMetadata metadata = 3;
|
||||
}
|
||||
|
||||
message PollUpdateMessageMetadata {
|
||||
}
|
||||
|
||||
message PollEncValue {
|
||||
@ -265,6 +236,12 @@ message ProductListHeaderImage {
|
||||
optional bytes jpegThumbnail = 2;
|
||||
}
|
||||
|
||||
message KeepInChatMessage {
|
||||
optional MessageKey key = 1;
|
||||
optional KeepType keepType = 2;
|
||||
optional int64 timestampMs = 3;
|
||||
}
|
||||
|
||||
message InvoiceMessage {
|
||||
optional string note = 1;
|
||||
optional string token = 2;
|
||||
@ -708,6 +685,11 @@ message Location {
|
||||
optional string name = 3;
|
||||
}
|
||||
|
||||
enum KeepType {
|
||||
UNKNOWN = 0;
|
||||
KEEP_FOR_ALL = 1;
|
||||
UNDO_KEEP_FOR_ALL = 2;
|
||||
}
|
||||
message InteractiveAnnotation {
|
||||
repeated Point polygonVertices = 1;
|
||||
oneof action {
|
||||
@ -926,12 +908,14 @@ message Message {
|
||||
optional InteractiveResponseMessage interactiveResponseMessage = 48;
|
||||
optional PollCreationMessage pollCreationMessage = 49;
|
||||
optional PollUpdateMessage pollUpdateMessage = 50;
|
||||
optional KeepInChatMessage keepInChatMessage = 51;
|
||||
}
|
||||
|
||||
message MessageContextInfo {
|
||||
optional DeviceListMetadata deviceListMetadata = 1;
|
||||
optional int32 deviceListMetadataVersion = 2;
|
||||
optional bytes messageSecret = 3;
|
||||
optional bytes paddingBytes = 4;
|
||||
}
|
||||
|
||||
message VideoMessage {
|
||||
@ -1060,6 +1044,39 @@ message ReactionMessage {
|
||||
optional int64 senderTimestampMs = 4;
|
||||
}
|
||||
|
||||
message ProtocolMessage {
|
||||
optional MessageKey key = 1;
|
||||
enum ProtocolMessageType {
|
||||
REVOKE = 0;
|
||||
EPHEMERAL_SETTING = 3;
|
||||
EPHEMERAL_SYNC_RESPONSE = 4;
|
||||
HISTORY_SYNC_NOTIFICATION = 5;
|
||||
APP_STATE_SYNC_KEY_SHARE = 6;
|
||||
APP_STATE_SYNC_KEY_REQUEST = 7;
|
||||
MSG_FANOUT_BACKFILL_REQUEST = 8;
|
||||
INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC = 9;
|
||||
APP_STATE_FATAL_EXCEPTION_NOTIFICATION = 10;
|
||||
}
|
||||
optional ProtocolMessageType type = 2;
|
||||
optional uint32 ephemeralExpiration = 4;
|
||||
optional int64 ephemeralSettingTimestamp = 5;
|
||||
optional HistorySyncNotification historySyncNotification = 6;
|
||||
optional AppStateSyncKeyShare appStateSyncKeyShare = 7;
|
||||
optional AppStateSyncKeyRequest appStateSyncKeyRequest = 8;
|
||||
optional InitialSecurityNotificationSettingSync initialSecurityNotificationSettingSync = 9;
|
||||
optional AppStateFatalExceptionNotification appStateFatalExceptionNotification = 10;
|
||||
optional DisappearingMode disappearingMode = 11;
|
||||
}
|
||||
|
||||
message ProductMessage {
|
||||
optional ProductSnapshot product = 1;
|
||||
optional string businessOwnerJid = 2;
|
||||
optional CatalogSnapshot catalog = 4;
|
||||
optional string body = 5;
|
||||
optional string footer = 6;
|
||||
optional ContextInfo contextInfo = 17;
|
||||
}
|
||||
|
||||
message EphemeralSetting {
|
||||
optional sfixed32 duration = 1;
|
||||
optional sfixed64 timestamp = 2;
|
||||
@ -1161,6 +1178,17 @@ message Conversation {
|
||||
optional MediaVisibility mediaVisibility = 27;
|
||||
optional uint64 tcTokenSenderTimestamp = 28;
|
||||
optional bool suspended = 29;
|
||||
optional bool terminated = 30;
|
||||
optional uint64 createdAt = 31;
|
||||
optional string createdBy = 32;
|
||||
optional string description = 33;
|
||||
optional bool support = 34;
|
||||
optional bool isParentGroup = 35;
|
||||
optional bool isDefaultSubgroup = 36;
|
||||
optional string parentGroupId = 37;
|
||||
optional string displayName = 38;
|
||||
optional string pnJid = 39;
|
||||
optional bool selfMasked = 40;
|
||||
}
|
||||
|
||||
message AutoDownloadSettings {
|
||||
@ -1192,8 +1220,8 @@ message MsgOpaqueData {
|
||||
optional string loc = 16;
|
||||
optional string pollName = 17;
|
||||
repeated PollOption pollOptions = 18;
|
||||
optional bytes pollEncKey = 19;
|
||||
optional uint32 pollSelectableOptionsCount = 20;
|
||||
optional bytes messageSecret = 21;
|
||||
}
|
||||
|
||||
message PollOption {
|
||||
@ -1559,20 +1587,6 @@ message BizAccountLinkInfo {
|
||||
optional BizAccountLinkInfoAccountType accountType = 5;
|
||||
}
|
||||
|
||||
message NoiseCertificate {
|
||||
optional bytes details = 1;
|
||||
optional bytes signature = 2;
|
||||
}
|
||||
|
||||
// Renamed from NoiseCertificate$Details
|
||||
message NoiseCertificateDetails {
|
||||
optional uint32 serial = 1;
|
||||
optional string issuer = 2;
|
||||
optional uint64 expires = 3;
|
||||
optional string subject = 4;
|
||||
optional bytes key = 5;
|
||||
}
|
||||
|
||||
message HandshakeMessage {
|
||||
optional ClientHello clientHello = 2;
|
||||
optional ServerHello serverHello = 3;
|
||||
@ -1943,6 +1957,7 @@ message WebMessageInfo {
|
||||
GROUP_PARTICIPANT_ACCEPT = 140;
|
||||
GROUP_PARTICIPANT_LINKED_GROUP_JOIN = 141;
|
||||
COMMUNITY_CREATE = 142;
|
||||
EPHEMERAL_KEEP_IN_CHAT = 143;
|
||||
}
|
||||
optional WebMessageInfoStubType messageStubType = 24;
|
||||
optional bool clearMedia = 25;
|
||||
@ -1976,6 +1991,7 @@ message WebMessageInfo {
|
||||
optional string agentId = 47;
|
||||
optional bool statusAlreadyViewed = 48;
|
||||
optional bytes messageSecret = 49;
|
||||
optional KeepInChat keepInChat = 50;
|
||||
}
|
||||
|
||||
message WebFeatures {
|
||||
@ -2148,3 +2164,43 @@ message MediaData {
|
||||
optional string localPath = 1;
|
||||
}
|
||||
|
||||
message KeepInChat {
|
||||
optional KeepType keepType = 1;
|
||||
optional int64 serverTimestamp = 2;
|
||||
optional string deviceJid = 3;
|
||||
}
|
||||
|
||||
message NoiseCertificate {
|
||||
optional bytes details = 1;
|
||||
optional bytes signature = 2;
|
||||
}
|
||||
|
||||
// Renamed from NoiseCertificate$Details
|
||||
message NoiseCertificateDetails {
|
||||
optional uint32 serial = 1;
|
||||
optional string issuer = 2;
|
||||
optional uint64 expires = 3;
|
||||
optional string subject = 4;
|
||||
optional bytes key = 5;
|
||||
}
|
||||
|
||||
message CertChain {
|
||||
optional CertChainNoiseCertificate leaf = 1;
|
||||
optional CertChainNoiseCertificate intermediate = 2;
|
||||
}
|
||||
|
||||
// Renamed from CertChain$NoiseCertificate
|
||||
message CertChainNoiseCertificate {
|
||||
optional bytes details = 1;
|
||||
optional bytes signature = 2;
|
||||
}
|
||||
|
||||
// Renamed from CertChain$NoiseCertificate$Details
|
||||
message CertChainNoiseCertificateDetails {
|
||||
optional uint32 serial = 1;
|
||||
optional uint32 issuerSerial = 2;
|
||||
optional bytes key = 3;
|
||||
optional uint64 notBefore = 4;
|
||||
optional uint64 notAfter = 5;
|
||||
}
|
||||
|
||||
|
18
vendor/go.mau.fi/whatsmeow/message.go
vendored
18
vendor/go.mau.fi/whatsmeow/message.go
vendored
@ -40,6 +40,9 @@ func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
|
||||
if err != nil {
|
||||
cli.Log.Warnf("Failed to parse message: %v", err)
|
||||
} else {
|
||||
if info.VerifiedName != nil && len(info.VerifiedName.Details.GetVerifiedName()) > 0 {
|
||||
go cli.updateBusinessName(info.Sender, info, info.VerifiedName.Details.GetVerifiedName())
|
||||
}
|
||||
if len(info.PushName) > 0 && info.PushName != "-" {
|
||||
go cli.updatePushName(info.Sender, info, info.PushName)
|
||||
}
|
||||
@ -47,13 +50,17 @@ func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
func (cli *Client) parseMessageSource(node *waBinary.Node) (source types.MessageSource, err error) {
|
||||
func (cli *Client) parseMessageSource(node *waBinary.Node, requireParticipant bool) (source types.MessageSource, err error) {
|
||||
ag := node.AttrGetter()
|
||||
from := ag.JID("from")
|
||||
if from.Server == types.GroupServer || from.Server == types.BroadcastServer {
|
||||
source.IsGroup = true
|
||||
source.Chat = from
|
||||
source.Sender = ag.JID("participant")
|
||||
if requireParticipant {
|
||||
source.Sender = ag.JID("participant")
|
||||
} else {
|
||||
source.Sender = ag.OptionalJIDOrEmpty("participant")
|
||||
}
|
||||
if source.Sender.User == cli.Store.ID.User {
|
||||
source.IsFromMe = true
|
||||
}
|
||||
@ -80,7 +87,7 @@ func (cli *Client) parseMessageSource(node *waBinary.Node) (source types.Message
|
||||
func (cli *Client) parseMessageInfo(node *waBinary.Node) (*types.MessageInfo, error) {
|
||||
var info types.MessageInfo
|
||||
var err error
|
||||
info.MessageSource, err = cli.parseMessageSource(node)
|
||||
info.MessageSource, err = cli.parseMessageSource(node, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -96,6 +103,11 @@ func (cli *Client) parseMessageInfo(node *waBinary.Node) (*types.MessageInfo, er
|
||||
for _, child := range node.GetChildren() {
|
||||
if child.Tag == "multicast" {
|
||||
info.Multicast = true
|
||||
} else if child.Tag == "verified_name" {
|
||||
info.VerifiedName, err = parseVerifiedNameContent(child)
|
||||
if err != nil {
|
||||
cli.Log.Warnf("Failed to parse verified_name node in %s: %v", info.ID, err)
|
||||
}
|
||||
} else if mediaType, ok := child.AttrGetter().GetString("mediatype", false); ok {
|
||||
info.MediaType = mediaType
|
||||
}
|
||||
|
2
vendor/go.mau.fi/whatsmeow/presence.go
vendored
2
vendor/go.mau.fi/whatsmeow/presence.go
vendored
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func (cli *Client) handleChatState(node *waBinary.Node) {
|
||||
source, err := cli.parseMessageSource(node)
|
||||
source, err := cli.parseMessageSource(node, true)
|
||||
if err != nil {
|
||||
cli.Log.Warnf("Failed to parse chat state update: %v", err)
|
||||
} else if len(node.GetChildren()) != 1 {
|
||||
|
34
vendor/go.mau.fi/whatsmeow/receipt.go
vendored
34
vendor/go.mau.fi/whatsmeow/receipt.go
vendored
@ -20,7 +20,7 @@ func (cli *Client) handleReceipt(node *waBinary.Node) {
|
||||
receipt, err := cli.parseReceipt(node)
|
||||
if err != nil {
|
||||
cli.Log.Warnf("Failed to parse receipt: %v", err)
|
||||
} else {
|
||||
} else if receipt != nil {
|
||||
if receipt.Type == events.ReceiptTypeRetry {
|
||||
go func() {
|
||||
err := cli.handleRetryReceipt(receipt, node)
|
||||
@ -34,9 +34,29 @@ func (cli *Client) handleReceipt(node *waBinary.Node) {
|
||||
go cli.sendAck(node)
|
||||
}
|
||||
|
||||
func (cli *Client) handleGroupedReceipt(partialReceipt events.Receipt, participants *waBinary.Node) {
|
||||
pag := participants.AttrGetter()
|
||||
partialReceipt.MessageIDs = []types.MessageID{pag.String("key")}
|
||||
for _, child := range participants.GetChildren() {
|
||||
if child.Tag != "user" {
|
||||
cli.Log.Warnf("Unexpected node in grouped receipt participants: %s", child.XMLString())
|
||||
continue
|
||||
}
|
||||
ag := child.AttrGetter()
|
||||
receipt := partialReceipt
|
||||
receipt.Timestamp = ag.UnixTime("t")
|
||||
receipt.MessageSource.Sender = ag.JID("jid")
|
||||
if !ag.OK() {
|
||||
cli.Log.Warnf("Failed to parse user node %s in grouped receipt: %v", child.XMLString(), ag.Error())
|
||||
continue
|
||||
}
|
||||
go cli.dispatchEvent(&receipt)
|
||||
}
|
||||
}
|
||||
|
||||
func (cli *Client) parseReceipt(node *waBinary.Node) (*events.Receipt, error) {
|
||||
ag := node.AttrGetter()
|
||||
source, err := cli.parseMessageSource(node)
|
||||
source, err := cli.parseMessageSource(node, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -45,6 +65,16 @@ func (cli *Client) parseReceipt(node *waBinary.Node) (*events.Receipt, error) {
|
||||
Timestamp: ag.UnixTime("t"),
|
||||
Type: events.ReceiptType(ag.OptionalString("type")),
|
||||
}
|
||||
if source.IsGroup && source.Sender.IsEmpty() {
|
||||
participantTags := node.GetChildrenByTag("participants")
|
||||
if len(participantTags) == 0 {
|
||||
return nil, &ElementMissingError{Tag: "participants", In: "grouped receipt"}
|
||||
}
|
||||
for _, pcp := range participantTags {
|
||||
cli.handleGroupedReceipt(receipt, &pcp)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
mainMessageID := ag.String("id")
|
||||
if !ag.OK() {
|
||||
return nil, fmt.Errorf("failed to parse read receipt attrs: %+v", ag.Errors)
|
||||
|
@ -74,7 +74,7 @@ func (vc WAVersionContainer) ProtoAppVersion() *waProto.AppVersion {
|
||||
}
|
||||
|
||||
// waVersion is the WhatsApp web client version
|
||||
var waVersion = WAVersionContainer{2, 2218, 8}
|
||||
var waVersion = WAVersionContainer{2, 2222, 11}
|
||||
|
||||
// waVersionHash is the md5 hash of a dot-separated waVersion
|
||||
var waVersionHash [16]byte
|
||||
@ -125,14 +125,14 @@ var BaseClientPayload = &waProto.ClientPayload{
|
||||
// Deprecated: renamed to DeviceProps
|
||||
var CompanionProps = DeviceProps
|
||||
|
||||
var DeviceProps = &waProto.CompanionProps{
|
||||
var DeviceProps = &waProto.DeviceProps{
|
||||
Os: proto.String("whatsmeow"),
|
||||
Version: &waProto.AppVersion{
|
||||
Primary: proto.Uint32(0),
|
||||
Secondary: proto.Uint32(1),
|
||||
Tertiary: proto.Uint32(0),
|
||||
},
|
||||
PlatformType: waProto.CompanionProps_UNKNOWN.Enum(),
|
||||
PlatformType: waProto.DeviceProps_UNKNOWN.Enum(),
|
||||
RequireFullSync: proto.Bool(false),
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,8 @@ const (
|
||||
adv_key, adv_details, adv_account_sig, adv_account_sig_key, adv_device_sig,
|
||||
platform, business_name, push_name)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
|
||||
ON CONFLICT (jid) DO UPDATE SET platform=$12, business_name=$13, push_name=$14
|
||||
ON CONFLICT (jid) DO UPDATE
|
||||
SET platform=excluded.platform, business_name=excluded.business_name, push_name=excluded.push_name
|
||||
`
|
||||
deleteDeviceQuery = `DELETE FROM whatsmeow_device WHERE jid=$1`
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ var _ store.ContactStore = (*SQLStore)(nil)
|
||||
const (
|
||||
putIdentityQuery = `
|
||||
INSERT INTO whatsmeow_identity_keys (our_jid, their_id, identity) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (our_jid, their_id) DO UPDATE SET identity=$3
|
||||
ON CONFLICT (our_jid, their_id) DO UPDATE SET identity=excluded.identity
|
||||
`
|
||||
deleteAllIdentitiesQuery = `DELETE FROM whatsmeow_identity_keys WHERE our_jid=$1 AND their_id LIKE $2`
|
||||
deleteIdentityQuery = `DELETE FROM whatsmeow_identity_keys WHERE our_jid=$1 AND their_id=$2`
|
||||
@ -108,7 +108,7 @@ const (
|
||||
hasSessionQuery = `SELECT true FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id=$2`
|
||||
putSessionQuery = `
|
||||
INSERT INTO whatsmeow_sessions (our_jid, their_id, session) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (our_jid, their_id) DO UPDATE SET session=$3
|
||||
ON CONFLICT (our_jid, their_id) DO UPDATE SET session=excluded.session
|
||||
`
|
||||
deleteAllSessionsQuery = `DELETE FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id LIKE $2`
|
||||
deleteSessionQuery = `DELETE FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id=$2`
|
||||
@ -259,7 +259,7 @@ const (
|
||||
getSenderKeyQuery = `SELECT sender_key FROM whatsmeow_sender_keys WHERE our_jid=$1 AND chat_id=$2 AND sender_id=$3`
|
||||
putSenderKeyQuery = `
|
||||
INSERT INTO whatsmeow_sender_keys (our_jid, chat_id, sender_id, sender_key) VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (our_jid, chat_id, sender_id) DO UPDATE SET sender_key=$4
|
||||
ON CONFLICT (our_jid, chat_id, sender_id) DO UPDATE SET sender_key=excluded.sender_key
|
||||
`
|
||||
)
|
||||
|
||||
@ -279,7 +279,8 @@ func (s *SQLStore) GetSenderKey(group, user string) (key []byte, err error) {
|
||||
const (
|
||||
putAppStateSyncKeyQuery = `
|
||||
INSERT INTO whatsmeow_app_state_sync_keys (jid, key_id, key_data, timestamp, fingerprint) VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (jid, key_id) DO UPDATE SET key_data=$3, timestamp=$4, fingerprint=$5
|
||||
ON CONFLICT (jid, key_id) DO UPDATE
|
||||
SET key_data=excluded.key_data, timestamp=excluded.timestamp, fingerprint=excluded.fingerprint
|
||||
`
|
||||
getAppStateSyncKeyQuery = `SELECT key_data, timestamp, fingerprint FROM whatsmeow_app_state_sync_keys WHERE jid=$1 AND key_id=$2`
|
||||
)
|
||||
@ -301,7 +302,7 @@ func (s *SQLStore) GetAppStateSyncKey(id []byte) (*store.AppStateSyncKey, error)
|
||||
const (
|
||||
putAppStateVersionQuery = `
|
||||
INSERT INTO whatsmeow_app_state_version (jid, name, version, hash) VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (jid, name) DO UPDATE SET version=$3, hash=$4
|
||||
ON CONFLICT (jid, name) DO UPDATE SET version=excluded.version, hash=excluded.hash
|
||||
`
|
||||
getAppStateVersionQuery = `SELECT version, hash FROM whatsmeow_app_state_version WHERE jid=$1 AND name=$2`
|
||||
deleteAppStateVersionQuery = `DELETE FROM whatsmeow_app_state_version WHERE jid=$1 AND name=$2`
|
||||
@ -435,11 +436,11 @@ const (
|
||||
`
|
||||
putPushNameQuery = `
|
||||
INSERT INTO whatsmeow_contacts (our_jid, their_jid, push_name) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (our_jid, their_jid) DO UPDATE SET push_name=$3
|
||||
ON CONFLICT (our_jid, their_jid) DO UPDATE SET push_name=excluded.push_name
|
||||
`
|
||||
putBusinessNameQuery = `
|
||||
INSERT INTO whatsmeow_contacts (our_jid, their_jid, business_name) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (our_jid, their_jid) DO UPDATE SET business_name=$3
|
||||
ON CONFLICT (our_jid, their_jid) DO UPDATE SET business_name=excluded.business_name
|
||||
`
|
||||
getContactQuery = `
|
||||
SELECT first_name, full_name, push_name, business_name FROM whatsmeow_contacts WHERE our_jid=$1 AND their_jid=$2
|
||||
@ -470,23 +471,25 @@ func (s *SQLStore) PutPushName(user types.JID, pushName string) (bool, string, e
|
||||
return false, "", nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) PutBusinessName(user types.JID, businessName string) error {
|
||||
func (s *SQLStore) PutBusinessName(user types.JID, businessName string) (bool, string, error) {
|
||||
s.contactCacheLock.Lock()
|
||||
defer s.contactCacheLock.Unlock()
|
||||
|
||||
cached, err := s.getContact(user)
|
||||
if err != nil {
|
||||
return err
|
||||
return false, "", err
|
||||
}
|
||||
if cached.BusinessName != businessName {
|
||||
_, err = s.db.Exec(putBusinessNameQuery, s.JID, user, businessName)
|
||||
if err != nil {
|
||||
return err
|
||||
return false, "", err
|
||||
}
|
||||
previousName := cached.BusinessName
|
||||
cached.BusinessName = businessName
|
||||
cached.Found = true
|
||||
return true, previousName, nil
|
||||
}
|
||||
return nil
|
||||
return false, "", nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) PutContactName(user types.JID, firstName, fullName string) error {
|
||||
@ -643,7 +646,7 @@ func (s *SQLStore) GetAllContacts() (map[types.JID]types.ContactInfo, error) {
|
||||
const (
|
||||
putChatSettingQuery = `
|
||||
INSERT INTO whatsmeow_chat_settings (our_jid, chat_jid, %[1]s) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (our_jid, chat_jid) DO UPDATE SET %[1]s=$3
|
||||
ON CONFLICT (our_jid, chat_jid) DO UPDATE SET %[1]s=excluded.%[1]s
|
||||
`
|
||||
getChatSettingsQuery = `
|
||||
SELECT muted_until, pinned, archived FROM whatsmeow_chat_settings WHERE our_jid=$1 AND chat_jid=$2
|
||||
|
@ -239,7 +239,7 @@ func upgradeV2(tx *sql.Tx, container *Container) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if container.dialect == "postgres" {
|
||||
if container.dialect == "postgres" || container.dialect == "pgx" {
|
||||
_, err = tx.Exec(fillSigKeyPostgres)
|
||||
} else {
|
||||
_, err = tx.Exec(fillSigKeySQLite)
|
||||
|
2
vendor/go.mau.fi/whatsmeow/store/store.go
vendored
2
vendor/go.mau.fi/whatsmeow/store/store.go
vendored
@ -80,7 +80,7 @@ type ContactEntry struct {
|
||||
|
||||
type ContactStore interface {
|
||||
PutPushName(user types.JID, pushName string) (bool, string, error)
|
||||
PutBusinessName(user types.JID, businessName string) error
|
||||
PutBusinessName(user types.JID, businessName string) (bool, string, error)
|
||||
PutContactName(user types.JID, fullName, firstName string) error
|
||||
PutAllContactNames(contacts []ContactEntry) error
|
||||
GetContact(user types.JID) (types.ContactInfo, error)
|
||||
|
@ -30,6 +30,14 @@ type PushName struct {
|
||||
NewPushName string // The new push name that was included in the message.
|
||||
}
|
||||
|
||||
// BusinessName is emitted when a message is received with a different verified business name than the previous value cached for the same user.
|
||||
type BusinessName struct {
|
||||
JID types.JID
|
||||
Message *types.MessageInfo // This is only present if the change was detected in a message.
|
||||
OldBusinessName string
|
||||
NewBusinessName string
|
||||
}
|
||||
|
||||
// Pin is emitted when a chat is pinned or unpinned from another device.
|
||||
type Pin struct {
|
||||
JID types.JID // The chat which was pinned or unpinned.
|
||||
|
1
vendor/go.mau.fi/whatsmeow/types/message.go
vendored
1
vendor/go.mau.fi/whatsmeow/types/message.go
vendored
@ -47,6 +47,7 @@ type MessageInfo struct {
|
||||
Multicast bool
|
||||
MediaType string
|
||||
|
||||
VerifiedName *VerifiedName
|
||||
DeviceSentMeta *DeviceSentMeta // Metadata for direct messages sent from another one of the user's own devices.
|
||||
}
|
||||
|
||||
|
18
vendor/go.mau.fi/whatsmeow/user.go
vendored
18
vendor/go.mau.fi/whatsmeow/user.go
vendored
@ -133,7 +133,7 @@ func (cli *Client) GetUserInfo(jids []types.JID) (map[types.JID]types.UserInfo,
|
||||
info.PictureID, _ = child.GetChildByTag("picture").Attrs["id"].(string)
|
||||
info.Devices = parseDeviceList(jid.User, child.GetChildByTag("devices"))
|
||||
if verifiedName != nil {
|
||||
cli.updateBusinessName(jid, verifiedName.Details.GetVerifiedName())
|
||||
cli.updateBusinessName(jid, nil, verifiedName.Details.GetVerifiedName())
|
||||
}
|
||||
respData[jid] = info
|
||||
}
|
||||
@ -262,13 +262,21 @@ func (cli *Client) updatePushName(user types.JID, messageInfo *types.MessageInfo
|
||||
}
|
||||
}
|
||||
|
||||
func (cli *Client) updateBusinessName(user types.JID, name string) {
|
||||
func (cli *Client) updateBusinessName(user types.JID, messageInfo *types.MessageInfo, name string) {
|
||||
if cli.Store.Contacts == nil {
|
||||
return
|
||||
}
|
||||
err := cli.Store.Contacts.PutBusinessName(user, name)
|
||||
changed, previousName, err := cli.Store.Contacts.PutBusinessName(user, name)
|
||||
if err != nil {
|
||||
cli.Log.Errorf("Failed to save business name of %s in device store: %v", user, err)
|
||||
} else if changed {
|
||||
cli.Log.Debugf("Business name of %s changed from %s to %s, dispatching event", user, previousName, name)
|
||||
cli.dispatchEvent(&events.BusinessName{
|
||||
JID: user,
|
||||
Message: messageInfo,
|
||||
OldBusinessName: previousName,
|
||||
NewBusinessName: name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,6 +288,10 @@ func parseVerifiedName(businessNode waBinary.Node) (*types.VerifiedName, error)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return parseVerifiedNameContent(verifiedNameNode)
|
||||
}
|
||||
|
||||
func parseVerifiedNameContent(verifiedNameNode waBinary.Node) (*types.VerifiedName, error) {
|
||||
rawCert, ok := verifiedNameNode.Content.([]byte)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user