parent
3b0bc18db9
commit
fa33750105
@ -1,4 +1,7 @@
|
|||||||
class ProfileController < ApplicationController
|
class ProfileController < ApplicationController
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def entry
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
class Favourite < ActiveRecord::Base
|
||||||
|
belongs_to :account, inverse_of: :favourites
|
||||||
|
belongs_to :status, inverse_of: :favourites
|
||||||
|
|
||||||
|
has_one :stream_entry, as: :activity
|
||||||
|
|
||||||
|
def verb
|
||||||
|
:favorite
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
"#{self.account.acct} favourited a status by #{self.status.account.acct}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def content
|
||||||
|
title
|
||||||
|
end
|
||||||
|
|
||||||
|
def object_type
|
||||||
|
target.object_type
|
||||||
|
end
|
||||||
|
|
||||||
|
def target
|
||||||
|
self.status
|
||||||
|
end
|
||||||
|
|
||||||
|
def mentions
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
|
def thread
|
||||||
|
target
|
||||||
|
end
|
||||||
|
|
||||||
|
after_create do
|
||||||
|
self.account.stream_entries.create!(activity: self)
|
||||||
|
end
|
||||||
|
end
|
@ -1,37 +1,9 @@
|
|||||||
Nokogiri::XML::Builder.new do |xml|
|
Nokogiri::XML::Builder.new do |xml|
|
||||||
entry(xml, true) do
|
entry(xml, true) do
|
||||||
unique_id xml, @entry.created_at, @entry.activity_id, @entry.activity_type
|
|
||||||
published_at xml, @entry.activity.created_at
|
|
||||||
updated_at xml, @entry.activity.updated_at
|
|
||||||
title xml, @entry.title
|
|
||||||
content xml, @entry.content
|
|
||||||
verb xml, @entry.verb
|
|
||||||
|
|
||||||
author(xml) do
|
author(xml) do
|
||||||
object_type xml, :person
|
include_author xml, @entry.account
|
||||||
uri xml, profile_url(name: @entry.account.username)
|
|
||||||
name xml, @entry.account.username
|
|
||||||
summary xml, @entry.account.note
|
|
||||||
link_alternate xml, profile_url(name: @entry.account.username)
|
|
||||||
portable_contact xml, @entry.account
|
|
||||||
end
|
|
||||||
|
|
||||||
if @entry.targeted?
|
|
||||||
target(xml) do
|
|
||||||
object_type xml, @entry.target.object_type
|
|
||||||
simple_id xml, @entry.target.uri
|
|
||||||
title xml, @entry.target.title
|
|
||||||
summary xml, @entry.target.summary
|
|
||||||
link_alternate xml, @entry.target.uri
|
|
||||||
|
|
||||||
if @entry.target.object_type == :person
|
|
||||||
portable_contact xml, @entry.target
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
object_type xml, @entry.object_type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
link_self xml, atom_entry_url(id: @entry.id)
|
include_entry xml, @entry
|
||||||
end
|
end
|
||||||
end
|
end.to_xml
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
class AddMetadataToStatuses < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :statuses, :in_reply_to_id, :integer, null: true
|
||||||
|
add_column :statuses, :reblog_of_id, :integer, null: true
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class MakeUrisNullableInStatuses < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :statuses, :uri, :string, null: true, default: nil
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddUrlToStatuses < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :statuses, :url, :string, null: true, default: nil
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddUrlToAccounts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :accounts, :url, :string, null: true, default: nil
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,12 @@
|
|||||||
|
class CreateFavourites < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :favourites do |t|
|
||||||
|
t.integer :account_id, null: false
|
||||||
|
t.integer :status_id, null: false
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :favourites, [:account_id, :status_id], unique: true
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Favourite, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue