mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 15:44:45 +02:00
REPP: Read/Ack poll messages
This commit is contained in:
parent
06088e33c5
commit
99a1f1f489
3 changed files with 52 additions and 1 deletions
|
@ -35,7 +35,7 @@ module Repp
|
||||||
param :ipv6, Array, desc: 'Array of IPv4 addresses'
|
param :ipv6, Array, desc: 'Array of IPv4 addresses'
|
||||||
end
|
end
|
||||||
param :admin_domain_contacts_attributes, Array, required: false, desc: 'Admin domain contacts codes'
|
param :admin_domain_contacts_attributes, Array, required: false, desc: 'Admin domain contacts codes'
|
||||||
param :admin_domain_contacts_attributes, Array, required: false, desc: 'Tech domain contacts codes'
|
param :tech_domain_contacts_attributes, Array, required: false, desc: 'Tech domain contacts codes'
|
||||||
param :dnskeys_attributes, Array, required: false, desc: 'DNSSEC keys for domain' do
|
param :dnskeys_attributes, Array, required: false, desc: 'DNSSEC keys for domain' do
|
||||||
param :flags, String, required: true, desc: 'Flag of DNSSEC key'
|
param :flags, String, required: true, desc: 'Flag of DNSSEC key'
|
||||||
param :protocol, String, required: true, desc: 'Protocol of DNSSEC key'
|
param :protocol, String, required: true, desc: 'Protocol of DNSSEC key'
|
||||||
|
@ -143,6 +143,8 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def forward_registrar_id
|
def forward_registrar_id
|
||||||
|
return unless params[:domain]
|
||||||
|
|
||||||
params[:domain][:registrar_id] = current_user.registrar.id
|
params[:domain][:registrar_id] = current_user.registrar.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
module Repp
|
||||||
|
module V1
|
||||||
|
module Registrar
|
||||||
|
class NotificationsController < BaseController
|
||||||
|
before_action :set_notification, only: [:update]
|
||||||
|
|
||||||
|
api :GET, '/repp/v1/registrar/notifications'
|
||||||
|
desc 'Get the latest unread poll message'
|
||||||
|
def index
|
||||||
|
@notification = current_user.unread_notifications.order('created_at DESC').take
|
||||||
|
render_success(data: nil) and return unless @notification
|
||||||
|
|
||||||
|
data = @notification.as_json(only: [:id, :text, :attached_obj_id,
|
||||||
|
:attached_obj_type])
|
||||||
|
|
||||||
|
render_success(data: data)
|
||||||
|
end
|
||||||
|
|
||||||
|
api :GET, '/repp/v1/registrar/notifications/:notification_id'
|
||||||
|
desc 'Get a specific poll message'
|
||||||
|
def show
|
||||||
|
@notification = current_user.registrar.notifications.find(params[:id])
|
||||||
|
data = @notification.as_json(only: [:id, :text, :attached_obj_id,
|
||||||
|
:attached_obj_type])
|
||||||
|
|
||||||
|
render_success(data: data)
|
||||||
|
end
|
||||||
|
|
||||||
|
api :PUT, '/repp/v1/registrar/notifications'
|
||||||
|
desc 'Mark poll message as read'
|
||||||
|
param :notification, Hash, required: true do
|
||||||
|
param :read, [true], required: true, desc: "Set as true to mark as read"
|
||||||
|
end
|
||||||
|
def update
|
||||||
|
handle_errors(@notification) and return unless @notification.mark_as_read
|
||||||
|
|
||||||
|
render_success(data: { notification_id: @notification.id, read: true })
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_notification
|
||||||
|
@notification = current_user.unread_notifications.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -53,6 +53,7 @@ Rails.application.routes.draw do
|
||||||
resources :auctions, only: %i[index]
|
resources :auctions, only: %i[index]
|
||||||
resources :retained_domains, only: %i[index]
|
resources :retained_domains, only: %i[index]
|
||||||
namespace :registrar do
|
namespace :registrar do
|
||||||
|
resources :notifications, only: [:index, :show, :update]
|
||||||
resources :nameservers do
|
resources :nameservers do
|
||||||
collection do
|
collection do
|
||||||
put '/', to: 'nameservers#update'
|
put '/', to: 'nameservers#update'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue