mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-11 19:37:30 -06:00
some updates to statuses and accounts
This commit is contained in:
parent
30718d7d10
commit
0b8b0948f6
11 changed files with 251 additions and 132 deletions
|
|
@ -32,6 +32,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// LimitKey is for setting the return amount limit for eg., requesting an account's statuses
|
||||
LimitKey = "limit"
|
||||
// IDKey is the key to use for retrieving account ID in requests
|
||||
IDKey = "id"
|
||||
// BasePath is the base API path for this module
|
||||
|
|
@ -42,6 +44,8 @@ const (
|
|||
VerifyPath = BasePath + "/verify_credentials"
|
||||
// UpdateCredentialsPath is for updating account credentials
|
||||
UpdateCredentialsPath = BasePath + "/update_credentials"
|
||||
// GetStatusesPath is for showing an account's statuses
|
||||
GetStatusesPath = BasePathWithID + "/statuses"
|
||||
)
|
||||
|
||||
// Module implements the ClientAPIModule interface for account-related actions
|
||||
|
|
@ -65,6 +69,7 @@ func (m *Module) Route(r router.Router) error {
|
|||
r.AttachHandler(http.MethodPost, BasePath, m.AccountCreatePOSTHandler)
|
||||
r.AttachHandler(http.MethodGet, BasePathWithID, m.muxHandler)
|
||||
r.AttachHandler(http.MethodPatch, BasePathWithID, m.muxHandler)
|
||||
r.AttachHandler(http.MethodGet, GetStatusesPath, m.AccountStatusesGETHandler)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
61
internal/api/client/account/statuses.go
Normal file
61
internal/api/client/account/statuses.go
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
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 account
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
)
|
||||
|
||||
// AccountStatusesGETHandler serves the statuses of the requested account, if they're visible to the requester.
|
||||
func (m *Module) AccountStatusesGETHandler(c *gin.Context) {
|
||||
authed, err := oauth.Authed(c, false, false, false, false)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
|
||||
return
|
||||
}
|
||||
|
||||
targetAcctID := c.Param(IDKey)
|
||||
if targetAcctID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
|
||||
return
|
||||
}
|
||||
|
||||
limit := 30
|
||||
limitString := c.Query(LimitKey)
|
||||
if limitString != "" {
|
||||
l, err := strconv.ParseInt(limitString, 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "couldn't parse limit query param"})
|
||||
return
|
||||
}
|
||||
limit = int(l)
|
||||
}
|
||||
|
||||
statuses, errWithCode := m.processor.AccountStatusesGet(authed, targetAcctID, limit)
|
||||
if errWithCode != nil {
|
||||
c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, statuses)
|
||||
}
|
||||
|
|
@ -86,23 +86,23 @@ type Status struct {
|
|||
// It should be used at the path https://mastodon.example/api/v1/statuses
|
||||
type StatusCreateRequest struct {
|
||||
// Text content of the status. If media_ids is provided, this becomes optional. Attaching a poll is optional while status is provided.
|
||||
Status string `form:"status"`
|
||||
Status string `form:"status" json:"status" xml:"status"`
|
||||
// Array of Attachment ids to be attached as media. If provided, status becomes optional, and poll cannot be used.
|
||||
MediaIDs []string `form:"media_ids" json:"media_ids" xml:"media_ids"`
|
||||
// Poll to include with this status.
|
||||
Poll *PollRequest `form:"poll"`
|
||||
Poll *PollRequest `form:"poll" json:"poll" xml:"poll"`
|
||||
// ID of the status being replied to, if status is a reply
|
||||
InReplyToID string `form:"in_reply_to_id"`
|
||||
InReplyToID string `form:"in_reply_to_id" json:"in_reply_to_id" xml:"in_reply_to_id"`
|
||||
// Mark status and attached media as sensitive?
|
||||
Sensitive bool `form:"sensitive"`
|
||||
Sensitive bool `form:"sensitive" json:"sensitive" xml:"sensitive"`
|
||||
// Text to be shown as a warning or subject before the actual content. Statuses are generally collapsed behind this field.
|
||||
SpoilerText string `form:"spoiler_text"`
|
||||
SpoilerText string `form:"spoiler_text" json:"spoiler_text" xml:"spoiler_text"`
|
||||
// Visibility of the posted status. Enumerable oneOf public, unlisted, private, direct.
|
||||
Visibility Visibility `form:"visibility"`
|
||||
Visibility Visibility `form:"visibility" json:"visibility" xml:"visibility"`
|
||||
// ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future.
|
||||
ScheduledAt string `form:"scheduled_at"`
|
||||
ScheduledAt string `form:"scheduled_at" json:"scheduled_at" xml:"scheduled_at"`
|
||||
// ISO 639 language code for this status.
|
||||
Language string `form:"language"`
|
||||
Language string `form:"language" json:"language" xml:"language"`
|
||||
}
|
||||
|
||||
// Visibility denotes the visibility of this status to other users
|
||||
|
|
@ -130,13 +130,13 @@ type AdvancedStatusCreateForm struct {
|
|||
// to the standard mastodon-compatible ones.
|
||||
type AdvancedVisibilityFlagsForm struct {
|
||||
// The gotosocial visibility model
|
||||
VisibilityAdvanced *string `form:"visibility_advanced"`
|
||||
VisibilityAdvanced *string `form:"visibility_advanced" json:"visibility_advanced" xml:"visibility_advanced"`
|
||||
// This status will be federated beyond the local timeline(s)
|
||||
Federated *bool `form:"federated"`
|
||||
Federated *bool `form:"federated" json:"federated" xml:"federated"`
|
||||
// This status can be boosted/reblogged
|
||||
Boostable *bool `form:"boostable"`
|
||||
Boostable *bool `form:"boostable" json:"boostable" xml:"boostable"`
|
||||
// This status can be replied to
|
||||
Replyable *bool `form:"replyable"`
|
||||
Replyable *bool `form:"replyable" json:"replyable" xml:"replyable"`
|
||||
// This status can be liked/faved
|
||||
Likeable *bool `form:"likeable"`
|
||||
Likeable *bool `form:"likeable" json:"likeable" xml:"likeable"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue