summaryrefslogtreecommitdiff
path: root/internal/message/fediprocess.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-23 18:07:04 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-23 18:07:04 +0200
commitee65d19ff343134c55ca968114dcbfe4b7b4431d (patch)
tree778141fb4dc2ff17c78594663b0c0cd2a47f79fc /internal/message/fediprocess.go
parentsmall fiddling to allow whalebird to work (a bit) (diff)
downloadgotosocial-ee65d19ff343134c55ca968114dcbfe4b7b4431d.tar.xz
status deletes, profile updates (#30)
1. Proper DELETE of federated statuses (not yet deleting all the media and stuff -- i still have to implement this -- but the actual status is toast). 2. Proper UPDATE of profiles. When you change your profile picture on your remote instance, that will now register properly in GoToSocial. 3. Scrolling down the home timeline - it no longer just sort of ends, and will keep loading older statuses as you scroll. 4. Little bugfixes -- still had some nil pointer errors when dereferencing remote accounts.
Diffstat (limited to 'internal/message/fediprocess.go')
-rw-r--r--internal/message/fediprocess.go42
1 files changed, 41 insertions, 1 deletions
diff --git a/internal/message/fediprocess.go b/internal/message/fediprocess.go
index 491997bf2..173da18ee 100644
--- a/internal/message/fediprocess.go
+++ b/internal/message/fediprocess.go
@@ -68,7 +68,7 @@ func (p *processor) authenticateAndDereferenceFediRequest(username string, r *ht
}
// convert it to our internal account representation
- requestingAccount, err = p.tc.ASRepresentationToAccount(requestingPerson)
+ requestingAccount, err = p.tc.ASRepresentationToAccount(requestingPerson, false)
if err != nil {
return nil, fmt.Errorf("couldn't convert dereferenced uri %s to gtsmodel account: %s", requestingAccountURI.String(), err)
}
@@ -163,6 +163,46 @@ func (p *processor) GetFediFollowers(requestedUsername string, request *http.Req
return data, nil
}
+func (p *processor) GetFediFollowing(requestedUsername string, request *http.Request) (interface{}, ErrorWithCode) {
+ // get the account the request is referring to
+ requestedAccount := &gtsmodel.Account{}
+ if err := p.db.GetLocalAccountByUsername(requestedUsername, requestedAccount); err != nil {
+ return nil, NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))
+ }
+
+ // authenticate the request
+ requestingAccount, err := p.authenticateAndDereferenceFediRequest(requestedUsername, request)
+ if err != nil {
+ return nil, NewErrorNotAuthorized(err)
+ }
+
+ blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID)
+ if err != nil {
+ return nil, NewErrorInternalError(err)
+ }
+
+ if blocked {
+ return nil, NewErrorNotAuthorized(fmt.Errorf("block exists between accounts %s and %s", requestedAccount.ID, requestingAccount.ID))
+ }
+
+ requestedAccountURI, err := url.Parse(requestedAccount.URI)
+ if err != nil {
+ return nil, NewErrorInternalError(fmt.Errorf("error parsing url %s: %s", requestedAccount.URI, err))
+ }
+
+ requestedFollowing, err := p.federator.FederatingDB().Following(context.Background(), requestedAccountURI)
+ if err != nil {
+ return nil, NewErrorInternalError(fmt.Errorf("error fetching following for uri %s: %s", requestedAccountURI.String(), err))
+ }
+
+ data, err := streams.Serialize(requestedFollowing)
+ if err != nil {
+ return nil, NewErrorInternalError(err)
+ }
+
+ return data, nil
+}
+
func (p *processor) GetFediStatus(requestedUsername string, requestedStatusID string, request *http.Request) (interface{}, ErrorWithCode) {
// get the account the request is referring to
requestedAccount := &gtsmodel.Account{}