mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-21 20:25:45 +08:00
add: notice system api
This commit is contained in:
37
app/services/notice/write/create_service.rb
Normal file
37
app/services/notice/write/create_service.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class Notice::Write::CreateService < Notice::Write::ClientService
|
||||
attr_accessor :receivers, :sender, :content, :notification_url, :source, :extra, :type
|
||||
|
||||
def initialize(receivers, content, notification_url, source, type=1, extra={},sender=-1)
|
||||
@receivers = receivers
|
||||
@sender = sender
|
||||
@content = content
|
||||
@notification_url = notification_url
|
||||
@source = source
|
||||
@extra = extra
|
||||
@type = type
|
||||
end
|
||||
|
||||
def call
|
||||
result = post("", request_params)
|
||||
response = render_response(result)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request_receivers
|
||||
receivers.join(",")
|
||||
end
|
||||
|
||||
def request_params
|
||||
Hash.new.merge(data: {
|
||||
receivers: request_receivers,
|
||||
sender: sender,
|
||||
content: content,
|
||||
notification_url: notification_url,
|
||||
source: source,
|
||||
extra: extra.to_json.to_s,
|
||||
type: type
|
||||
}.stringify_keys)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user