Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F8613254
report_note.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
report_note.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.ReportNote
do
use
Ecto.Schema
import
Ecto.Changeset
import
Ecto.Query
alias
Pleroma.Activity
alias
Pleroma.Repo
alias
Pleroma.ReportNote
alias
Pleroma.User
@type
t
::
%
__MODULE__
{}
schema
"report_notes"
do
field
(
:content
,
:string
)
belongs_to
(
:user
,
User
,
type
:
FlakeId.Ecto.CompatType
)
belongs_to
(
:activity
,
Activity
,
type
:
FlakeId.Ecto.CompatType
)
timestamps
()
end
@spec
create
(
FlakeId.Ecto.CompatType
.
t
(),
FlakeId.Ecto.CompatType
.
t
(),
String
.
t
())
::
{
:ok
,
ReportNote
.
t
()}
|
{
:error
,
Changeset
.
t
()}
def
create
(
user_id
,
activity_id
,
content
)
do
attrs
=
%{
user_id
:
user_id
,
activity_id
:
activity_id
,
content
:
content
}
%
ReportNote
{}
|>
cast
(
attrs
,
[
:user_id
,
:activity_id
,
:content
])
|>
validate_required
([
:user_id
,
:activity_id
,
:content
])
|>
Repo
.
insert
()
end
@spec
destroy
(
FlakeId.Ecto.CompatType
.
t
())
::
{
:ok
,
ReportNote
.
t
()}
|
{
:error
,
Changeset
.
t
()}
def
destroy
(
id
)
do
from
(
r
in
ReportNote
,
where
:
r
.
id
==
^
id
)
|>
Repo
.
one
()
|>
Repo
.
delete
()
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Oct 25, 3:14 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
541834
Default Alt Text
report_note.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment