♻️ Move the chat part of the Sphere service to the Messager service
This commit is contained in:
@@ -24,16 +24,16 @@ public class SnAccount : ModelBase
|
||||
public Guid? AutomatedId { get; set; }
|
||||
|
||||
public SnAccountProfile Profile { get; set; } = null!;
|
||||
public ICollection<SnAccountContact> Contacts { get; set; } = [];
|
||||
public ICollection<SnAccountBadge> Badges { get; set; } = [];
|
||||
public List<SnAccountContact> Contacts { get; set; } = [];
|
||||
public List<SnAccountBadge> Badges { get; set; } = [];
|
||||
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountAuthFactor> AuthFactors { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountConnection> Connections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAuthSession> Sessions { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAuthChallenge> Challenges { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAccountAuthFactor> AuthFactors { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAccountConnection> Connections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAuthSession> Sessions { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAuthChallenge> Challenges { get; set; } = [];
|
||||
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountRelationship> OutgoingRelationships { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountRelationship> IncomingRelationships { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAccountRelationship> OutgoingRelationships { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnAccountRelationship> IncomingRelationships { get; set; } = [];
|
||||
|
||||
[NotMapped] public SnSubscriptionReferenceObject? PerkSubscription { get; set; }
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class SnCheckInResult : ModelBase
|
||||
public int? RewardExperience { get; set; }
|
||||
|
||||
[Column(TypeName = "jsonb")]
|
||||
public ICollection<CheckInFortuneTip> Tips { get; set; } = new List<CheckInFortuneTip>();
|
||||
public List<CheckInFortuneTip> Tips { get; set; } = new List<CheckInFortuneTip>();
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public SnAccount Account { get; set; } = null!;
|
||||
@@ -135,7 +135,7 @@ public class DailyEventResponse
|
||||
{
|
||||
public Instant Date { get; set; }
|
||||
public SnCheckInResult? CheckInResult { get; set; }
|
||||
public ICollection<SnAccountStatus> Statuses { get; set; } = new List<SnAccountStatus>();
|
||||
public List<SnAccountStatus> Statuses { get; set; } = new List<SnAccountStatus>();
|
||||
}
|
||||
|
||||
public enum PresenceType
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SnChatMessage : ModelBase, IIdentifiedResource
|
||||
|
||||
[Column(TypeName = "jsonb")] public List<SnCloudFileReferenceObject> Attachments { get; set; } = [];
|
||||
|
||||
public ICollection<SnChatMessageReaction> Reactions { get; set; } = new List<SnChatMessageReaction>();
|
||||
public List<SnChatReaction> Reactions { get; set; } = new();
|
||||
|
||||
public Guid? RepliedMessageId { get; set; }
|
||||
public SnChatMessage? RepliedMessage { get; set; }
|
||||
@@ -66,7 +66,7 @@ public enum MessageReactionAttitude
|
||||
Negative,
|
||||
}
|
||||
|
||||
public class SnChatMessageReaction : ModelBase
|
||||
public class SnChatReaction : ModelBase
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public Guid MessageId { get; set; }
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SnChatRoom : ModelBase, IIdentifiedResource
|
||||
|
||||
[IgnoreMember]
|
||||
[JsonIgnore]
|
||||
public ICollection<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
||||
public List<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
||||
|
||||
public Guid? AccountId { get; set; }
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SnChatRoom : ModelBase, IIdentifiedResource
|
||||
|
||||
[NotMapped]
|
||||
[JsonPropertyName("members")]
|
||||
public ICollection<ChatMemberTransmissionObject> DirectMembers { get; set; } =
|
||||
public List<ChatMemberTransmissionObject> DirectMembers { get; set; } =
|
||||
new List<ChatMemberTransmissionObject>();
|
||||
|
||||
public string ResourceIdentifier => $"chatroom:{Id}";
|
||||
@@ -81,30 +81,22 @@ public class SnChatMember : ModelBase
|
||||
public SnChatRoom ChatRoom { get; set; } = null!;
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public SnAccount? Account { get; set; }
|
||||
[NotMapped] public SnAccount? Account { get; set; }
|
||||
[NotMapped] public SnAccountStatus? Status { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public SnAccountStatus? Status { get; set; }
|
||||
|
||||
[MaxLength(1024)]
|
||||
public string? Nick { get; set; }
|
||||
[MaxLength(1024)] public string? Nick { get; set; }
|
||||
|
||||
public ChatMemberNotify Notify { get; set; } = ChatMemberNotify.All;
|
||||
public Instant? LastReadAt { get; set; }
|
||||
public Instant? JoinedAt { get; set; }
|
||||
public Instant? LeaveAt { get; set; }
|
||||
|
||||
[JsonIgnore] public List<SnChatMessage> Messages { get; set; } = [];
|
||||
[JsonIgnore] public List<SnChatReaction> Reactions { get; set; } = [];
|
||||
|
||||
public Guid? InvitedById { get; set; }
|
||||
public SnChatMember? InvitedBy { get; set; }
|
||||
|
||||
// Backwards support field
|
||||
[NotMapped]
|
||||
public int Role { get; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public bool IsBot { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The break time is the user doesn't receive any message from this member for a while.
|
||||
/// Expect mentioned him or her.
|
||||
@@ -147,13 +139,6 @@ public class ChatMemberTransmissionObject : ModelBase
|
||||
public Instant? TimeoutUntil { get; set; }
|
||||
public ChatTimeoutCause? TimeoutCause { get; set; }
|
||||
|
||||
// Backwards support field
|
||||
[NotMapped]
|
||||
public int Role { get; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public bool IsBot { get; } = false;
|
||||
|
||||
public static ChatMemberTransmissionObject FromEntity(SnChatMember member)
|
||||
{
|
||||
return new ChatMemberTransmissionObject
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SnCloudFile : ModelBase, ICloudFile, IIdentifiedResource
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? FastUploadLink { get; set; }
|
||||
|
||||
public ICollection<SnCloudFileReference> References { get; set; } = new List<SnCloudFileReference>();
|
||||
public List<SnCloudFileReference> References { get; set; } = new List<SnCloudFileReference>();
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class SnCustomApp : ModelBase, IIdentifiedResource
|
||||
[Column(TypeName = "jsonb")] public SnCustomAppOauthConfig? OauthConfig { get; set; }
|
||||
[Column(TypeName = "jsonb")] public SnCustomAppLinks? Links { get; set; }
|
||||
|
||||
[JsonIgnore] public ICollection<SnCustomAppSecret> Secrets { get; set; } = new List<SnCustomAppSecret>();
|
||||
[JsonIgnore] public List<SnCustomAppSecret> Secrets { get; set; } = new List<SnCustomAppSecret>();
|
||||
|
||||
public Guid ProjectId { get; set; }
|
||||
public SnDevProject Project { get; set; } = null!;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class SnFediverseActor : ModelBase
|
||||
public Guid InstanceId { get; set; }
|
||||
public SnFediverseInstance Instance { get; set; } = null!;
|
||||
|
||||
[JsonIgnore] public ICollection<SnFediverseRelationship> FollowingRelationships { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnFediverseRelationship> FollowerRelationships { get; set; } = [];
|
||||
[JsonIgnore] public List<SnFediverseRelationship> FollowingRelationships { get; set; } = [];
|
||||
[JsonIgnore] public List<SnFediverseRelationship> FollowerRelationships { get; set; } = [];
|
||||
|
||||
public Instant? LastFetchedAt { get; set; }
|
||||
public Instant? LastActivityAt { get; set; }
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SnFediverseInstance : ModelBase
|
||||
public bool IsSilenced { get; set; } = false;
|
||||
|
||||
[MaxLength(2048)] public string? BlockReason { get; set; }
|
||||
[JsonIgnore] public ICollection<SnFediverseActor> Actors { get; set; } = [];
|
||||
[JsonIgnore] public List<SnFediverseActor> Actors { get; set; } = [];
|
||||
|
||||
public Instant? LastFetchedAt { get; set; }
|
||||
public Instant? LastActivityAt { get; set; }
|
||||
|
||||
@@ -81,8 +81,8 @@ public class SnPermissionGroup : ModelBase
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
[MaxLength(1024)] public string Key { get; set; } = null!;
|
||||
|
||||
public ICollection<SnPermissionNode> Nodes { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnPermissionGroupMember> Members { get; set; } = [];
|
||||
public List<SnPermissionNode> Nodes { get; set; } = [];
|
||||
[JsonIgnore] public List<SnPermissionGroupMember> Members { get; set; } = [];
|
||||
}
|
||||
|
||||
public class SnPermissionGroupMember : ModelBase
|
||||
|
||||
@@ -2,6 +2,8 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Models;
|
||||
@@ -19,6 +21,60 @@ public class SnPoll : ModelBase
|
||||
|
||||
public Guid PublisherId { get; set; }
|
||||
[JsonIgnore] public SnPublisher? Publisher { get; set; }
|
||||
|
||||
public Poll ToProtoValue()
|
||||
{
|
||||
var proto = new Poll
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
IsAnonymous = IsAnonymous,
|
||||
PublisherId = PublisherId.ToString(),
|
||||
Publisher = Publisher?.ToProtoValue(),
|
||||
CreatedAt = Timestamp.FromDateTimeOffset(CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Timestamp.FromDateTimeOffset(UpdatedAt.ToDateTimeOffset()),
|
||||
};
|
||||
|
||||
if (Title != null)
|
||||
proto.Title = Title;
|
||||
|
||||
if (Description != null)
|
||||
proto.Description = Description;
|
||||
|
||||
if (EndedAt.HasValue)
|
||||
proto.EndedAt = Timestamp.FromDateTimeOffset(EndedAt.Value.ToDateTimeOffset());
|
||||
|
||||
proto.Questions.AddRange(Questions.Select(q => q.ToProtoValue()));
|
||||
|
||||
if (DeletedAt.HasValue)
|
||||
proto.DeletedAt = Timestamp.FromDateTimeOffset(DeletedAt.Value.ToDateTimeOffset());
|
||||
|
||||
return proto;
|
||||
}
|
||||
|
||||
public static SnPoll FromProtoValue(Poll proto)
|
||||
{
|
||||
var poll = new SnPoll
|
||||
{
|
||||
Id = Guid.Parse(proto.Id),
|
||||
Title = proto.Title != null ? proto.Title : null,
|
||||
Description = proto.Description != null ? proto.Description : null,
|
||||
IsAnonymous = proto.IsAnonymous,
|
||||
PublisherId = Guid.Parse(proto.PublisherId),
|
||||
Publisher = proto.Publisher != null ? SnPublisher.FromProtoValue(proto.Publisher) : null,
|
||||
CreatedAt = Instant.FromDateTimeOffset(proto.CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Instant.FromDateTimeOffset(proto.UpdatedAt.ToDateTimeOffset()),
|
||||
};
|
||||
|
||||
if (proto.EndedAt != null)
|
||||
poll.EndedAt = Instant.FromDateTimeOffset(proto.EndedAt.ToDateTimeOffset());
|
||||
|
||||
poll.Questions.AddRange(proto.Questions.Select(SnPollQuestion.FromProtoValue));
|
||||
|
||||
if (proto.DeletedAt != null)
|
||||
poll.DeletedAt = Instant.FromDateTimeOffset(proto.DeletedAt.ToDateTimeOffset());
|
||||
|
||||
return poll;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PollQuestionType
|
||||
@@ -44,6 +100,46 @@ public class SnPollQuestion : ModelBase
|
||||
|
||||
public Guid PollId { get; set; }
|
||||
[JsonIgnore] public SnPoll Poll { get; set; } = null!;
|
||||
|
||||
public PollQuestion ToProtoValue()
|
||||
{
|
||||
var proto = new PollQuestion
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Type = (Proto.PollQuestionType)((int)Type + 1),
|
||||
Title = Title,
|
||||
Order = Order,
|
||||
IsRequired = IsRequired,
|
||||
};
|
||||
|
||||
if (Description != null)
|
||||
proto.Description = Description;
|
||||
|
||||
if (Options != null)
|
||||
proto.Options.AddRange(Options.Select(o => o.ToProtoValue()));
|
||||
|
||||
return proto;
|
||||
}
|
||||
|
||||
public static SnPollQuestion FromProtoValue(PollQuestion proto)
|
||||
{
|
||||
var question = new SnPollQuestion
|
||||
{
|
||||
Id = Guid.Parse(proto.Id),
|
||||
Type = (PollQuestionType)((int)proto.Type - 1),
|
||||
Title = proto.Title,
|
||||
Order = proto.Order,
|
||||
IsRequired = proto.IsRequired,
|
||||
};
|
||||
|
||||
if (proto.Description != null)
|
||||
question.Description = proto.Description;
|
||||
|
||||
if (proto.Options.Count > 0)
|
||||
question.Options = proto.Options.Select(SnPollOption.FromProtoValue).ToList();
|
||||
|
||||
return question;
|
||||
}
|
||||
}
|
||||
|
||||
public class SnPollOption
|
||||
@@ -52,6 +148,32 @@ public class SnPollOption
|
||||
[Required][MaxLength(1024)] public string Label { get; set; } = null!;
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
public int Order { get; set; } = 0;
|
||||
|
||||
public PollOption ToProtoValue()
|
||||
{
|
||||
var proto = new PollOption
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Label = Label,
|
||||
Order = Order,
|
||||
};
|
||||
|
||||
if (Description != null)
|
||||
proto.Description = Description;
|
||||
|
||||
return proto;
|
||||
}
|
||||
|
||||
public static SnPollOption FromProtoValue(PollOption proto)
|
||||
{
|
||||
return new SnPollOption
|
||||
{
|
||||
Id = Guid.Parse(proto.Id),
|
||||
Label = proto.Label,
|
||||
Description = proto.Description != null ? proto.Description : null,
|
||||
Order = proto.Order,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class SnPollAnswer : ModelBase
|
||||
@@ -63,4 +185,40 @@ public class SnPollAnswer : ModelBase
|
||||
public Guid PollId { get; set; }
|
||||
[JsonIgnore] public SnPoll? Poll { get; set; }
|
||||
[NotMapped] public SnAccount? Account { get; set; }
|
||||
|
||||
public PollAnswer ToProtoValue()
|
||||
{
|
||||
var proto = new PollAnswer
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Answer = GrpcTypeHelper.ConvertObjectToByteString(Answer),
|
||||
AccountId = AccountId.ToString(),
|
||||
PollId = PollId.ToString(),
|
||||
CreatedAt = Timestamp.FromDateTimeOffset(CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Timestamp.FromDateTimeOffset(UpdatedAt.ToDateTimeOffset()),
|
||||
};
|
||||
|
||||
if (DeletedAt.HasValue)
|
||||
proto.DeletedAt = Timestamp.FromDateTimeOffset(DeletedAt.Value.ToDateTimeOffset());
|
||||
|
||||
return proto;
|
||||
}
|
||||
|
||||
public static SnPollAnswer FromProtoValue(PollAnswer proto)
|
||||
{
|
||||
var answer = new SnPollAnswer
|
||||
{
|
||||
Id = Guid.Parse(proto.Id),
|
||||
Answer = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, JsonElement>>(proto.Answer),
|
||||
AccountId = Guid.Parse(proto.AccountId),
|
||||
PollId = Guid.Parse(proto.PollId),
|
||||
CreatedAt = Instant.FromDateTimeOffset(proto.CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Instant.FromDateTimeOffset(proto.UpdatedAt.ToDateTimeOffset()),
|
||||
};
|
||||
|
||||
if (proto.DeletedAt != null)
|
||||
answer.DeletedAt = Instant.FromDateTimeOffset(proto.DeletedAt.ToDateTimeOffset());
|
||||
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ public class SnPublisher : ModelBase, IIdentifiedResource
|
||||
[MaxLength(8192)] [JsonIgnore] public string? PrivateKeyPem { get; set; }
|
||||
[MaxLength(8192)] public string? PublicKeyPem { get; set; }
|
||||
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPost> Posts { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPoll> Polls { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPostCollection> Collections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPublisherMember> Members { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPublisherFeature> Features { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnPost> Posts { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnPoll> Polls { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnPostCollection> Collections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnPublisherMember> Members { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public List<SnPublisherFeature> Features { get; set; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public ICollection<SnPublisherSubscription> Subscriptions { get; set; } = [];
|
||||
public List<SnPublisherSubscription> Subscriptions { get; set; } = [];
|
||||
|
||||
public Guid? AccountId { get; set; }
|
||||
public Guid? RealmId { get; set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SnRealm : ModelBase, IIdentifiedResource
|
||||
|
||||
[Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; }
|
||||
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnRealmMember> Members { get; set; } = new List<SnRealmMember>();
|
||||
[IgnoreMember] [JsonIgnore] public List<SnRealmMember> Members { get; set; } = new List<SnRealmMember>();
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SnWallet : ModelBase
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public ICollection<SnWalletPocket> Pockets { get; set; } = new List<SnWalletPocket>();
|
||||
public List<SnWalletPocket> Pockets { get; set; } = new List<SnWalletPocket>();
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public SnAccount Account { get; set; } = null!;
|
||||
@@ -98,7 +98,7 @@ public class SnWalletFund : ModelBase
|
||||
public SnAccount CreatorAccount { get; set; } = null!;
|
||||
|
||||
// Recipients
|
||||
public ICollection<SnWalletFundRecipient> Recipients { get; set; } = new List<SnWalletFundRecipient>();
|
||||
public List<SnWalletFundRecipient> Recipients { get; set; } = new List<SnWalletFundRecipient>();
|
||||
|
||||
// Expiration
|
||||
public Instant ExpiredAt { get; set; }
|
||||
|
||||
133
DysonNetwork.Shared/Proto/poll.proto
Normal file
133
DysonNetwork.Shared/Proto/poll.proto
Normal file
@@ -0,0 +1,133 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package proto;
|
||||
|
||||
option csharp_namespace = "DysonNetwork.Shared.Proto";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "publisher.proto";
|
||||
|
||||
// Enums
|
||||
enum PollQuestionType {
|
||||
POLL_QUESTION_TYPE_UNSPECIFIED = 0;
|
||||
SINGLE_CHOICE = 1;
|
||||
MULTIPLE_CHOICE = 2;
|
||||
YES_NO = 3;
|
||||
RATING = 4;
|
||||
FREE_TEXT = 5;
|
||||
}
|
||||
|
||||
// Messages
|
||||
|
||||
message PollOption {
|
||||
string id = 1;
|
||||
string label = 2;
|
||||
google.protobuf.StringValue description = 3;
|
||||
int32 order = 4;
|
||||
}
|
||||
|
||||
message PollQuestion {
|
||||
string id = 1;
|
||||
PollQuestionType type = 2;
|
||||
repeated PollOption options = 3;
|
||||
string title = 4;
|
||||
google.protobuf.StringValue description = 5;
|
||||
int32 order = 6;
|
||||
bool is_required = 7;
|
||||
}
|
||||
|
||||
message Poll {
|
||||
string id = 1;
|
||||
google.protobuf.StringValue title = 2;
|
||||
google.protobuf.StringValue description = 3;
|
||||
optional google.protobuf.Timestamp ended_at = 4;
|
||||
bool is_anonymous = 5;
|
||||
|
||||
string publisher_id = 6;
|
||||
optional Publisher publisher = 7;
|
||||
|
||||
repeated PollQuestion questions = 8;
|
||||
|
||||
google.protobuf.Timestamp created_at = 9;
|
||||
google.protobuf.Timestamp updated_at = 10;
|
||||
optional google.protobuf.Timestamp deleted_at = 11;
|
||||
}
|
||||
|
||||
message PollAnswer {
|
||||
string id = 1;
|
||||
bytes answer = 2; // Dictionary<string, JsonElement>
|
||||
|
||||
string account_id = 3;
|
||||
string poll_id = 4;
|
||||
|
||||
google.protobuf.Timestamp created_at = 5;
|
||||
google.protobuf.Timestamp updated_at = 6;
|
||||
optional google.protobuf.Timestamp deleted_at = 7;
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// Request/Response Messages
|
||||
// ====================================
|
||||
|
||||
message GetPollRequest {
|
||||
oneof identifier {
|
||||
string id = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message GetPollBatchRequest {
|
||||
repeated string ids = 1;
|
||||
}
|
||||
|
||||
message GetPollBatchResponse {
|
||||
repeated Poll polls = 1;
|
||||
}
|
||||
|
||||
message ListPollsRequest {
|
||||
google.protobuf.StringValue publisher_id = 1;
|
||||
int32 page_size = 2;
|
||||
string page_token = 3;
|
||||
google.protobuf.StringValue order_by = 4;
|
||||
bool order_desc = 5;
|
||||
}
|
||||
|
||||
message ListPollsResponse {
|
||||
repeated Poll polls = 1;
|
||||
string next_page_token = 2;
|
||||
int32 total_size = 3;
|
||||
}
|
||||
|
||||
message GetPollAnswerRequest {
|
||||
string poll_id = 1;
|
||||
string account_id = 2;
|
||||
}
|
||||
|
||||
message GetPollStatsRequest {
|
||||
string poll_id = 1;
|
||||
}
|
||||
|
||||
message GetPollStatsResponse {
|
||||
map<string, string> stats = 1; // Question ID -> JSON string of stats (option_id -> count)
|
||||
}
|
||||
|
||||
message GetPollQuestionStatsRequest {
|
||||
string question_id = 1;
|
||||
}
|
||||
|
||||
message GetPollQuestionStatsResponse {
|
||||
map<string, int32> stats = 1; // Option ID -> count
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// Service Definitions
|
||||
// ====================================
|
||||
|
||||
service PollService {
|
||||
rpc GetPoll(GetPollRequest) returns (Poll);
|
||||
rpc GetPollBatch(GetPollBatchRequest) returns (GetPollBatchResponse);
|
||||
rpc ListPolls(ListPollsRequest) returns (ListPollsResponse);
|
||||
rpc GetPollAnswer(GetPollAnswerRequest) returns (PollAnswer);
|
||||
rpc GetPollStats(GetPollStatsRequest) returns (GetPollStatsResponse);
|
||||
rpc GetPollQuestionStats(GetPollQuestionStatsRequest) returns (GetPollQuestionStatsResponse);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import "google/protobuf/wrappers.proto";
|
||||
import "file.proto";
|
||||
import "realm.proto";
|
||||
import "publisher.proto";
|
||||
import "account.proto";
|
||||
|
||||
// Enums
|
||||
enum PostType {
|
||||
@@ -320,5 +321,3 @@ service PostService {
|
||||
// List posts with filters
|
||||
rpc ListPosts(ListPostsRequest) returns (ListPostsResponse);
|
||||
}
|
||||
|
||||
import 'account.proto';
|
||||
|
||||
@@ -116,6 +116,12 @@ public static class ServiceInjectionHelper
|
||||
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler()
|
||||
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true }
|
||||
);
|
||||
|
||||
services
|
||||
.AddGrpcClient<PollService.PollServiceClient>(o => o.Address = new Uri("https://_grpc.sphere"))
|
||||
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler()
|
||||
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true }
|
||||
);
|
||||
services.AddSingleton<RemotePublisherService>();
|
||||
|
||||
return services;
|
||||
|
||||
Reference in New Issue
Block a user