From 753a2c771b21d2044411674a89a762c09a1a0ab5 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Wed, 27 Nov 2024 14:22:25 +0800 Subject: [PATCH] refactor: Remove `use_original_filename` Reference: https://github.com/tryzealot/zealot/pull/1744#issuecomment-2502671883 --- app/controllers/api/apps/upload_controller.rb | 27 +++++++++---------- app/controllers/api/releases_controller.rb | 2 +- app/controllers/releases_controller.rb | 3 +-- app/jobs/app_web_hook_job.rb | 3 +-- app/models/concerns/release_parser.rb | 1 - app/serializers/api/upload_app_serializer.rb | 2 +- app/serializers/release_serializer.rb | 2 +- app/services/create_sample_data_service.rb | 3 +-- app/views/releases/_form.html.slim | 1 - config/locales/simple_form/simple_form.en.yml | 2 -- .../locales/simple_form/simple_form.zh-CN.yml | 2 -- config/locales/zealot/api.en.yml | 1 - config/locales/zealot/api.zh-CN.yml | 2 -- db/migrate/20150210090223_create_releases.rb | 1 - db/schema.rb | 1 - spec/swagger_helper.rb | 3 --- swagger/v1/swagger_en.json | 12 --------- swagger/v1/swagger_zh-CN.json | 12 --------- 18 files changed, 19 insertions(+), 61 deletions(-) diff --git a/app/controllers/api/apps/upload_controller.rb b/app/controllers/api/apps/upload_controller.rb index 17257af16..719b2c2a6 100644 --- a/app/controllers/api/apps/upload_controller.rb +++ b/app/controllers/api/apps/upload_controller.rb @@ -9,19 +9,18 @@ class Api::Apps::UploadController < Api::BaseController # # POST /api/apps/upload # - # @param token [String] required user token - # @param file [String] required file of app - # @param channel_key [String] optional channel key of app - # @param name [String] optional name of app - # @param password [String] optional password to download app - # @param release_type [String] optional release type(debug, beta, adhoc, release, enterprise etc) - # @param source [String] optional upload source(api, cli, jenkins, gitlab-ci etc) - # @param changelog [String] optional changelog - # @param branch [String] optional git branch - # @param git_commit [String] optional git commit - # @param ci_url [String] optional ci url - # @param use_original_filename [Boolean] optional whether to use the original file name (true/false) - # @return [String] json formatted app info + # @param token [String] required user token + # @param file [String] required file of app + # @param channel_key [String] optional channel key of app + # @param name [String] optional name of app + # @param password [String] optional password to download app + # @param release_type [String] optional release type(debug, beta, adhoc, release, enterprise etc) + # @param source [String] optional upload source(api, cli, jenkins, gitlab-ci etc) + # @param changelog [String] optional changelog + # @param branch [String] optional git branch + # @param git_commit [String] optional git commit + # @param ci_url [String] optional ci url + # @return [String] json formatted app info def create create_or_update_release perform_teardown_job @@ -124,7 +123,7 @@ def parse_scheme_name def release_params params.permit( :file, :release_type, :source, :branch, :git_commit, - :ci_url, :changelog, :devices, :custom_fields, :use_original_filename + :ci_url, :changelog, :devices, :custom_fields ) end diff --git a/app/controllers/api/releases_controller.rb b/app/controllers/api/releases_controller.rb index 4e4839f49..030d18103 100644 --- a/app/controllers/api/releases_controller.rb +++ b/app/controllers/api/releases_controller.rb @@ -25,7 +25,7 @@ def set_release def release_params params.permit( :release_version, :build_version, :release_type, :source, :branch, :git_commit, - :ci_url, :custom_fields, :changelog, :use_original_filename + :ci_url, :custom_fields, :changelog ) end end diff --git a/app/controllers/releases_controller.rb b/app/controllers/releases_controller.rb index de4611514..c92d1efaa 100644 --- a/app/controllers/releases_controller.rb +++ b/app/controllers/releases_controller.rb @@ -91,8 +91,7 @@ def set_channel def release_params params.require(:release).permit( - :file, :changelog, :release_version, :build_version, :release_type, :branch, :git_commit, - :ci_url, :use_original_filename + :file, :changelog, :release_version, :build_version, :release_type, :branch, :git_commit, :ci_url ) end diff --git a/app/jobs/app_web_hook_job.rb b/app/jobs/app_web_hook_job.rb index d5d77462e..7128e73da 100644 --- a/app/jobs/app_web_hook_job.rb +++ b/app/jobs/app_web_hook_job.rb @@ -115,8 +115,7 @@ def build_example_release bundle_id: 'im.ews.zealot.example.app', release_version: '1.0.0', build_version: '5', - git_commit: '31dbb8497b81e103ecadcab0ca724c3fd87b3ab9', - use_original_filename: false + git_commit: '31dbb8497b81e103ecadcab0ca724c3fd87b3ab9' ) end end diff --git a/app/models/concerns/release_parser.rb b/app/models/concerns/release_parser.rb index 4eab3826d..5980ed03a 100644 --- a/app/models/concerns/release_parser.rb +++ b/app/models/concerns/release_parser.rb @@ -32,7 +32,6 @@ def build_metadata(parser, default_source) self.release_version = parser.release_version self.build_version = parser.build_version self.release_type ||= parser.release_type if parser.respond_to?(:release_type) - self.original_filename = File.basename(file.path) if parser.use_original_filename icon_file = fetch_icon(parser) self.icon = icon_file if icon_file diff --git a/app/serializers/api/upload_app_serializer.rb b/app/serializers/api/upload_app_serializer.rb index e8fc18aa0..c52614e73 100644 --- a/app/serializers/api/upload_app_serializer.rb +++ b/app/serializers/api/upload_app_serializer.rb @@ -5,7 +5,7 @@ class Api::UploadAppSerializer < ApplicationSerializer attributes :id, :version, :app_name, :bundle_id, :release_version, :build_version, :source, :branch, :git_commit, :ci_url, :size, :platform, :device_type, :icon_url, :release_url, :install_url, :qrcode_url, :changelog, :text_changelog, - :custom_fields, :created_at, :use_original_filename + :custom_fields, :created_at belongs_to :app belongs_to :scheme diff --git a/app/serializers/release_serializer.rb b/app/serializers/release_serializer.rb index ac3d806bc..f76ff419f 100644 --- a/app/serializers/release_serializer.rb +++ b/app/serializers/release_serializer.rb @@ -4,7 +4,7 @@ class ReleaseSerializer < ApplicationSerializer attributes :id, :version, :app_name, :bundle_id, :release_version, :build_version, :source, :branch, :git_commit, :ci_url, :size, :platform, :device_type, :icon_url, :install_url, :changelog, :text_changelog, :custom_fields, - :created_at, :use_original_filename + :created_at def changelog diff --git a/app/services/create_sample_data_service.rb b/app/services/create_sample_data_service.rb index 6b10908a9..24640c0e4 100644 --- a/app/services/create_sample_data_service.rb +++ b/app/services/create_sample_data_service.rb @@ -796,8 +796,7 @@ def generate_release(channel, app_bundle_id, release_type, changelog, build_vers branch: 'develop', device_type: device_type || channel.device_type, git_commit: SecureRandom.hex, - changelog: changelog, - use_original_filename: false + changelog: changelog ).save(validate: false) end diff --git a/app/views/releases/_form.html.slim b/app/views/releases/_form.html.slim index b8ab3a9f7..51bd04ae8 100644 --- a/app/views/releases/_form.html.slim +++ b/app/views/releases/_form.html.slim @@ -8,7 +8,6 @@ = f.input :branch = f.input :git_commit = f.input :ci_url - = f.input :use_original_filename, as: :radio_buttons, collection: [[true, '启用'], [false, '禁用']], checked: @use_original_filename = f.input :changelog, input_html: { rows: 10, cols: 10 } = f.button :submit diff --git a/config/locales/simple_form/simple_form.en.yml b/config/locales/simple_form/simple_form.en.yml index d44933a3c..4be7fba0f 100644 --- a/config/locales/simple_form/simple_form.en.yml +++ b/config/locales/simple_form/simple_form.en.yml @@ -50,7 +50,6 @@ en: branch: Git branch git_commit: Git commit SHA ci_url: CI URL - use_original_filename: Use original file name web_hook: url: URL body: Body @@ -118,7 +117,6 @@ en: branch: Git branch. In general either main or develop. git_commit: 40 bit length SHA value of git commit ci_url: The CI URL specific like Jenkins, Gitlab CI etc - use_original_filename: When this option is enabled, the name of the downloaded file will remain the same as the name of the uploaded file. web_hook: body: Custom JSON struct body to apply the third party notification services. Use default structure by leave it empty. debug_file: diff --git a/config/locales/simple_form/simple_form.zh-CN.yml b/config/locales/simple_form/simple_form.zh-CN.yml index 0ab2c04a9..abce12d92 100644 --- a/config/locales/simple_form/simple_form.zh-CN.yml +++ b/config/locales/simple_form/simple_form.zh-CN.yml @@ -50,7 +50,6 @@ zh-CN: branch: Git 分支名称 git_commit: Git 最后提交 SHA ci_url: CI URL - use_original_filename: 使用原文件名 web_hook: url: URL body: 自定义消息体 @@ -119,7 +118,6 @@ zh-CN: branch: 通常情况是 main 或 develop git_commit: 通常是 40 位长度的哈希值 ci_url: Jenkins、Gitlab CI 具体构建的地址 - use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致 web_hook: body: 自定义的 JSON 消息体以满足不同第三方服务消息体的要求,不填写会使用默认结构 debug_file: diff --git a/config/locales/zealot/api.en.yml b/config/locales/zealot/api.en.yml index b79c7da5e..71f46e470 100644 --- a/config/locales/zealot/api.en.yml +++ b/config/locales/zealot/api.en.yml @@ -103,7 +103,6 @@ en: branch: a branch name from source control tool git_commit: Git Commit SHA value ci_url: the build url of a CI service - use_original_filename: When this option is enabled, the name of the downloaded file will be the same as the name of the uploaded file. The default value is `false` custom_fields: JSON formatted custom fields, icon only accepts fontawesome. app_options: description: App form data diff --git a/config/locales/zealot/api.zh-CN.yml b/config/locales/zealot/api.zh-CN.yml index eda0f59b4..9b024f582 100644 --- a/config/locales/zealot/api.zh-CN.yml +++ b/config/locales/zealot/api.zh-CN.yml @@ -100,7 +100,6 @@ zh-CN: branch: 代码控制软件的分支名 git_commit: 代码控制软件提交哈希值 ci_url: 持续构建系统构建 URL - use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致,默认是 `false` custom_fields: 这是一个用 JSON 字符串定义的自定义字段,图标可接受 fontawesome app_options: description: 应用表单字段结构 @@ -132,7 +131,6 @@ zh-CN: branch: 代码控制软件的分支名 git_commit: 代码控制软件提交哈希值 ci_url: 持续构建系统构建 URL - use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致,默认是 `false` custom_fields: 这是一个用 JSON 字符串定义的自定义字段,图标可接受 fontawesome collaborator_options: description: 应用成员表单字段结构 diff --git a/db/migrate/20150210090223_create_releases.rb b/db/migrate/20150210090223_create_releases.rb index 908b26aa3..8c75b7ce3 100644 --- a/db/migrate/20150210090223_create_releases.rb +++ b/db/migrate/20150210090223_create_releases.rb @@ -15,7 +15,6 @@ def change t.jsonb :changelog, null: false t.string :file, null: true t.jsonb :devices, null: false, default: [] - t.boolean :use_original_filename, default: false t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 59acc73ef..999a9e2fe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -282,7 +282,6 @@ t.jsonb "custom_fields", default: [], null: false t.string "name" t.string "device_type" - t.boolean "use_original_filename", default: false t.index ["build_version"], name: "index_releases_on_build_version" t.index ["bundle_id"], name: "index_releases_on_bundle_id" t.index ["channel_id", "version"], name: "index_releases_on_channel_id_and_version", unique: true diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index 44a454edd..f042b0fc8 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -159,7 +159,6 @@ text_changelog: { type: :string, example: '- bump 1.1\n-n fixes bugs' }, custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }}, created_at: { type: :date, example: '2024-03-01 12:00:00 +0800' }, - use_original_filename: { type: :boolean, example: true }, } }, ReleaseChangelog: { @@ -306,7 +305,6 @@ branch: { type: :string, description: I18n.t('api.definitions.upload_options.properties.branch') }, git_commit: { type: :string, description: I18n.t('api.definitions.upload_options.properties.git_commit') }, ci_url: { type: :string, description: I18n.t('api.definitions.upload_options.properties.ci_url') }, - use_original_filename: { type: :boolean, description: I18n.t('api.definitions.upload_options.properties.use_original_filename') }, custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }, description: I18n.t('api.definitions.upload_options.properties.custom_fields')}, } }, @@ -353,7 +351,6 @@ branch: { type: :string, description: I18n.t('api.definitions.release_options.properties.branch') }, git_commit: { type: :string, description: I18n.t('api.definitions.release_options.properties.git_commit') }, ci_url: { type: :string, description: I18n.t('api.definitions.release_options.properties.ci_url') }, - use_original_filename: { type: :boolean, description: I18n.t('api.definitions.release_options.properties.use_original_filename') }, custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }, description: I18n.t('api.definitions.release_options.properties.custom_fields')}, } }, diff --git a/swagger/v1/swagger_en.json b/swagger/v1/swagger_en.json index 49c181d3f..40f294aea 100644 --- a/swagger/v1/swagger_en.json +++ b/swagger/v1/swagger_en.json @@ -2393,10 +2393,6 @@ "created_at": { "type": "date", "example": "2024-03-01 12:00:00 +0800" - }, - "use_original_filename": { - "type": "boolean", - "example": true } } }, @@ -2875,10 +2871,6 @@ "type": "string", "description": "the build url of a CI service" }, - "use_original_filename": { - "type": "boolean", - "example": true - }, "custom_fields": { "type": "array", "items": { @@ -3006,10 +2998,6 @@ "type": "string", "description": "the build url of a CI service" }, - "use_original_filename": { - "type": "boolean", - "example": true - }, "custom_fields": { "type": "array", "items": { diff --git a/swagger/v1/swagger_zh-CN.json b/swagger/v1/swagger_zh-CN.json index 5c0c9ad56..0297ab1ca 100644 --- a/swagger/v1/swagger_zh-CN.json +++ b/swagger/v1/swagger_zh-CN.json @@ -2393,10 +2393,6 @@ "created_at": { "type": "date", "example": "2024-03-01 12:00:00 +0800" - }, - "use_original_filename": { - "type": "boolean", - "example": true } } }, @@ -2875,10 +2871,6 @@ "type": "string", "description": "持续构建系统构建 URL" }, - "use_original_filename": { - "type": "boolean", - "example": true - }, "custom_fields": { "type": "array", "items": { @@ -3006,10 +2998,6 @@ "type": "string", "description": "持续构建系统构建 URL" }, - "use_original_filename": { - "type": "boolean", - "example": true - }, "custom_fields": { "type": "array", "items": {