Skip to content

Commit

Permalink
convert base64 apns token to hex
Browse files Browse the repository at this point in the history
  • Loading branch information
1Conan committed Jan 6, 2025
1 parent 487f11f commit 38e0b78
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/connector/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"fmt"

"encoding/base64"
"encoding/hex"

"github.com/gotd/td/tg"
"go.mau.fi/util/random"
"maunium.net/go/mautrix/bridgev2"
Expand All @@ -28,6 +31,11 @@ func (t *TelegramClient) RegisterPushNotifications(ctx context.Context, pushType
tokenType = 2
case bridgev2.PushTypeAPNs:
tokenType = 1
if tokenData, err := base64.StdEncoding.DecodeString(token); err == nil {
token = hex.EncodeToString(tokenData)
} else {
return fmt.Errorf("failed to decode APNs token: %w", err)
}
default:
return fmt.Errorf("unsupported push type %s", pushType)
}
Expand Down

0 comments on commit 38e0b78

Please sign in to comment.