fix: publish issues

This commit is contained in:
Rogee
2024-09-05 17:33:07 +08:00
parent f849bbcef0
commit 81c60f2e9d
2 changed files with 9 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ func publishCmd(ctx context.Context) error {
// publish item
if err := publish(ctx, msg); err != nil {
return errors.Wrap(err, "failed to publish")
return errors.Wrapf(err, "failed to publish id: %d", msg.ChannelMessages.ID)
}
_, err := tbl.UPDATE().SET(tbl.Published.SET(Bool(true))).WHERE(tbl.ID.EQ(Int64(msg.ChannelMessages.ID))).ExecContext(ctx, db)
@@ -110,6 +110,10 @@ func publish(_ context.Context, msg publishMsg) error {
continue
}
if file == "" {
continue
}
filepath := filepath.Join(config.C.Output, file)
b, err := os.ReadFile(filepath)
if err != nil {

View File

@@ -60,6 +60,10 @@ func Post(pd PostData) error {
return errors.New("post memo failed, body: " + resp.String())
}
if len(pd.Resources) == 0 {
return nil
}
type Resources struct {
Resources []Resource `json:"resources"`
}