forked from NetCoreApps/CreatorKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosts.cs
More file actions
138 lines (123 loc) · 3.97 KB
/
Copy pathPosts.cs
File metadata and controls
138 lines (123 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using ServiceStack;
using System;
using System.Collections.Generic;
using CreatorKit.ServiceModel.Types;
namespace CreatorKit.ServiceModel;
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoApply(Behavior.AuditQuery)]
public class GetThreadUserData : IGet, IReturn<GetThreadUserDataResponse>
{
public int ThreadId { get; set; }
}
public class GetThreadUserDataResponse
{
public int ThreadId { get; set; }
public bool Liked { get; set; }
public List<int> UpVoted { get; set; }
public List<int> DownVoted { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
[Tag(Tag.Posts)]
[AutoApply(Behavior.AuditQuery)]
public class QueryComments : QueryDb<Comment, CommentResult>,
IJoin<Comment,AppUser>
{
public int? ThreadId { get; set; }
}
[Tag(Tag.Posts)]
public class GetThread : IGet, IReturn<GetThreadResponse>
{
public int? Id { get; set; }
public string? Url { get; set; }
}
public class GetThreadResponse
{
public Thread Result { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated, ValidateActiveUser]
[AutoApply(Behavior.AuditCreate)]
[AutoPopulate(nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
[AutoPopulate(nameof(Comment.Votes), Value = 1)]
public class CreateComment : ICreateDb<Comment>, IReturn<Comment>
{
public int ThreadId { get; set; }
public int? ReplyId { get; set; }
[ValidateLength(1,280)]
public string Content { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated, ValidateActiveUser]
[AutoApply(Behavior.AuditModify)]
[AutoFilter(QueryTerm.Ensure, nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class UpdateComment : IPatchDb<Comment>, IReturn<Comment>
{
public int Id { get; set; }
public string? Content { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated, ValidateActiveUser]
[AutoApply(Behavior.AuditSoftDelete)]
[AutoFilter(QueryTerm.Ensure, nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class DeleteComment : IDeleteDb<Comment>, IReturnVoid
{
public int Id { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoApply(Behavior.AuditCreate)]
[AutoPopulate(nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class CreateThreadLike : ICreateDb<ThreadLike>, IReturnVoid
{
public int ThreadId { get; set; }
[ValidateInclusiveBetween(-1, 1)]
public int Vote { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoFilter(QueryTerm.Ensure, nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class DeleteThreadLike : IDeleteDb<ThreadLike>, IReturn<EmptyResponse>
{
public int ThreadId { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoFilter(QueryTerm.Ensure, nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class QueryCommentVotes : QueryDb<CommentVote>
{
public int ThreadId { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoApply(Behavior.AuditCreate)]
[AutoPopulate(nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class CreateCommentVote : ICreateDb<CommentVote>, IReturnVoid
{
public int CommentId { get; set; }
[ValidateInclusiveBetween(-1, 1)]
public int Vote { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated]
[AutoFilter(QueryTerm.Ensure, nameof(Comment.AppUserId), Eval = "userAuthIntId()")]
public class DeleteCommentVote : IDeleteDb<CommentVote>, IReturnVoid
{
public int CommentId { get; set; }
}
[Tag(Tag.Posts)]
[ValidateIsAuthenticated, ValidateActiveUser]
[AutoApply(Behavior.AuditCreate)]
[AutoPopulate(nameof(CommentReport.AppUserId), Eval = "userAuthIntId()")]
[AutoPopulate(nameof(CommentReport.Moderation), Value = ModerationDecision.None)]
public class CreateCommentReport : ICreateDb<CommentReport>, IReturnVoid
{
public int CommentId { get; set; }
public PostReport PostReport { get; set; }
public string? Description { get; set; }
}
public class ValidateActiveUserAttribute : ValidateRequestAttribute
{
public ValidateActiveUserAttribute() : base("ActiveUser()") { }
}