Debian Codegraph @

server/keys.go

raw
1 package server
2
3 import (
4 "net/http"
5
6 "github.com/gin-gonic/gin"
7 "github.com/henrybear327/go-proton-api"
8 )
9
10 func (s *Server) handleGetKeys() gin.HandlerFunc {
11 return func(c *gin.Context) {
12 if pubKeys, err := s.b.GetPublicKeys(c.Query("Email")); err == nil && len(pubKeys) > 0 {
13 c.JSON(http.StatusOK, gin.H{
14 "Keys": pubKeys,
15 "RecipientType": proton.RecipientTypeInternal,
16 })
17 } else {
18 c.JSON(http.StatusOK, gin.H{
19 "RecipientType": proton.RecipientTypeExternal,
20 })
21 }
22 }
23 }
24
25 func (s *Server) handleGetKeySalts() gin.HandlerFunc {
26 return func(c *gin.Context) {
27 salts, err := s.b.GetKeySalts(c.GetString("UserID"))
28 if err != nil {
29 c.AbortWithStatus(http.StatusInternalServerError)
30 return
31 }
32
33 c.JSON(http.StatusOK, gin.H{
34 "KeySalts": salts,
35 })
36 }
37 }