mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Show info for pending replies, allow implicit accept of pending replies (#3322)
* [feature] Allow implicit accept of pending replies * update wording
This commit is contained in:
@@ -19,6 +19,7 @@ package typeutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/url"
|
||||
@@ -30,6 +31,8 @@ import (
|
||||
"github.com/k3a/html2text"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/language"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
@@ -187,6 +190,47 @@ func placeholderAttachments(arr []*apimodel.Attachment) (string, []*apimodel.Att
|
||||
return text.SanitizeToHTML(note.String()), arr
|
||||
}
|
||||
|
||||
func (c *Converter) pendingReplyNote(
|
||||
ctx context.Context,
|
||||
s *gtsmodel.Status,
|
||||
) (string, error) {
|
||||
intReq, err := c.state.DB.GetInteractionRequestByInteractionURI(ctx, s.URI)
|
||||
if err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||
// Something's gone wrong.
|
||||
err := gtserror.Newf("db error getting interaction request for %s: %w", s.URI, err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
// No interaction request present
|
||||
// for this status. Race condition?
|
||||
if intReq == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var (
|
||||
proto = config.GetProtocol()
|
||||
host = config.GetHost()
|
||||
|
||||
// Build the settings panel URL at which the user
|
||||
// can view + approve/reject the interaction request.
|
||||
//
|
||||
// Eg., https://example.org/settings/user/interaction_requests/01J5QVXCCEATJYSXM9H6MZT4JR
|
||||
settingsURL = proto + "://" + host + "/settings/user/interaction_requests/" + intReq.ID
|
||||
)
|
||||
|
||||
var note strings.Builder
|
||||
note.WriteString(`<hr>`)
|
||||
note.WriteString(`<p><i lang="en">ℹ️ Note from ` + host + `: `)
|
||||
note.WriteString(`This reply is pending your approval. You can quickly accept it by liking, boosting or replying to it. You can also accept or reject it at the following link: `)
|
||||
note.WriteString(`<a href="` + settingsURL + `" `)
|
||||
note.WriteString(`rel="noreferrer noopener" target="_blank">`)
|
||||
note.WriteString(settingsURL)
|
||||
note.WriteString(`</a>.`)
|
||||
note.WriteString(`</i></p>`)
|
||||
|
||||
return text.SanitizeToHTML(note.String()), nil
|
||||
}
|
||||
|
||||
// ContentToContentLanguage tries to
|
||||
// extract a content string and language
|
||||
// tag string from the given intermediary
|
||||
|
Reference in New Issue
Block a user