chatRooms
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
|
||||
namespace Yavsc.Models.Access
|
||||
{
|
||||
public abstract class Rule<TResource> where TResource : IAuthorizationRequirement
|
||||
public abstract class Rule<TResource,TRequirement>
|
||||
{
|
||||
public virtual bool Mandatory { get; set; }
|
||||
public abstract bool Allow(ApplicationUser user);
|
||||
public Rule()
|
||||
{
|
||||
|
||||
}
|
||||
// Abstract method to compute any authorization on a resource
|
||||
public abstract bool Allow(ApplicationDbContext context, string userId, TResource resource, TRequirement requirement);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.Models.Access
|
||||
{
|
||||
public abstract class RuleSet <TResource,TRequirement>:List<Rule<TResource,TRequirement>> {
|
||||
|
||||
public class RuleSet <TResource>:List<Rule<TResource>> where TResource : IAuthorizationRequirement{
|
||||
|
||||
bool Allow(ApplicationUser user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public abstract bool Allow(ApplicationDbContext context, string userId, TResource resource, TRequirement requirement);
|
||||
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ namespace Yavsc.Models
|
||||
builder.Entity<Relationship.Contact>().HasKey(x => new { x.OwnerId, x.UserId });
|
||||
builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
|
||||
builder.Entity<BlogTag>().HasKey(x=>new { x.PostId, x.TagId});
|
||||
builder.Entity<ApplicationUser>().HasMany<Connection>( c=>c.Connections );
|
||||
builder.Entity<ApplicationUser>().HasMany<ChatConnection>( c=>c.Connections );
|
||||
builder.Entity<ApplicationUser>().Property(u=>u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u=>u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
|
||||
builder.Entity<UserActivity>().HasKey(u=> new { u.DoesCode, u.UserId});
|
||||
@ -58,6 +58,7 @@ namespace Yavsc.Models
|
||||
builder.Entity<Period>().HasKey(l=>new { l.Start, l.End });
|
||||
builder.Entity<Models.Cratie.Option>().HasKey( o => new { o.Code, o.CodeScrutin });
|
||||
builder.Entity<Notification>().Property(n=> n.icon).HasDefaultValue("exclam");
|
||||
builder.Entity<ChatRoomPresence>().HasKey(p=>new { room = p.ChannelName, user = p.ChatUserConnectionId });
|
||||
foreach (var et in builder.Model.GetEntityTypes()) {
|
||||
if (et.ClrType.GetInterface("IBaseTrackedEntity")!=null)
|
||||
et.FindProperty("DateCreated").IsReadOnlyAfterSave = true;
|
||||
@ -197,7 +198,7 @@ namespace Yavsc.Models
|
||||
|
||||
public DbSet<ClientProviderInfo> ClientProviderInfo { get; set; }
|
||||
|
||||
public DbSet<Connection> Connections { get; set; }
|
||||
public DbSet<ChatConnection> Connections { get; set; }
|
||||
|
||||
public DbSet<BlackListed> BlackListed { get; set; }
|
||||
|
||||
@ -293,5 +294,10 @@ namespace Yavsc.Models
|
||||
public DbSet<Comment> Comment { get; set; }
|
||||
|
||||
public DbSet<Announce> Announce { get; set; }
|
||||
|
||||
public DbSet<ChatConnection> ChatConnection { get; set; }
|
||||
public DbSet<ChatRoom> ChatRoom { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,25 +19,32 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Models.Chat
|
||||
{
|
||||
using Yavsc;
|
||||
|
||||
public class Connection : IConnection
|
||||
public class ChatConnection : Abstract.Streaming.IChatConnection<ChatRoomPresence>
|
||||
{
|
||||
[JsonIgnore,Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
[ForeignKey("ApplicationUserId"),JsonIgnore]
|
||||
public virtual ApplicationUser Owner { get; set; }
|
||||
|
||||
[Key]
|
||||
public string ConnectionId { get; set; }
|
||||
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
public bool Connected { get; set; }
|
||||
|
||||
[InverseProperty("ChatUserConnection")]
|
||||
public virtual List<ChatRoomPresence> Rooms { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
27
Yavsc/Models/Chat/ChatRoom.cs
Normal file
27
Yavsc/Models/Chat/ChatRoom.cs
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Abstract.Streaming;
|
||||
|
||||
namespace Yavsc.Models.Chat
|
||||
{
|
||||
public class ChatRoom: IChatRoom<ChatRoomPresence>
|
||||
{
|
||||
[StringLengthAttribute(1023,MinimumLength=1)]
|
||||
public string Topic { get; set; }
|
||||
|
||||
[Key]
|
||||
[StringLengthAttribute(255,MinimumLength=1)]
|
||||
public string Name { get; set;}
|
||||
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
[ForeignKey("ApplicationUserId")]
|
||||
public virtual ApplicationUser Owner { get; set; }
|
||||
|
||||
[InverseProperty("Room")]
|
||||
public virtual List<ChatRoomPresence> UserList { get; set;}
|
||||
|
||||
}
|
||||
}
|
23
Yavsc/Models/Chat/ChatRoomPresence.cs
Normal file
23
Yavsc/Models/Chat/ChatRoomPresence.cs
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Abstract.Streaming;
|
||||
|
||||
namespace Yavsc.Models.Chat
|
||||
{
|
||||
public class ChatRoomPresence: IChatRoomUsage
|
||||
{
|
||||
public string ChannelName { get; set; }
|
||||
[ForeignKey("ChannelName")]
|
||||
public virtual ChatRoom Room { get; set; }
|
||||
|
||||
public string ChatUserConnectionId { get; set; }
|
||||
|
||||
[ForeignKey("ChatUserConnectionId")]
|
||||
public virtual ChatConnection ChatUserConnection { get; set; }
|
||||
|
||||
public ChatRoomUsageLevel Level
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ namespace Yavsc.Models
|
||||
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
|
||||
|
||||
[InverseProperty("Owner"),JsonIgnore]
|
||||
public virtual List<Connection> Connections { get; set; }
|
||||
public virtual List<ChatConnection> Connections { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -94,6 +94,8 @@ namespace Yavsc.Models
|
||||
public long DiskQuota { get; set; } = 512*1024*1024;
|
||||
public long DiskUsage { get; set; } = 0;
|
||||
|
||||
public long MaxFileSize { get; set; } = 512*1024*1024;
|
||||
|
||||
[JsonIgnore][InverseProperty("Owner")]
|
||||
public virtual List<BlackListed> BlackList { get; set; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user