Add debug endpoint for getting replies to node id
All checks were successful
/ docker (push) Successful in 4m19s
All checks were successful
/ docker (push) Successful in 4m19s
This commit is contained in:
parent
1b0c63a3b1
commit
c9895bc9af
5 changed files with 20 additions and 5 deletions
|
@ -25,6 +25,6 @@ func (n *CollectionTargetType) Value() (driver.Value, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *CollectionTargetType) Scan(value any) error {
|
func (ct *CollectionTargetType) Scan(value any) error {
|
||||||
*ct = CollectionTargetType(value.(uint32))
|
*ct = CollectionTargetType(value.(string))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ type Note struct {
|
||||||
// Soft delete means that this entry still exists in the db, but gorm won't include it anymore unless specifically told to
|
// Soft delete means that this entry still exists in the db, but gorm won't include it anymore unless specifically told to
|
||||||
// If not null, this entry is marked as deleted
|
// If not null, this entry is marked as deleted
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
Creator User // The user that created this note
|
Creator *User // The user that created this note
|
||||||
CreatorId string // Id of the creator user
|
CreatorId string // Id of the creator user
|
||||||
Remote bool // Whether the note is originally a remote one and just "cached"
|
Remote bool // Whether the note is originally a remote one and just "cached"
|
||||||
// Raw content of the note. So without additional formatting applied
|
// Raw content of the note. So without additional formatting applied
|
||||||
|
@ -26,7 +26,7 @@ type Note struct {
|
||||||
RepliesTo sql.NullString // Url of the message this replies to
|
RepliesTo sql.NullString // Url of the message this replies to
|
||||||
Quotes sql.NullString // url of the message this note quotes
|
Quotes sql.NullString // url of the message this note quotes
|
||||||
AccessLevel NoteAccessLevel // Where to send this message to (public, home, followers, dm)
|
AccessLevel NoteAccessLevel // Where to send this message to (public, home, followers, dm)
|
||||||
Origin RemoteServer
|
Origin *RemoteServer
|
||||||
OriginId uint
|
OriginId uint
|
||||||
|
|
||||||
AttachmentRelations []NoteToAttachment `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Attachments added on to this note
|
AttachmentRelations []NoteToAttachment `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Attachments added on to this note
|
||||||
|
|
|
@ -59,7 +59,7 @@ func postAs(w http.ResponseWriter, r *http.Request) {
|
||||||
n := dbgen.Note
|
n := dbgen.Note
|
||||||
note := models.Note{
|
note := models.Note{
|
||||||
ID: shared.NewId(),
|
ID: shared.NewId(),
|
||||||
Creator: *user,
|
Creator: user,
|
||||||
CreatorId: user.ID,
|
CreatorId: user.ID,
|
||||||
RawContent: data.Content,
|
RawContent: data.Content,
|
||||||
Remote: false,
|
Remote: false,
|
||||||
|
@ -167,3 +167,17 @@ func notesFrom(w http.ResponseWriter, r *http.Request) {
|
||||||
})
|
})
|
||||||
webutils.SendJson(w, publicNotes)
|
webutils.SendJson(w, publicNotes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inReplyTo(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := hlog.FromRequest(r)
|
||||||
|
noteId := r.PathValue("id")
|
||||||
|
notes, err := dbgen.Note.
|
||||||
|
Where(dbgen.Note.RepliesTo.Eq(sql.NullString{Valid: true, String: noteId})).
|
||||||
|
Find()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Str("id", noteId).Msg("Error getting replies to note with id")
|
||||||
|
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_ = webutils.SendJson(w, notes)
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ func New(addr string) *Server {
|
||||||
handler.HandleFunc("GET /import-server", importServerInfo)
|
handler.HandleFunc("GET /import-server", importServerInfo)
|
||||||
handler.HandleFunc("GET /request-follow", kickoffFollow)
|
handler.HandleFunc("GET /request-follow", kickoffFollow)
|
||||||
handler.HandleFunc("POST /send-as", proxyMessageToTarget)
|
handler.HandleFunc("POST /send-as", proxyMessageToTarget)
|
||||||
|
handler.HandleFunc("GET /replies-to/{id}", inReplyTo)
|
||||||
web := http.Server{
|
web := http.Server{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Handler: webutils.ChainMiddlewares(
|
Handler: webutils.ChainMiddlewares(
|
||||||
|
|
|
@ -740,7 +740,7 @@ func handleCreate(w http.ResponseWriter, r *http.Request, object map[string]any)
|
||||||
dbNote := models.Note{
|
dbNote := models.Note{
|
||||||
ID: objectNote.Id,
|
ID: objectNote.Id,
|
||||||
CreatedAt: objectNote.Published,
|
CreatedAt: objectNote.Published,
|
||||||
Creator: *actingUser,
|
Creator: actingUser,
|
||||||
CreatorId: actingUser.ID,
|
CreatorId: actingUser.ID,
|
||||||
Remote: true,
|
Remote: true,
|
||||||
RawContent: objectNote.Content,
|
RawContent: objectNote.Content,
|
||||||
|
|
Loading…
Reference in a new issue