47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
|
|
package threads_account
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
domusecase "haixun-backend/internal/model/threads_account/domain/usecase"
|
||
|
|
"haixun-backend/internal/svc"
|
||
|
|
"haixun-backend/internal/types"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ImportThreadsAccountSessionLogic struct {
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewImportThreadsAccountSessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImportThreadsAccountSessionLogic {
|
||
|
|
return &ImportThreadsAccountSessionLogic{ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *ImportThreadsAccountSessionLogic) ImportThreadsAccountSession(
|
||
|
|
req *types.ThreadsAccountPath,
|
||
|
|
body *types.ImportThreadsAccountSessionReq,
|
||
|
|
) (*types.ImportThreadsAccountSessionData, error) {
|
||
|
|
tenantID, uid, err := actorFrom(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
result, err := l.svcCtx.ThreadsAccount.ImportBrowserSession(l.ctx, domusecase.ImportBrowserSessionRequest{
|
||
|
|
TenantID: tenantID,
|
||
|
|
OwnerUID: uid,
|
||
|
|
AccountID: req.ID,
|
||
|
|
StorageState: body.StorageState,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.ImportThreadsAccountSessionData{
|
||
|
|
Success: true,
|
||
|
|
Valid: result.Valid,
|
||
|
|
Synced: result.Synced,
|
||
|
|
AccountID: result.AccountID,
|
||
|
|
Username: result.Username,
|
||
|
|
Message: result.Message,
|
||
|
|
UpdateAt: result.UpdateAt,
|
||
|
|
}, nil
|
||
|
|
}
|