mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 23:57:50 -05:00
38 lines
800 B
Go
38 lines
800 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/ProtonMail/go-proton-api"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (s *Server) handleGetKeys() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
if pubKeys, err := s.b.GetPublicKeys(c.Query("Email")); err == nil && len(pubKeys) > 0 {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"Keys": pubKeys,
|
|
"RecipientType": proton.RecipientTypeInternal,
|
|
})
|
|
} else {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"RecipientType": proton.RecipientTypeExternal,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s *Server) handleGetKeySalts() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
salts, err := s.b.GetKeySalts(c.GetString("UserID"))
|
|
if err != nil {
|
|
c.AbortWithStatus(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"KeySalts": salts,
|
|
})
|
|
}
|
|
}
|