-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
49 lines (40 loc) · 998 Bytes
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package mapi
import (
"errors"
"github.com/labstack/echo/v4"
"github.com/uakihir0/nostr-rest/server/domain"
minjection "github.com/uakihir0/nostr-rest/server/mastodon/injection"
"net/http"
)
// GetMApiV1AccountsVerifyCredentials
func (h *MastodonHandler) GetApiV1AccountsVerifyCredentials(c echo.Context) error {
accountService := minjection.AccountService()
pk := c.(*domain.Context).PubKey
if pk == nil {
return errors.New("needs user public key")
}
account, err := accountService.GetAccount(*pk)
if err != nil {
return err
}
return c.JSON(
http.StatusOK,
ToCredentialAccount(*account),
)
}
// GetMApiV1AccountsId
func (h *MastodonHandler) GetApiV1AccountsUid(c echo.Context, uid string) error {
accountService := minjection.AccountService()
pk, err := domain.ToUserPubKey(uid)
if err != nil {
return err
}
account, err := accountService.GetAccount(*pk)
if err != nil {
return err
}
return c.JSON(
http.StatusOK,
ToCredentialAccount(*account),
)
}