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