view_w_watch_list_add_post.go 933 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package route
  2. import "opennamu/route/tool"
  3. func View_w_watch_list_add_post(config tool.Config, doc_name string, do_type string) string {
  4. db := tool.DB_connect()
  5. defer tool.DB_close(db)
  6. name_from := false
  7. switch do_type {
  8. case "watchlist_from":
  9. name_from = true
  10. do_type = "watchlist"
  11. case "star_doc_from":
  12. name_from = true
  13. do_type = "star_doc"
  14. }
  15. if do_type != "watchlist" {
  16. do_type = "star_doc"
  17. }
  18. api_data := Api_w_watch_list_post(config, doc_name, do_type)
  19. out := ""
  20. if api_data["response"] != "ok" {
  21. out = tool.Get_error_page(db, config, "error")
  22. } else {
  23. if name_from {
  24. out = tool.Get_redirect("/w/" + doc_name)
  25. } else if do_type == "watchlist" {
  26. out = tool.Get_redirect("/watch_list")
  27. } else {
  28. out = tool.Get_redirect("/star_doc")
  29. }
  30. }
  31. return out
  32. }