返回 AiToEarn
engagement-task.schema.ts
根目录 / project / aitoearn-backend / libs / channel-db / src / schemas / engagement-task.schema.ts
1 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2 import { DEFAULT_SCHEMA_OPTIONS } from '../channel-db.constants'
3 import { BaseTemp } from './time.tamp'
4
5 export enum EngagementTaskStatus {
6 CREATED = 'CREATED',
7 DISTRIBUTED = 'DISTRIBUTED',
8 IN_PROGRESS = 'IN_PROGRESS',
9 COMPLETED = 'COMPLETED',
10 PAUSED = 'PAUSED',
11 CANCELED = 'CANCELED',
12 FAILED = 'FAILED',
13 PARTIALLY_COMPLETED = 'PARTIALLY_COMPLETED',
14 }
15 export enum EngagementTaskType {
16 LIKE = 'LIKE',
17 FAVORITE = 'FAVORITE',
18 COMMENT = 'COMMENT', // comment on post
19 REPLY = 'REPLY', // reply to comment
20 }
21
22 export enum EngagementTargetScope {
23 ALL = 'ALL',
24 PARTIAL = 'PARTIAL',
25 }
26
27 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'engagementTask' })
28 export class EngagementTask extends BaseTemp {
29 id: string
30 @Prop({
31 required: true,
32 })
33 accountId: string
34
35 @Prop({
36 required: true,
37 })
38 userId: string
39
40 @Prop({
41 required: true,
42 })
43 postId: string
44
45 @Prop({
46 required: true,
47 })
48 platform: string
49
50 @Prop({
51 required: true,
52 default: '',
53 })
54 model: string
55
56 @Prop({
57 required: false,
58 default: '',
59 })
60 prompt: string
61
62 @Prop({
63 required: true,
64 enum: EngagementTaskType,
65 default: EngagementTaskType.REPLY,
66 })
67 taskType: EngagementTaskType
68
69 @Prop({
70 required: true,
71 enum: EngagementTargetScope,
72 default: EngagementTargetScope.ALL,
73 })
74 targetScope: EngagementTargetScope
75
76 @Prop({
77 required: false,
78 type: [String],
79 })
80 targetIds: string[]
81
82 @Prop({
83 required: true,
84 enum: EngagementTaskStatus,
85 default: EngagementTaskStatus.CREATED,
86 })
87 status: EngagementTaskStatus
88
89 @Prop({
90 required: true,
91 default: 0,
92 })
93 subTaskCount: number
94
95 @Prop({
96 required: true,
97 default: 0,
98 })
99 completedSubTaskCount: number
100
101 @Prop({
102 required: true,
103 default: 0,
104 })
105 failedSubTaskCount: number
106 }
107
108 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'engagementSubTask' })
109 export class EngagementSubTask extends BaseTemp {
110 id: string
111
112 @Prop({
113 required: true,
114 index: true,
115 type: String,
116 })
117 taskId: string
118
119 @Prop({
120 required: true,
121 })
122 accountId: string
123
124 @Prop({
125 required: true,
126 })
127 userId: string
128
129 @Prop({
130 required: true,
131 })
132 postId: string
133
134 @Prop({
135 required: true,
136 })
137 commentId: string
138
139 @Prop({
140 required: true,
141 default: '',
142 })
143 commentContent: string
144
145 @Prop({
146 required: false,
147 default: '',
148 })
149 replyContent: string
150
151 @Prop({
152 required: true,
153 })
154 platform: string
155
156 @Prop({
157 required: true,
158 enum: EngagementTaskStatus,
159 default: EngagementTaskStatus.CREATED,
160 })
161 status: EngagementTaskStatus
162 }
163 export const EngagementTaskSchema = SchemaFactory.createForClass(EngagementTask)
164 export const EngagementSubTaskSchema = SchemaFactory.createForClass(EngagementSubTask)
165
165 lines TYPESCRIPT