-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refactor/group_validator_fields' into 'develop'
object_validators: Group common fields in CommonValidations See merge request pleroma/pleroma!3384
- Loading branch information
Showing
19 changed files
with
211 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
lib/pleroma/web/activity_pub/object_validators/common_fields.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Pleroma: A lightweight social networking server | ||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonFields do | ||
alias Pleroma.EctoType.ActivityPub.ObjectValidators | ||
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator | ||
alias Pleroma.Web.ActivityPub.ObjectValidators.TagValidator | ||
|
||
# Activities and Objects, except (Create)ChatMessage | ||
defmacro message_fields do | ||
quote bind_quoted: binding() do | ||
field(:type, :string) | ||
field(:id, ObjectValidators.ObjectID, primary_key: true) | ||
|
||
field(:to, ObjectValidators.Recipients, default: []) | ||
field(:cc, ObjectValidators.Recipients, default: []) | ||
field(:bto, ObjectValidators.Recipients, default: []) | ||
field(:bcc, ObjectValidators.Recipients, default: []) | ||
end | ||
end | ||
|
||
defmacro activity_fields do | ||
quote bind_quoted: binding() do | ||
field(:object, ObjectValidators.ObjectID) | ||
field(:actor, ObjectValidators.ObjectID) | ||
end | ||
end | ||
|
||
# All objects except Answer and CHatMessage | ||
defmacro object_fields do | ||
quote bind_quoted: binding() do | ||
field(:content, :string) | ||
|
||
field(:published, ObjectValidators.DateTime) | ||
field(:emoji, ObjectValidators.Emoji, default: %{}) | ||
embeds_many(:attachment, AttachmentValidator) | ||
end | ||
end | ||
|
||
# Basically objects that aren't ChatMessage and Answer | ||
defmacro status_object_fields do | ||
quote bind_quoted: binding() do | ||
# TODO: Remove actor on objects | ||
field(:actor, ObjectValidators.ObjectID) | ||
field(:attributedTo, ObjectValidators.ObjectID) | ||
|
||
embeds_many(:tag, TagValidator) | ||
|
||
field(:name, :string) | ||
field(:summary, :string) | ||
|
||
field(:context, :string) | ||
# short identifier for PleromaFE to group statuses by context | ||
field(:context_id, :integer) | ||
|
||
field(:sensitive, :boolean, default: false) | ||
field(:replies_count, :integer, default: 0) | ||
field(:like_count, :integer, default: 0) | ||
field(:announcement_count, :integer, default: 0) | ||
field(:inReplyTo, ObjectValidators.ObjectID) | ||
field(:url, ObjectValidators.Uri) | ||
|
||
field(:likes, {:array, ObjectValidators.ObjectID}, default: []) | ||
field(:announcements, {:array, ObjectValidators.ObjectID}, default: []) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.