summaryrefslogtreecommitdiff
path: root/internal/message
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
parentLetsencrypt (#17) (diff)
downloadgotosocial-3363e0ebdd2ad8bde458037b82432bc3dd93adde.tar.xz
add api/v1/instance info handler + instance model (#18)
Diffstat (limited to 'internal/message')
-rw-r--r--internal/message/instanceprocess.go22
-rw-r--r--internal/message/processor.go18
2 files changed, 33 insertions, 7 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
+}
diff --git a/internal/message/processor.go b/internal/message/processor.go
index 2126c9597..0c0334e20 100644
--- a/internal/message/processor.go
+++ b/internal/message/processor.go
@@ -68,9 +68,20 @@ type Processor interface {
// AccountUpdate processes the update of an account with the given form
AccountUpdate(authed *oauth.Auth, form *apimodel.UpdateCredentialsRequest) (*apimodel.Account, error)
+ // AdminEmojiCreate handles the creation of a new instance emoji by an admin, using the given form.
+ AdminEmojiCreate(authed *oauth.Auth, form *apimodel.EmojiCreateRequest) (*apimodel.Emoji, error)
+
// AppCreate processes the creation of a new API application
AppCreate(authed *oauth.Auth, form *apimodel.ApplicationCreateRequest) (*apimodel.Application, error)
+ // InstanceGet retrieves instance information for serving at api/v1/instance
+ InstanceGet(domain string) (*apimodel.Instance, ErrorWithCode)
+
+ // MediaCreate handles the creation of a media attachment, using the given form.
+ MediaCreate(authed *oauth.Auth, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error)
+ // MediaGet handles the fetching of a media attachment, using the given request form.
+ MediaGet(authed *oauth.Auth, form *apimodel.GetContentRequestForm) (*apimodel.Content, error)
+
// StatusCreate processes the given form to create a new status, returning the api model representation of that status if it's OK.
StatusCreate(authed *oauth.Auth, form *apimodel.AdvancedStatusCreateForm) (*apimodel.Status, error)
// StatusDelete processes the delete of a given status, returning the deleted status if the delete goes through.
@@ -86,13 +97,6 @@ type Processor interface {
// StatusUnfave processes the unfaving of a given status, returning the updated status if the fave goes through.
StatusUnfave(authed *oauth.Auth, targetStatusID string) (*apimodel.Status, error)
- // MediaCreate handles the creation of a media attachment, using the given form.
- MediaCreate(authed *oauth.Auth, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error)
- // MediaGet handles the fetching of a media attachment, using the given request form.
- MediaGet(authed *oauth.Auth, form *apimodel.GetContentRequestForm) (*apimodel.Content, error)
- // AdminEmojiCreate handles the creation of a new instance emoji by an admin, using the given form.
- AdminEmojiCreate(authed *oauth.Auth, form *apimodel.EmojiCreateRequest) (*apimodel.Emoji, error)
-
/*
FEDERATION API-FACING PROCESSING FUNCTIONS
These functions are intended to be called when the federating client needs an immediate (ie., synchronous) reply