예제 #1
0
        public async Task <ActionResult> GetChatPictureAsync(
            string roomHashid,
            string userHashid,
            string timestamp,
            [FromServices] DrrrDbContext dbContext)
        {
            int roomId        = Decode(roomHashid);
            int userId        = Decode(userHashid);
            int currentUserId = Decode(User.FindFirst("uid").Value);

            // 判断当前用户是否属于该聊天室
            if (!dbContext.Connection.Any(c => c.RoomId == roomId && c.UserId == currentUserId))
            {
                return(Forbid(JwtBearerDefaults.AuthenticationScheme));
            }
            string fileFullNameWithoutExtension = Path.Combine(_picturesDirectory,
                                                               roomId.ToString(), "originals", $"{userId}_{timestamp}");
            string path;

            if (Exists(path = $"{fileFullNameWithoutExtension}.jpg") ||
                Exists(path = $"{fileFullNameWithoutExtension}.gif"))
            {
                return(File(await ReadAllBytesAsync(path), _imageService.GetMimeType(path)));
            }
            return(NotFound());
        }
예제 #2
0
 public ChatRoomService(
     DrrrDbContext dbContext,
     SystemMessagesService systemMessagesService)
 {
     _dbContext = dbContext;
     _msg       = systemMessagesService;
 }
예제 #3
0
 public UserRegisterService(
     SystemMessagesService systemMessagesService,
     TokenAuthService tokenAuthService,
     DrrrDbContext dbContext)
 {
     _msg = systemMessagesService;
     _tokenAuthService = tokenAuthService;
     _dbContext        = dbContext;
 }
예제 #4
0
 public ChatHub(
     SystemMessagesService systemMessagesService,
     DrrrDbContext dbContext,
     ImageService imageService,
     IConfiguration configuration)
 {
     _msg               = systemMessagesService;
     _dbContext         = dbContext;
     _imageService      = imageService;
     _picturesDirectory = configuration["Resources:Pictures"];
 }
예제 #5
0
 public UserProfileService(
     DrrrDbContext dbContext,
     SystemMessagesService systemMessagesService,
     TokenAuthService tokenAuthService,
     ImageService imageService,
     IConfiguration configuration)
 {
     _dbContext        = dbContext;
     _tokenAuthService = tokenAuthService;
     _imageService     = imageService;
     _avatarsDirectory = configuration["Resources:Avatars"];
 }
예제 #6
0
 public TokenAuthService(DrrrDbContext dbContext) => _dbContext = dbContext;
예제 #7
0
 public SiteInfoService(DrrrDbContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #8
0
 public CaptchaHub(DrrrDbContext dbContext) => _dbContext = dbContext;