1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# -*- coding: utf-8 -*-
module Plugin::Activity
class Activity < Retriever::Model
include Retriever::Model::MessageMixin
include Retriever::Model::UserMixin
register :activity, name: "Activity"
field.string :description, required: true
field.string :title, required: true
field.string :icon
field.bool :related
field.string :plugin_slug
field.time :date, required: true
field.string :kind, required: true
field.string :identity
field.has :children, [Retriever::Model]
# model_field
# service
# TLにアイコンを表示するため
def profile_image_url
icon || MUI::Skin.get('activity.png')
end
def plugin
self[:plugin] || Plugin[plugin_slug]
end
def title
self[:title].tr("\n", "")
end
def children
self[:children] || []
end
# TLに表示するため
def name
title
end
# TLに表示するため
def created
date
end
def host
kind.gsub('_', '-')
end
memoize def path
if identity
identity
elsif children.empty?
'/' + SecureRandom.uuid
else
children.inject('/'){|memo,child| memo + Digest::MD5.hexdigest(child.uri.to_s) + '/' }
end
end
end
end
|