package tools

import (
	"amocrm/internal/proto/socialauth"
	"google.golang.org/protobuf/proto"
	"fmt"
)

func DeserializeProtobufMessage(protobufMessage string) (string, string, error) {
	msg := socialauth.Message{}

	err := proto.Unmarshal([]byte(protobufMessage), &msg)
	if err != nil {
		return "", "", err
	}

	fmt.Println("PROTOOTOT", msg.State, *msg.AccessToken)

	var accountID string
	if msg.AccessToken != nil {
		accountID = *msg.AccessToken
	}

	return accountID, msg.ReturnURL, nil
}
