diff options
author | 2021-05-09 14:06:06 +0200 | |
---|---|---|
committer | 2021-05-09 14:06:06 +0200 | |
commit | 3363e0ebdd2ad8bde458037b82432bc3dd93adde (patch) | |
tree | 3b105083f75aa47f3872b588403d9e5cf2f45d14 /internal/message/instanceprocess.go | |
parent | Letsencrypt (#17) (diff) | |
download | gotosocial-3363e0ebdd2ad8bde458037b82432bc3dd93adde.tar.xz |
add api/v1/instance info handler + instance model (#18)
Diffstat (limited to 'internal/message/instanceprocess.go')
-rw-r--r-- | internal/message/instanceprocess.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/message/instanceprocess.go b/internal/message/instanceprocess.go new file mode 100644 index 000000000..16a5594de --- /dev/null +++ b/internal/message/instanceprocess.go @@ -0,0 +1,22 @@ +package message + +import ( + "fmt" + + apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" + "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +) + +func (p *processor) InstanceGet(domain string) (*apimodel.Instance, ErrorWithCode) { + i := >smodel.Instance{} + if err := p.db.GetWhere("domain", domain, i); err != nil { + return nil, NewErrorInternalError(fmt.Errorf("db error fetching instance %s: %s", p.config.Host, err)) + } + + ai, err := p.tc.InstanceToMasto(i) + if err != nil { + return nil, NewErrorInternalError(fmt.Errorf("error converting instance to api representation: %s", err)) + } + + return ai, nil +} |