summaryrefslogtreecommitdiff
path: root/internal/message/frprocess.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-15 11:58:11 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-15 11:58:11 +0200
commitcc48294c31a76e94fa879ad0d8d5dbd7e94c651b (patch)
tree7c26d33b41bab33bbdfbba540958444f4c296602 /internal/message/frprocess.go
parentMediahandler (#21) (diff)
downloadgotosocial-cc48294c31a76e94fa879ad0d8d5dbd7e94c651b.tar.xz
Inbox post (#22)
Inbox POST from federated servers now working for statuses and follow requests. Follow request client API added. Start work on federating outgoing messages. Other fixes and changes/tidying up.
Diffstat (limited to 'internal/message/frprocess.go')
-rw-r--r--internal/message/frprocess.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/message/frprocess.go b/internal/message/frprocess.go
new file mode 100644
index 000000000..c96b83dec
--- /dev/null
+++ b/internal/message/frprocess.go
@@ -0,0 +1,42 @@
+package message
+
+import (
+ apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
+ "github.com/superseriousbusiness/gotosocial/internal/db"
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/oauth"
+)
+
+func (p *processor) FollowRequestsGet(auth *oauth.Auth) ([]apimodel.Account, ErrorWithCode) {
+ frs := []gtsmodel.FollowRequest{}
+ if err := p.db.GetFollowRequestsForAccountID(auth.Account.ID, &frs); err != nil {
+ if _, ok := err.(db.ErrNoEntries); !ok {
+ return nil, NewErrorInternalError(err)
+ }
+ }
+
+ accts := []apimodel.Account{}
+ for _, fr := range frs {
+ acct := &gtsmodel.Account{}
+ if err := p.db.GetByID(fr.AccountID, acct); err != nil {
+ return nil, NewErrorInternalError(err)
+ }
+ mastoAcct, err := p.tc.AccountToMastoPublic(acct)
+ if err != nil {
+ return nil, NewErrorInternalError(err)
+ }
+ accts = append(accts, *mastoAcct)
+ }
+ return accts, nil
+}
+
+func (p *processor) FollowRequestAccept(auth *oauth.Auth, accountID string) ErrorWithCode {
+ if err := p.db.AcceptFollowRequest(accountID, auth.Account.ID); err != nil {
+ return NewErrorNotFound(err)
+ }
+ return nil
+}
+
+func (p *processor) FollowRequestDeny(auth *oauth.Auth) ErrorWithCode {
+ return nil
+}