@@ -313,70 +313,3 @@ def ListMyCommunitiesDiscussions(
313313 discussions = [discussion_to_pb (session , d , context ) for d in discussions [:page_size ]],
314314 next_page_token = str (discussions [- 1 ].id ) if len (discussions ) > page_size else None ,
315315 )
316-
317- def UpdateDiscussion (
318- self , request : discussions_pb2 .UpdateDiscussionReq , context : CouchersContext , session : Session
319- ) -> discussions_pb2 .Discussion :
320- discussion = session .execute (
321- select (Discussion ).where (Discussion .id == request .discussion_id )
322- ).scalar_one_or_none ()
323- if not discussion :
324- context .abort_with_error_code (grpc .StatusCode .NOT_FOUND , "discussion_not_found" )
325- if discussion .deleted is not None :
326- context .abort_with_error_code (grpc .StatusCode .FAILED_PRECONDITION , "discussion_deleted" )
327- if context .user_id != discussion .creator_user_id :
328- context .abort_with_error_code (grpc .StatusCode .PERMISSION_DENIED , "discussion_edit_permission_denied" )
329-
330- if request .HasField ("title" ):
331- new_title = request .title .value .strip ()
332- if not new_title :
333- context .abort_with_error_code (grpc .StatusCode .INVALID_ARGUMENT , "missing_discussion_title" )
334- discussion .title = new_title
335-
336- if request .HasField ("content" ):
337- new_content = request .content .value .strip ()
338- if not new_content :
339- context .abort_with_error_code (grpc .StatusCode .INVALID_ARGUMENT , "missing_discussion_content" )
340- discussion .content = new_content
341-
342- discussion .last_edited = now ()
343-
344- log_event (
345- context ,
346- session ,
347- "discussion.updated" ,
348- {
349- "discussion_id" : discussion .id ,
350- },
351- )
352-
353- return discussion_to_pb (session , discussion , context )
354-
355- def DeleteDiscussion (
356- self , request : discussions_pb2 .DeleteDiscussionReq , context : CouchersContext , session : Session
357- ) -> empty_pb2 .Empty :
358- discussion = session .execute (
359- select (Discussion ).where (Discussion .id == request .discussion_id )
360- ).scalar_one_or_none ()
361- if not discussion :
362- context .abort_with_error_code (grpc .StatusCode .NOT_FOUND , "discussion_not_found" )
363- if discussion .deleted is not None :
364- context .abort_with_error_code (grpc .StatusCode .FAILED_PRECONDITION , "discussion_deleted" )
365-
366- is_creator = context .user_id == discussion .creator_user_id
367- is_moderator = can_moderate_node (session , context .user_id , discussion .owner_cluster .parent_node_id )
368- if not is_creator and not is_moderator :
369- context .abort_with_error_code (grpc .StatusCode .PERMISSION_DENIED , "discussion_delete_permission_denied" )
370-
371- discussion .deleted = now ()
372-
373- log_event (
374- context ,
375- session ,
376- "discussion.deleted" ,
377- {
378- "discussion_id" : discussion .id ,
379- },
380- )
381-
382- return empty_pb2 .Empty ()
0 commit comments