@@ -11,6 +11,7 @@ import (
1111 appratelimit "github.com/BetaGoRobot/BetaGo-Redefine/internal/application/lark/ratelimit"
1212 scheduleapp "github.com/BetaGoRobot/BetaGo-Redefine/internal/application/lark/schedule"
1313 apppermission "github.com/BetaGoRobot/BetaGo-Redefine/internal/application/permission"
14+ "github.com/BetaGoRobot/BetaGo-Redefine/internal/infrastructure/lark_dal/larkmsg"
1415 cardactionproto "github.com/BetaGoRobot/BetaGo-Redefine/pkg/cardaction"
1516 "github.com/larksuite/oapi-sdk-go/v3/event/dispatcher/callback"
1617)
@@ -117,6 +118,8 @@ func handleFeatureAction(ctx context.Context, actionCtx *Context) (*callback.Car
117118 }
118119 card , cardErr := appconfig .BuildFeatureCardWithOptions (ctx , actionCtx .ChatID (), actionCtx .OpenID (), appconfig.FeatureCardViewOptions {
119120 LastModifierOpenID : actionCtx .OpenID (),
121+ MessageID : actionCtx .MessageID (),
122+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
120123 })
121124 if cardErr != nil {
122125 return InfoToast (resp .Message ), nil
@@ -139,6 +142,8 @@ func handleFeatureView(ctx context.Context, actionCtx *Context) (*callback.CardA
139142 }
140143 card , err := appconfig .BuildFeatureCardWithOptions (ctx , chatID , openID , appconfig.FeatureCardViewOptions {
141144 LastModifierOpenID : req .LastModifierOpenID ,
145+ MessageID : actionCtx .MessageID (),
146+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
142147 })
143148 if err != nil {
144149 return ErrorToast (err .Error ()), nil
@@ -160,6 +165,8 @@ func handleConfigAction(ctx context.Context, actionCtx *Context) (*callback.Card
160165 card , cardErr := appconfig .BuildConfigCardJSONWithOptions (ctx , req .Scope , req .ChatID , req .OpenID , appconfig.ConfigCardViewOptions {
161166 BypassCache : true ,
162167 LastModifierOpenID : actionCtx .OpenID (),
168+ MessageID : actionCtx .MessageID (),
169+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
163170 })
164171 if cardErr != nil {
165172 return InfoToast (resp .Message ), nil
@@ -175,6 +182,8 @@ func handleConfigView(ctx context.Context, actionCtx *Context) (*callback.CardAc
175182 card , err := appconfig .BuildConfigCardJSONWithOptions (ctx , req .Scope , req .ChatID , req .OpenID , appconfig.ConfigCardViewOptions {
176183 BypassCache : true ,
177184 LastModifierOpenID : req .LastModifierOpenID ,
185+ MessageID : actionCtx .MessageID (),
186+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
178187 })
179188 if err != nil {
180189 return ErrorToast (err .Error ()), nil
@@ -195,6 +204,8 @@ func handlePermissionAction(ctx context.Context, actionCtx *Context) (*callback.
195204 }
196205 card , cardErr := apppermission .BuildPermissionCardJSONWithOptions (ctx , actionCtx .ChatID (), actionCtx .OpenID (), req .TargetOpenID , apppermission.PermissionCardViewOptions {
197206 LastModifierOpenID : actionCtx .OpenID (),
207+ MessageID : actionCtx .MessageID (),
208+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
198209 })
199210 if cardErr != nil {
200211 return InfoToast (resp .Message ), nil
@@ -209,6 +220,8 @@ func handlePermissionView(ctx context.Context, actionCtx *Context) (*callback.Ca
209220 }
210221 card , err := apppermission .BuildPermissionCardJSONWithOptions (ctx , actionCtx .ChatID (), actionCtx .OpenID (), req .TargetOpenID , apppermission.PermissionCardViewOptions {
211222 LastModifierOpenID : req .LastModifierOpenID ,
223+ MessageID : actionCtx .MessageID (),
224+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
212225 })
213226 if err != nil {
214227 return ErrorToast (err .Error ()), nil
@@ -228,7 +241,10 @@ func handleRateLimitView(ctx context.Context, actionCtx *Context) (*callback.Car
228241 if chatID == "" && actionCtx .MetaData != nil {
229242 chatID = strings .TrimSpace (actionCtx .MetaData .ChatID )
230243 }
231- card , err := appratelimit .BuildStatsCardJSON (ctx , chatID )
244+ card , err := appratelimit .BuildStatsCardJSONWithOptions (ctx , chatID , appratelimit.StatsCardOptions {
245+ MessageID : actionCtx .MessageID (),
246+ PendingHistory : []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )},
247+ })
232248 if err != nil {
233249 return ErrorToast (err .Error ()), nil
234250 }
@@ -245,6 +261,8 @@ func handleScheduleView(ctx context.Context, actionCtx *Context) (*callback.Card
245261 if chatID == "" && actionCtx .MetaData != nil {
246262 chatID = strings .TrimSpace (actionCtx .MetaData .ChatID )
247263 }
264+ req .View .MessageID = actionCtx .MessageID ()
265+ req .View .PendingHistory = []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )}
248266 card , err := scheduleapp .BuildTaskCardPayloadForView (ctx , chatID , req .View , true )
249267 if err != nil {
250268 return ErrorToast (err .Error ()), nil
@@ -289,6 +307,8 @@ func handleScheduleAction(ctx context.Context, actionCtx *Context) (*callback.Ca
289307 }
290308
291309 req .View .LastModifierOpenID = actorOpenID
310+ req .View .MessageID = actionCtx .MessageID ()
311+ req .View .PendingHistory = []larkmsg.CardActionHistoryRecord {larkmsg .NewCardActionHistoryRecord (actionCtx .Event )}
292312 card , cardErr := scheduleapp .BuildTaskCardPayloadForView (ctx , chatID , req .View , req .Action == scheduleapp .TaskActionDelete )
293313 if cardErr != nil {
294314 return InfoToast (message ), nil
0 commit comments