-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIGraphCommentSystem.cs
165 lines (138 loc) · 5.04 KB
/
IGraphCommentSystem.cs
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using System.Collections.Generic;
using NFX.DataAccess.Distributed;
using NFX.Glue;
using Agni.Contracts;
namespace Agni.Social.Graph
{
[Glued]
[LifeCycle(ServerInstanceMode.Singleton)]
public interface IGraphCommentSystem : IAgniService
{
/// <summary>
/// Create new comment with rating
/// </summary>
/// <param name="gAuthorNode">GDID of autor node</param>
/// <param name="gTargetNode">GDID of target node</param>
/// <param name="dimension">Scope for rating</param>
/// <param name="content">Content</param>
/// <param name="data">Byte array of data</param>
/// <param name="publicationState">State of publication</param>
/// <param name="value">star 1-2-3-4-5</param>
/// <param name="timeStamp">Time of current action</param>
/// <returns>Comment</returns>
Comment Create(GDID gAuthorNode,
GDID gTargetNode,
string dimension,
string content,
byte[] data,
PublicationState publicationState,
RatingValue value = RatingValue.Undefined,
DateTime? timeStamp = null);
/// <summary>
/// Make response to target commentary
/// </summary>
/// <param name="gAuthorNode">Author</param>
/// <param name="parent">Parent commentary</param>
/// <param name="content">Content of commentary</param>
/// <param name="data">Byte Array</param>
/// <returns>New CommentID</returns>
Comment Respond(GDID gAuthorNode, CommentID parent, string content, byte[] data);
/// <summary>
/// Updates existing rating by ID
/// </summary>
GraphChangeStatus Update(CommentID ratingId, RatingValue value, string content, byte[] data);
/// <summary>
/// Delete comment
/// </summary>
/// <param name="commentId">Existing Comment ID</param>
GraphChangeStatus DeleteComment(CommentID commentId);
/// <summary>
/// Updates likes/dislikes
/// </summary>
GraphChangeStatus Like(CommentID commentId, int deltaLike, int deltaDislike);
/// <summary>
/// Check if target node has existing comment, made by author
/// </summary>
/// <param name="gNode">Target node</param>
/// <param name="gAuthor">Author</param>
/// <param name="dimension">Scope of comments</param>
bool IsCommentedByAuthor(GDID gNode, GDID gAuthor, string dimension);
/// <summary>
/// Returns summary ratings per node, dimensions and create date (rating epochs)
/// </summary>
IEnumerable<SummaryRating> GetNodeSummaries(GDID gNode);
/// <summary>
/// Returns comments for Target Node
/// </summary>
IEnumerable<Comment> Fetch(CommentQuery query);
/// <summary>
/// Returns comments for comment by Comment ID
/// </summary>
IEnumerable<Comment> FetchResponses(CommentID commentId);
/// <summary>
/// Returns comment complaints by comment ID
/// </summary>
/// <param name="commentId"></param>
/// <returns></returns>
IEnumerable<Complaint> FetchComplaints(CommentID commentId);
/// <summary>
/// Return comment by comment ID
/// </summary>
Comment GetComment(CommentID commentId);
/// <summary>
/// Complain about comment
/// </summary>
GraphChangeStatus Complain(CommentID commentId, GDID gAuthorNode, string kind, string message);
/// <summary>
/// Justify moderated comment
/// </summary>
GraphChangeStatus Justify(CommentID commentID);
}
public interface IGraphCommentSystemClient : IGraphCommentSystem, IAgniServiceClient
{
//todo Add async versions
}
public struct CommentQuery : IEquatable<CommentQuery>
{
//todo design
public const int COMMENT_BLOCK_SIZE = 32;
public static CommentQuery MakeNew(GDID gTargetNode, string dimension, CommentOrderType orderType, bool asc, DateTime asOfDate, int blockIndex)
{
return new CommentQuery(gTargetNode, dimension, orderType, asc, asOfDate, blockIndex);
}
internal CommentQuery(GDID gTargetNode, string dimension, CommentOrderType orderType, bool asc, DateTime asOfDate, int blockIndex)
{
G_TargetNode = gTargetNode;
Dimension = dimension;
OrderType = orderType;
Ascending = asc;
AsOfDate = asOfDate;
BlockIndex = blockIndex;
}
public readonly GDID G_TargetNode;
public readonly string Dimension;
public readonly CommentOrderType OrderType;
public readonly bool Ascending;
public readonly DateTime AsOfDate;
public readonly int BlockIndex;
public bool Equals(CommentQuery other)
{
return this.G_TargetNode == other.G_TargetNode &&
this.Dimension == other.Dimension &&
this.OrderType == other.OrderType &&
this.Ascending == other.Ascending &&
this.BlockIndex == other.BlockIndex
;
}
public override int GetHashCode()
{
return G_TargetNode.GetHashCode() ^ BlockIndex;
}
public override bool Equals(object obj)
{
if (! (obj is CommentQuery)) return false;
return Equals((CommentQuery)obj);
}
}
}