@@ -304,31 +304,6 @@ func CreatePost(ctx *context.Context) {
304304 handleCreateError (ctx , ctxUser , err , "CreatePost" , tplCreate , & form )
305305}
306306
307- const (
308- tplWatchUnwatch templates.TplName = "repo/watch_unwatch"
309- tplStarUnstar templates.TplName = "repo/star_unstar"
310- )
311-
312- func acceptTransfer (ctx * context.Context ) {
313- err := repo_service .AcceptTransferOwnership (ctx , ctx .Repo .Repository , ctx .Doer )
314- if err == nil {
315- ctx .Flash .Success (ctx .Tr ("repo.settings.transfer.success" ))
316- ctx .Redirect (ctx .Repo .Repository .Link ())
317- return
318- }
319- handleActionError (ctx , err )
320- }
321-
322- func rejectTransfer (ctx * context.Context ) {
323- err := repo_service .RejectRepositoryTransfer (ctx , ctx .Repo .Repository , ctx .Doer )
324- if err == nil {
325- ctx .Flash .Success (ctx .Tr ("repo.settings.transfer.rejected" ))
326- ctx .Redirect (ctx .Repo .Repository .Link ())
327- return
328- }
329- handleActionError (ctx , err )
330- }
331-
332307func handleActionError (ctx * context.Context , err error ) {
333308 if errors .Is (err , user_model .ErrBlockedUser ) {
334309 ctx .Flash .Error (ctx .Tr ("repo.action.blocked_user" ))
@@ -339,72 +314,6 @@ func handleActionError(ctx *context.Context, err error) {
339314 }
340315}
341316
342- // Action response for actions to a repository
343- func Action (ctx * context.Context ) {
344- var err error
345- switch ctx .PathParam ("action" ) {
346- case "watch" :
347- err = repo_model .WatchRepo (ctx , ctx .Doer , ctx .Repo .Repository , true )
348- case "unwatch" :
349- err = repo_model .WatchRepo (ctx , ctx .Doer , ctx .Repo .Repository , false )
350- case "star" :
351- err = repo_model .StarRepo (ctx , ctx .Doer , ctx .Repo .Repository , true )
352- case "unstar" :
353- err = repo_model .StarRepo (ctx , ctx .Doer , ctx .Repo .Repository , false )
354- case "accept_transfer" :
355- acceptTransfer (ctx )
356- return
357- case "reject_transfer" :
358- rejectTransfer (ctx )
359- return
360- case "desc" : // FIXME: this is not used
361- if ! ctx .Repo .IsOwner () {
362- ctx .Error (http .StatusNotFound )
363- return
364- }
365-
366- ctx .Repo .Repository .Description = ctx .FormString ("desc" )
367- ctx .Repo .Repository .Website = ctx .FormString ("site" )
368- err = repo_service .UpdateRepository (ctx , ctx .Repo .Repository , false )
369- }
370-
371- if err != nil {
372- handleActionError (ctx , err )
373- return
374- }
375-
376- switch ctx .PathParam ("action" ) {
377- case "watch" , "unwatch" :
378- ctx .Data ["IsWatchingRepo" ] = repo_model .IsWatching (ctx , ctx .Doer .ID , ctx .Repo .Repository .ID )
379- case "star" , "unstar" :
380- ctx .Data ["IsStaringRepo" ] = repo_model .IsStaring (ctx , ctx .Doer .ID , ctx .Repo .Repository .ID )
381- }
382-
383- // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
384- ctx .RespHeader ().Add ("hx-trigger" , "refreshUserCards" )
385-
386- switch ctx .PathParam ("action" ) {
387- case "watch" , "unwatch" , "star" , "unstar" :
388- // we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed
389- ctx .Data ["Repository" ], err = repo_model .GetRepositoryByName (ctx , ctx .Repo .Repository .OwnerID , ctx .Repo .Repository .Name )
390- if err != nil {
391- ctx .ServerError (fmt .Sprintf ("Action (%s)" , ctx .PathParam ("action" )), err )
392- return
393- }
394- }
395-
396- switch ctx .PathParam ("action" ) {
397- case "watch" , "unwatch" :
398- ctx .HTML (http .StatusOK , tplWatchUnwatch )
399- return
400- case "star" , "unstar" :
401- ctx .HTML (http .StatusOK , tplStarUnstar )
402- return
403- }
404-
405- ctx .RedirectToCurrentSite (ctx .FormString ("redirect_to" ), ctx .Repo .RepoLink )
406- }
407-
408317// RedirectDownload return a file based on the following infos:
409318func RedirectDownload (ctx * context.Context ) {
410319 var (
0 commit comments