Fix up missing avatars
This commit is contained in:
parent
6dd11aa970
commit
475716322f
|
@ -227,7 +227,6 @@ func FetchInternedMessage(ctx context.Context, dbConn db.ConnOrTx, msgId string)
|
||||||
LEFT JOIN discord_message_content AS content ON content.message_id = message.id
|
LEFT JOIN discord_message_content AS content ON content.message_id = message.id
|
||||||
LEFT JOIN discord_user AS duser ON duser.userid = message.user_id
|
LEFT JOIN discord_user AS duser ON duser.userid = message.user_id
|
||||||
LEFT JOIN hmn_user AS hmnuser ON hmnuser.id = duser.hmn_user_id
|
LEFT JOIN hmn_user AS hmnuser ON hmnuser.id = duser.hmn_user_id
|
||||||
LEFT JOIN asset AS hmnuser_avatar ON hmnuser_avatar.id = hmnuser.avatar_asset_id
|
|
||||||
WHERE message.id = $1
|
WHERE message.id = $1
|
||||||
`,
|
`,
|
||||||
msgId,
|
msgId,
|
||||||
|
|
|
@ -141,8 +141,10 @@ func FetchThreads(
|
||||||
|
|
||||||
type resultRow struct {
|
type resultRow struct {
|
||||||
ThreadAndStuff
|
ThreadAndStuff
|
||||||
ThreadLastReadTime *time.Time `db:"tlri.lastread"`
|
FirstPostAuthorAvatar *models.Asset `db:"first_author_avatar"`
|
||||||
ForumLastReadTime *time.Time `db:"slri.lastread"`
|
LastPostAuthorAvatar *models.Asset `db:"last_author_avatar"`
|
||||||
|
ThreadLastReadTime *time.Time `db:"tlri.lastread"`
|
||||||
|
ForumLastReadTime *time.Time `db:"slri.lastread"`
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := db.Query[resultRow](ctx, dbConn, qb.String(), qb.Args()...)
|
rows, err := db.Query[resultRow](ctx, dbConn, qb.String(), qb.Args()...)
|
||||||
|
@ -152,6 +154,13 @@ func FetchThreads(
|
||||||
|
|
||||||
result := make([]ThreadAndStuff, len(rows))
|
result := make([]ThreadAndStuff, len(rows))
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
|
if row.FirstPostAuthor != nil {
|
||||||
|
row.FirstPostAuthor.AvatarAsset = row.FirstPostAuthorAvatar
|
||||||
|
}
|
||||||
|
if row.LastPostAuthor != nil {
|
||||||
|
row.LastPostAuthor.AvatarAsset = row.LastPostAuthorAvatar
|
||||||
|
}
|
||||||
|
|
||||||
hasRead := false
|
hasRead := false
|
||||||
if currentUser != nil && currentUser.MarkedAllReadAt.After(row.LastPost.PostDate) {
|
if currentUser != nil && currentUser.MarkedAllReadAt.After(row.LastPost.PostDate) {
|
||||||
hasRead = true
|
hasRead = true
|
||||||
|
@ -320,8 +329,11 @@ func FetchPosts(
|
||||||
|
|
||||||
type resultRow struct {
|
type resultRow struct {
|
||||||
PostAndStuff
|
PostAndStuff
|
||||||
ThreadLastReadTime *time.Time `db:"tlri.lastread"`
|
AuthorAvatar *models.Asset `db:"author_avatar"`
|
||||||
ForumLastReadTime *time.Time `db:"slri.lastread"`
|
EditorAvatar *models.Asset `db:"editor_avatar"`
|
||||||
|
ReplyAuthorAvatar *models.Asset `db:"reply_author_avatar"`
|
||||||
|
ThreadLastReadTime *time.Time `db:"tlri.lastread"`
|
||||||
|
ForumLastReadTime *time.Time `db:"slri.lastread"`
|
||||||
}
|
}
|
||||||
|
|
||||||
qb.Add(
|
qb.Add(
|
||||||
|
@ -410,6 +422,16 @@ func FetchPosts(
|
||||||
|
|
||||||
result := make([]PostAndStuff, len(rows))
|
result := make([]PostAndStuff, len(rows))
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
|
if row.Author != nil {
|
||||||
|
row.Author.AvatarAsset = row.AuthorAvatar
|
||||||
|
}
|
||||||
|
if row.Editor != nil {
|
||||||
|
row.Editor.AvatarAsset = row.EditorAvatar
|
||||||
|
}
|
||||||
|
if row.ReplyAuthor != nil {
|
||||||
|
row.ReplyAuthor.AvatarAsset = row.ReplyAuthorAvatar
|
||||||
|
}
|
||||||
|
|
||||||
hasRead := false
|
hasRead := false
|
||||||
if currentUser != nil && currentUser.MarkedAllReadAt.After(row.Post.PostDate) {
|
if currentUser != nil && currentUser.MarkedAllReadAt.After(row.Post.PostDate) {
|
||||||
hasRead = true
|
hasRead = true
|
||||||
|
|
Loading…
Reference in New Issue