Skip to content

Commit

Permalink
Revert "レスポンスにサムネイル情報追加"
Browse files Browse the repository at this point in the history
This reverts commit e4494ee.
  • Loading branch information
azbcww committed Nov 27, 2023
1 parent 9069946 commit 96ed273
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 45 deletions.
35 changes: 0 additions & 35 deletions router/v3/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,38 +623,3 @@ func formatStampPalettes(cfs []*model.StampPalette) []*StampPalette {
sort.Slice(res, func(i, j int) bool { return res[i].ID.String() < res[j].ID.String() })
return res
}

type StampInfo struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
CreatorID uuid.UUID `json:"creatorId"`
FileID uuid.UUID `json:"fileId"`
IsUnicode bool `json:"isUnicode"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt time.Time `json:"-"`
Thumbnails []model.FileThumbnail `json:"thumbnails"`
}

func formatStampInfo(stamp *model.Stamp, thumb []model.FileThumbnail) *StampInfo {
si := &StampInfo{
ID: stamp.ID,
Name: stamp.Name,
CreatorID: stamp.CreatorID,
FileID: stamp.FileID,
IsUnicode: stamp.IsUnicode,
CreatedAt: stamp.CreatedAt,
UpdatedAt: stamp.UpdatedAt,
DeletedAt: stamp.DeletedAt.Time,
Thumbnails: thumb,
}
return si
}

func formatStampInfos(stamps []*model.Stamp, thumbs [][]model.FileThumbnail) []*StampInfo {
result := make([]*StampInfo, len(stamps))
for i, stamp := range stamps {
result[i] = formatStampInfo(stamp, thumbs[i])
}
return result
}
11 changes: 1 addition & 10 deletions router/v3/stamps.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/gofrs/uuid"
"github.com/labstack/echo/v4"

"github.com/traPtitech/traQ/model"
"github.com/traPtitech/traQ/repository"
"github.com/traPtitech/traQ/router/consts"
"github.com/traPtitech/traQ/router/extension"
Expand Down Expand Up @@ -72,15 +71,7 @@ func (h *Handlers) GetStamps(c echo.Context) error {
return herror.InternalServerError(err)
}

thumbs := make([][]model.FileThumbnail, len(stamps))
for i, stamp := range stamps {
ts, err := h.Repo.GetFileMeta(stamp.FileID)
if err != nil {
return herror.InternalServerError(err)
}
thumbs[i] = ts.Thumbnails
}
return extension.ServeJSONWithETag(c, formatStampInfos(stamps, thumbs))
return extension.ServeJSONWithETag(c, stamps)
}

// CreateStamp POST /stamps
Expand Down

0 comments on commit 96ed273

Please sign in to comment.