20
20
)
21
21
from v2 .services .gpt import generate_text
22
22
from v2 .services .pubsub import get_service
23
- from v2 .utils .query import get_thread_id , get_user_id_same_couple
23
+ from v2 .utils .query import get_thread_id
24
24
25
25
router = APIRouter ()
26
26
logger = get_logger ()
34
34
35
35
@router .post (
36
36
"/{id}" ,
37
- tags = ["raspi" ],
37
+ tags = ["futarin- raspi" ],
38
38
summary = "一連の動作全て" ,
39
39
response_class = FileResponse ,
40
40
responses = {
@@ -82,7 +82,7 @@ async def all(
82
82
83
83
@router .post (
84
84
"/{id}/messages" ,
85
- tags = ["raspi" ],
85
+ tags = ["futarin- raspi" ],
86
86
summary = "メッセージ送信" ,
87
87
response_model = raspi_schema .RaspiMessageResponse ,
88
88
)
@@ -100,7 +100,7 @@ async def create_message(
100
100
return response
101
101
102
102
103
- @router .post ("/{id}/negotiate" , tags = ["raspi" ], summary = "websocketsのURL発行" )
103
+ @router .post ("/{id}/negotiate" , tags = ["futarin- raspi" ], summary = "websocketsのURL発行" )
104
104
async def negotiate (id : int ):
105
105
if not id :
106
106
return "missing user id" , 400
@@ -110,30 +110,33 @@ async def negotiate(id: int):
110
110
111
111
112
112
@router .get (
113
- "/{id }" ,
114
- tags = ["raspi" ],
113
+ "/{raspi_id}/messages/{message_id }" ,
114
+ tags = ["futarin- raspi" ],
115
115
summary = "同coupleのメッセージ取得" ,
116
116
# response_model=Union[FileResponse, raspi_schema.RaspiMessageResponse],
117
117
)
118
- async def get_message (id : int , db : AsyncSession = Depends (get_db )):
118
+ async def get_message (
119
+ raspi_id : int ,
120
+ message_id : int ,
121
+ ):
119
122
# 同coupleのidを取得
120
- boddy_id = await get_user_id_same_couple (db , id )
123
+ # boddy_id = await get_user_id_same_couple(db, id)
121
124
# 同coupleのファイルをダウンロード
122
- is_downloaded = is_downloaded_blob (str (boddy_id ), blob_service_client )
125
+ is_downloaded = is_downloaded_blob (str (message_id ), blob_service_client )
123
126
124
127
if is_downloaded :
125
128
current_dir = os .path .dirname (os .path .abspath (__file__ ))
126
- file_path = os .path .join (current_dir , f"../../downloads/{ boddy_id } .wav" )
129
+ file_path = os .path .join (current_dir , f"../../downloads/{ message_id } .wav" )
127
130
return FileResponse (
128
- path = file_path , media_type = "audio/wav" , filename = f"{ boddy_id } .wav"
131
+ path = file_path , media_type = "audio/wav" , filename = f"{ message_id } .wav"
129
132
)
130
133
131
- return {"id" : id , "message" : "相方のファイルは見つかりませんでした" }
134
+ return {"id" : raspi_id , "message" : "相方のファイルは見つかりませんでした" }
132
135
133
136
134
137
@router .get (
135
138
"/" ,
136
- tags = ["raspi " ],
139
+ tags = ["raspis " ],
137
140
summary = "ラズパイ一覧の取得" ,
138
141
response_model = List [raspi_schema .RaspiResponse ],
139
142
)
@@ -143,7 +146,7 @@ async def list_raspi(db: AsyncSession = Depends(get_db)):
143
146
144
147
@router .post (
145
148
"/" ,
146
- tags = ["raspi " ],
149
+ tags = ["raspis " ],
147
150
summary = "新規ラズパイの作成" ,
148
151
response_model = raspi_schema .RaspiResponse ,
149
152
)
@@ -155,7 +158,7 @@ async def create_raspi(
155
158
156
159
@router .put (
157
160
"/{id}" ,
158
- tags = ["raspi " ],
161
+ tags = ["raspis " ],
159
162
summary = "ラズパイの更新" ,
160
163
response_model = raspi_schema .RaspiResponse ,
161
164
)
@@ -168,7 +171,7 @@ async def update_raspi(
168
171
return await raspi_crud .update_raspi (db , raspi_body , original = raspi )
169
172
170
173
171
- @router .delete ("/{id}" , tags = ["raspi " ], summary = "ラズパイの削除" , response_model = None )
174
+ @router .delete ("/{id}" , tags = ["raspis " ], summary = "ラズパイの削除" , response_model = None )
172
175
async def delete_raspi (id : int , db : AsyncSession = Depends (get_db )):
173
176
raspi = await raspi_crud .get_raspi (db , raspi_id = id )
174
177
if raspi is None :
0 commit comments