syntax = "proto3";

package media;

service MediaService {
  rpc CreateAvatarUploadUrl (AvatarUploadRequest) returns (PresignedUploadResponse);
  rpc ConfirmAvatar (ConfirmAvatarRequest) returns (AvatarResponse);
  rpc GetAvatarAccessUrl (AvatarAccessRequest) returns (MediaAccessResponse);
  rpc CreateDocumentPhotoUploadUrl (DocumentPhotoUploadRequest) returns (PresignedUploadResponse);
  rpc GetDocumentPhotoAccessUrl (DocumentPhotoAccessRequest) returns (MediaAccessResponse);
  rpc ResolveStreamToken (StreamTokenRequest) returns (StreamTokenResponse);
  rpc CreateFamilyAvatarUploadUrl (FamilyAvatarUploadRequest) returns (PresignedUploadResponse);
  rpc ConfirmFamilyAvatar (ConfirmFamilyAvatarRequest) returns (FamilyAvatarResponse);
  rpc GetFamilyAvatarAccessUrl (FamilyAvatarAccessRequest) returns (MediaAccessResponse);
  rpc CreateChatMediaUploadUrl (ChatMediaUploadRequest) returns (PresignedUploadResponse);
  rpc GetChatMediaAccessUrl (ChatMediaAccessRequest) returns (MediaAccessResponse);
  rpc CreateChatRoomAvatarUploadUrl (ChatRoomAvatarUploadRequest) returns (PresignedUploadResponse);
  rpc ConfirmChatRoomAvatar (ConfirmChatRoomAvatarRequest) returns (ChatRoomAvatarResponse);
  rpc GetChatRoomAvatarAccessUrl (ChatRoomAvatarAccessRequest) returns (MediaAccessResponse);
}

message AvatarUploadRequest {
  string userId = 1;
  string contentType = 2;
}

message ConfirmAvatarRequest {
  string userId = 1;
  string storageKey = 2;
}

message AvatarAccessRequest {
  string requesterId = 1;
  string targetUserId = 2;
}

message DocumentPhotoUploadRequest {
  string userId = 1;
  string documentId = 2;
  string contentType = 3;
}

message DocumentPhotoAccessRequest {
  string requesterId = 1;
  string targetUserId = 2;
  string storageKey = 3;
}

message PresignedUploadResponse {
  string uploadUrl = 1;
  string storageKey = 2;
  string expiresAt = 3;
  optional string uploadToken = 4;
}

message AvatarResponse {
  string userId = 1;
  bool hasAvatar = 2;
}

message MediaAccessResponse {
  string accessUrl = 1;
  string expiresAt = 2;
}

message StreamTokenRequest {
  string token = 1;
  optional string requesterId = 2;
}

message StreamTokenResponse {
  string storageKey = 1;
  string contentType = 2;
  optional string fileName = 3;
}

message FamilyAvatarUploadRequest {
  string requesterId = 1;
  string groupId = 2;
  string contentType = 3;
}

message ConfirmFamilyAvatarRequest {
  string requesterId = 1;
  string groupId = 2;
  string storageKey = 3;
}

message FamilyAvatarAccessRequest {
  string requesterId = 1;
  string groupId = 2;
}

message FamilyAvatarResponse {
  string groupId = 1;
  bool hasAvatar = 2;
}

message ChatMediaUploadRequest {
  string requesterId = 1;
  string roomId = 2;
  string contentType = 3;
}

message ChatMediaAccessRequest {
  string requesterId = 1;
  string roomId = 2;
  string storageKey = 3;
  optional string fileName = 4;
}

message ChatRoomAvatarUploadRequest {
  string requesterId = 1;
  string roomId = 2;
  string contentType = 3;
}

message ConfirmChatRoomAvatarRequest {
  string requesterId = 1;
  string roomId = 2;
  string storageKey = 3;
}

message ChatRoomAvatarAccessRequest {
  string requesterId = 1;
  string roomId = 2;
}

message ChatRoomAvatarResponse {
  string roomId = 1;
  bool hasAvatar = 2;
}
