Merge pull request '修复同步问题' (#3) from bankmulan into mulanoss_server

This commit is contained in:
gua2048 2022-07-13 10:51:52 +08:00
commit 98cb154193
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class WatchersController < ApplicationController
return normal_status(2, "你还没有关注哦") unless current_user.watched?(@target)
current_user.unwatch!(@target)
render_ok({watchers_count: @target.watchers_count, watched: false})
Users::SynchronizationService.call(current_user, @target, false) if params[:target_type].to_s == "project"
Users::SynchronizationService.new.call(current_user, @target, false) if params[:target_type].to_s == "project"
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
@ -27,7 +27,7 @@ class WatchersController < ApplicationController
return normal_status(2, "你已关注了") if current_user.watched?(@target)
current_user.watch!(@target)
render_ok({watchers_count: @target.watchers_count, watched: true})
Users::SynchronizationService.call(current_user, @target, true) if params[:target_type].to_s == "project"
Users::SynchronizationService.new.call(current_user, @target, true) if params[:target_type].to_s == "project"
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)

View File

@ -18,7 +18,7 @@ class Users::SynchronizationService
def sync_to_smart_doaction
uri = URI("http://smart.doaction.tech/smartApi/callback/mulan/project/favorite")
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'text/plain;charset=utf-8'})
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json; charset=utf-8'})
req.body = @data.to_json
res = http.request(req)
body = res.body
@ -32,7 +32,7 @@ class Users::SynchronizationService
projectUrl:"https://code.mulanos.cn/#{@target.owner.login}/#{@target.name}",
projectTitle: @target.name,
projectDesc: @target.description,
operateTime: Time.now.to_i,
operateTime: Time.now.to_i * 1000,
}
end