Beispiel #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());
        }
Beispiel #2
0
 public ChatRoomService(
     DrrrDbContext dbContext,
     SystemMessagesService systemMessagesService)
 {
     _dbContext = dbContext;
     _msg       = systemMessagesService;
 }
Beispiel #3
0
 public UserRegisterService(
     SystemMessagesService systemMessagesService,
     TokenAuthService tokenAuthService,
     DrrrDbContext dbContext)
 {
     _msg = systemMessagesService;
     _tokenAuthService = tokenAuthService;
     _dbContext        = dbContext;
 }
Beispiel #4
0
 public ChatHub(
     SystemMessagesService systemMessagesService,
     DrrrDbContext dbContext,
     ImageService imageService,
     IConfiguration configuration)
 {
     _msg               = systemMessagesService;
     _dbContext         = dbContext;
     _imageService      = imageService;
     _picturesDirectory = configuration["Resources:Pictures"];
 }
Beispiel #5
0
 public UserProfileService(
     DrrrDbContext dbContext,
     SystemMessagesService systemMessagesService,
     TokenAuthService tokenAuthService,
     ImageService imageService,
     IConfiguration configuration)
 {
     _dbContext        = dbContext;
     _tokenAuthService = tokenAuthService;
     _imageService     = imageService;
     _avatarsDirectory = configuration["Resources:Avatars"];
 }
Beispiel #6
0
 public TokenAuthService(DrrrDbContext dbContext) => _dbContext = dbContext;
Beispiel #7
0
 public SiteInfoService(DrrrDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Beispiel #8
0
 public CaptchaHub(DrrrDbContext dbContext) => _dbContext = dbContext;