summaryrefslogtreecommitdiff
path: root/internal/message/instanceprocess.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-09 14:06:06 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-09 14:06:06 +0200
commit3363e0ebdd2ad8bde458037b82432bc3dd93adde (patch)
tree3b105083f75aa47f3872b588403d9e5cf2f45d14 /internal/message/instanceprocess.go
parentLetsencrypt (#17) (diff)
downloadgotosocial-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.go22
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 := &gtsmodel.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
+}