Implementing quote posts
An overview of quote post APIs and UX guidelines.
API additions for quote posts
The new APIs described below are available starting with mastodon API version 7.
New attributes to existing entities
- the Status entity has a new
quote_approvalattribute, holding a QuoteApproval entity - the Status entity also has an additional
quotes_countattribute counting the number of accepted quotes - the CredentialAccount entity has an additional
source[quote_policy]attribute holding the default quote policy for the user. One ofpublic,followersandnobody - the response to
GET /api/v1/preferenceshas a new attributeposting:default:quote_policyholding the default quote policy for the user. One ofpublic,followersandnobody.
New notification types
Mastodon 4.5 introduces two new notification types:
quote: Someone quoted one of your posts. This means the quote post has been automatically accepted by Mastodon (Mastodon does not offer its user manual approval). The quote post is in thestatusattribute.quoted_update: A status you have quoted has been edited. This is similar toupdate, exceptstatusholds your quote post, not the post you have quoted. There is at this time no notification for a post quoting you being edited.
Those two notification types are also new alerts keys for requests to the /api/v1/push endpoint.
New parameters to existing endpoints
The following endpoints have new parameters:
POST /api/v1/statuseshas two new optional parameters:quoted_status_id: the identifier of the status to quote This will raise an error if the current user does not have access to this status, or if Mastodon knows for sure the policy disallows it.
Unless the quoted post is on the same server, the quote will be in pending state until it is explicitly accepted; quoting a private post is only possible in a private quote.
Private Mentions cannot be quoted.
Mastodon will not allow sending quotes in Private Mentions if the quote author is not also explicitly mentioned in the Private Mention.
A<p class="quote-inline">RE: <a href="…">…</a></p>link will be prepended to the body by the server for backward compatibility purposes if the body of the post does not already include a link to the quoted post. (This prepended paragraph will be hidden by the Mastodon Web UI)quote_approval_policy: a string, one ofpublic,followersornobody; if omitted, it will use the user’s default settings; if the status’ visibility isprivateordirect, this parameter will be ignored and the policy be set tonobody
PUT /api/v1/statuses/:idhas one new parameter:quote_approval_policy: a string, one ofpublic,followersornobody; if omitted, it will use the user’s default settings; if the status’ visibility isprivateordirect, this parameter will be ignored and the policy be set tonobody
PATCH /api/v1/accounts/update_credentialshas one new parameter:source[quote_policy]: a string, one ofpublic,followersornobody, setting the default quote policy when making new posts
New endpoints
GET /api/v1/statuses/:id/quotes: returns a list of posts quoting the status specified byid; requires a logged-in userPOST /api/v1/statuses/:id/quotes/:quoting_status_id/revoke: revoke quote authorization of postquoting_status_id, requires the status identified byidto be owned by the current userPUT /api/v1/statuses/:id/interaction_policy: use parameterquote_approval_policyto update the quote policy of a status without going through the entire edit flow
General recommendations for clients
Generally speaking, a rough order of priorities for implementing quote-post related features should be the following:
- displaying quote posts, as not doing that may cause a loss of meaning when displaying posts that are intended to be quotes
- handling quote notifications and offering to revoke quotes, as users who did not change the default posting setting will be quotable
- handling changing the quote policy of new and existing posts
- handling authoring of quote posts
Displaying quote posts
Displaying quote posts should be fairly straightforward, given the [Quote]/entities/Quote/ and ShallowQuote entities already contain all the pre-processed information.
Don’t forget to apply filters to quoted posts as well. In this regard, the context type is inherited from the quoting post (i.e. if it’s in a home timeline, the filter for home timelines should apply), and we have decided for the Mastodon Web UI to still show the quoting post if the quoted post matches a hide action filter but not the quoting post. In this case, the Mastodon Web UI hides the quoted post with “Hidden due to one of your filters”.
We do not recommend displaying quotes more than 1 level deep, and recommend having a placeholder instead:
If you do decide to handle deeper quotes, be mindful of potential infinite recursion.
Additionally, if a status has a quote, you should remove/hide from its contents any element with the quote-inline CSS class, as this will be used for fallback and will otherwise be redundant.
Interpreting quote policies
While Mastodon currently only allows setting very straightforward quote policies (only automatic approval, public, followers or nobody), the underlying protocol allows for both automatic approval and manual approval policies, and allows each of these policies to list arbitrary accounts. Mastodon has chosen to support only a subset of that for implementation complexity and database storage reasons, but will still expose policies with more granularity than it allows setting.
In particular, it supports the split between automatic and manual policies, and will also record when one of these sub-policies is too complex to be accurately represented by Mastodon. This will be represented as an unsupported_policy value in the sub-policy.
Through the current_user attribute discussed above, Mastodon will tell API consumers if they are denied the ability to quote a post, if the approval will be automatic, if the quote approval will be manual, or if it is unknown to Mastodon. That last case should probably be treated as denied, unless you target “power users” who want the most accurate representation possible and be able to author a quote even if it will be likely rejected.
The automatic and manual lists can be used to convey the policy as accurately possible to users.
For reference, the Mastodon Web UI uses the current_user, automatic and manual values as follow:
- if
current_userisautomatic, allow quoting the post and label the button “Quote” - if the
current_userismanual, allow quoting the post and label the button “Request to quote” / “Author will manually review” - if the
current_userisunknownordenied, disallow quoting, and display either “Only followers can quote this post” or “You are not allowed to quote this post” depending on the presence offollowersin the policies
Setting quote policies
As discussed above, while the underlying protocol allows for more complex policies, Mastodon only supports setting a few predefined policies:
public(“Anybody can quote”): anybody except blocked users will be able to quotefollowers(“Only followers can quote”): only followers and the author will be able to quotenobody(“Just me”): only the author will be able to quote
The author is always allowed to quote themselves (except for private mentions), and blocked users are never allowed to quote (Mastodon will automatically reject their quotes). Approval is automatically handled by Mastodon, meaning there is no manual authorization for clients (but there is a posteriori removal of quotes).
Mastodon will always set the policy of private (“followers-only”) and direct (“private mentions”) posts to nobody (“Just me”), but the UI should be mindful of these limits to avoid user confusion.
Authoring quote posts
Mastodon 4.5 lets people quote posts if the policy allows it. It doesn’t allow adding a poll or media attachment together with a quote, so clients should be mindful of that. Editing a post can’t remove or change a quote.
Last updated