| 
									
										
										
										
											2019-03-03 22:18:23 +01:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-27 15:55:23 +01:00
										 |  |  | class ActivityPub::VoteSerializer < ActivityPub::Serializer | 
					
						
							|  |  |  |   class NoteSerializer < ActivityPub::Serializer | 
					
						
							| 
									
										
										
										
											2019-03-03 22:18:23 +01:00
										 |  |  |     attributes :id, :type, :name, :attributed_to, | 
					
						
							|  |  |  |                :in_reply_to, :to | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def id | 
					
						
							| 
									
										
										
										
											2019-03-04 22:51:23 +01:00
										 |  |  |       ActivityPub::TagManager.instance.uri_for(object) || [ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id].join | 
					
						
							| 
									
										
										
										
											2019-03-03 22:18:23 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def type | 
					
						
							|  |  |  |       'Note' | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def name | 
					
						
							|  |  |  |       object.poll.options[object.choice.to_i] | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def attributed_to | 
					
						
							|  |  |  |       ActivityPub::TagManager.instance.uri_for(object.account) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-04 01:06:19 +01:00
										 |  |  |     def in_reply_to | 
					
						
							|  |  |  |       ActivityPub::TagManager.instance.uri_for(object.poll.status) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-03 22:18:23 +01:00
										 |  |  |     def to | 
					
						
							|  |  |  |       ActivityPub::TagManager.instance.uri_for(object.poll.account) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   attributes :id, :type, :actor, :to | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   has_one :object, serializer: ActivityPub::VoteSerializer::NoteSerializer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def id | 
					
						
							| 
									
										
										
										
											2019-03-04 01:53:58 +01:00
										 |  |  |     [ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id, '/activity'].join | 
					
						
							| 
									
										
										
										
											2019-03-03 22:18:23 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def type | 
					
						
							|  |  |  |     'Create' | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def actor | 
					
						
							|  |  |  |     ActivityPub::TagManager.instance.uri_for(object.account) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def to | 
					
						
							|  |  |  |     ActivityPub::TagManager.instance.uri_for(object.poll.account) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |