2024-04-19 16:05:42 +00:00
|
|
|
package tools
|
|
|
|
|
|
|
|
import (
|
|
|
|
"amocrm/internal/proto/socialauth"
|
|
|
|
"google.golang.org/protobuf/proto"
|
2024-05-30 19:08:32 +00:00
|
|
|
"fmt"
|
2024-04-19 16:05:42 +00:00
|
|
|
)
|
|
|
|
|
2024-05-29 17:35:07 +00:00
|
|
|
func DeserializeProtobufMessage(protobufMessage string) (string, string, error) {
|
2024-04-19 16:05:42 +00:00
|
|
|
msg := socialauth.Message{}
|
|
|
|
|
|
|
|
err := proto.Unmarshal([]byte(protobufMessage), &msg)
|
|
|
|
if err != nil {
|
2024-05-29 17:35:07 +00:00
|
|
|
return "", "", err
|
2024-04-19 16:05:42 +00:00
|
|
|
}
|
|
|
|
|
2024-05-30 19:08:32 +00:00
|
|
|
fmt.Println("PROTOOTOT", msg.State, *msg.AccessToken)
|
|
|
|
|
2024-05-29 17:35:07 +00:00
|
|
|
var accountID string
|
|
|
|
if msg.AccessToken != nil {
|
|
|
|
accountID = *msg.AccessToken
|
|
|
|
}
|
|
|
|
|
|
|
|
return accountID, msg.ReturnURL, nil
|
2024-04-19 16:05:42 +00:00
|
|
|
}
|