diff options
author | 2021-05-23 18:07:04 +0200 | |
---|---|---|
committer | 2021-05-23 18:07:04 +0200 | |
commit | ee65d19ff343134c55ca968114dcbfe4b7b4431d (patch) | |
tree | 778141fb4dc2ff17c78594663b0c0cd2a47f79fc /internal/api | |
parent | small fiddling to allow whalebird to work (a bit) (diff) | |
download | gotosocial-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/api')
-rw-r--r-- | internal/api/s2s/user/following.go | 58 | ||||
-rw-r--r-- | internal/api/s2s/user/user.go | 3 | ||||
-rw-r--r-- | internal/api/s2s/user/userget_test.go | 2 |
3 files changed, 62 insertions, 1 deletions
diff --git a/internal/api/s2s/user/following.go b/internal/api/s2s/user/following.go new file mode 100644 index 000000000..de5701f8d --- /dev/null +++ b/internal/api/s2s/user/following.go @@ -0,0 +1,58 @@ +/* + GoToSocial + Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +package user + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" +) + +func (m *Module) FollowingGETHandler(c *gin.Context) { + l := m.log.WithFields(logrus.Fields{ + "func": "FollowingGETHandler", + "url": c.Request.RequestURI, + }) + + requestedUsername := c.Param(UsernameKey) + if requestedUsername == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "no username specified in request"}) + return + } + + // make sure this actually an AP request + format := c.NegotiateFormat(ActivityPubAcceptHeaders...) + if format == "" { + c.JSON(http.StatusNotAcceptable, gin.H{"error": "could not negotiate format with given Accept header(s)"}) + return + } + l.Tracef("negotiated format: %s", format) + + // make a copy of the context to pass along so we don't break anything + cp := c.Copy() + user, err := m.processor.GetFediFollowing(requestedUsername, cp.Request) // handles auth as well + if err != nil { + l.Info(err.Error()) + c.JSON(err.Code(), gin.H{"error": err.Safe()}) + return + } + + c.JSON(http.StatusOK, user) +} diff --git a/internal/api/s2s/user/user.go b/internal/api/s2s/user/user.go index d866e47e1..e1bdb9a8d 100644 --- a/internal/api/s2s/user/user.go +++ b/internal/api/s2s/user/user.go @@ -44,6 +44,8 @@ const ( UsersInboxPath = UsersBasePathWithUsername + "/" + util.InboxPath // UsersFollowersPath is for serving GET request's to a user's followers list, with the given username key. UsersFollowersPath = UsersBasePathWithUsername + "/" + util.FollowersPath + // UsersFollowingPath is for serving GET request's to a user's following list, with the given username key. + UsersFollowingPath = UsersBasePathWithUsername + "/" + util.FollowingPath // UsersStatusPath is for serving GET requests to a particular status by a user, with the given username key and status ID UsersStatusPath = UsersBasePathWithUsername + "/" + util.StatusesPath + "/:" + StatusIDKey ) @@ -76,6 +78,7 @@ func (m *Module) Route(s router.Router) error { s.AttachHandler(http.MethodGet, UsersBasePathWithUsername, m.UsersGETHandler) s.AttachHandler(http.MethodPost, UsersInboxPath, m.InboxPOSTHandler) s.AttachHandler(http.MethodGet, UsersFollowersPath, m.FollowersGETHandler) + s.AttachHandler(http.MethodGet, UsersFollowingPath, m.FollowingGETHandler) s.AttachHandler(http.MethodGet, UsersStatusPath, m.StatusGETHandler) return nil } diff --git a/internal/api/s2s/user/userget_test.go b/internal/api/s2s/user/userget_test.go index b45b01b63..fab490767 100644 --- a/internal/api/s2s/user/userget_test.go +++ b/internal/api/s2s/user/userget_test.go @@ -145,7 +145,7 @@ func (suite *UserGetTestSuite) TestGetUser() { // convert person to account // since this account is already known, we should get a pretty full model of it from the conversion - a, err := suite.tc.ASRepresentationToAccount(person) + a, err := suite.tc.ASRepresentationToAccount(person, false) assert.NoError(suite.T(), err) assert.EqualValues(suite.T(), targetAccount.Username, a.Username) } |