diff --git a/models/activities1.py b/models/activities1.py deleted file mode 100644 index 452ae0600e3392a55a7573b1234874b1e59c54ed..0000000000000000000000000000000000000000 --- a/models/activities1.py +++ /dev/null @@ -1,11 +0,0 @@ -from pydantic import BaseModel, HttpUrl -from typing import List -from models.actors1 import Actor -from models.objects1 import Object - -class Activity(BaseModel): - id: HttpUrl - type: str - actor: Actor - object: Object - to: List[HttpUrl] = [] diff --git a/models/actors1.py b/models/actors1.py deleted file mode 100644 index 68bfc77900186d36b5c9ba3fd65a6a0db6a4ac1e..0000000000000000000000000000000000000000 --- a/models/actors1.py +++ /dev/null @@ -1,58 +0,0 @@ -from __future__ import annotations -from typing import Optional, Union, List -from pydantic import BaseModel, HttpUrl, Field -from serializers.json_serializer import ActivityPubModel -from .objects1 import Object, _MediaMixin - - -class Icon(ActivityPubModel, _MediaMixin): - type: Optional[str] = "Image" - mediaType: Optional[str] = "image/jpeg" - url: HttpUrl - -class Actor(Object): - """ - Base class for ActivityPub actors. - """ - inbox: HttpUrl - outbox: HttpUrl - following: Optional[HttpUrl] = None - followers: Optional[HttpUrl] = None - liked: Optional[HttpUrl] = None - streams: Optional[Union[HttpUrl, List[HttpUrl]]] = None - preferred_username: Optional[str] = None - name: Optional[str] = None - summary: Optional[str] = None - icon: Optional[Union[HttpUrl, List[Icon]]] = None - preferred_username_map: Optional[dict] = None - endpoints: Optional[dict] = None - -class Person(Actor): - """ - Represents a Person actor in ActivityPub. - """ - type: str = "Person" - -class Group(Actor): - """ - Represents a Group actor in ActivityPub. - """ - type: str = "Group" - -class Organization(Actor): - """ - Represents an Organization actor in ActivityPub. - """ - type: str = "Organization" - -class Application(Actor): - """ - Represents an Application actor in ActivityPub. - """ - type: str = "Application" - -class Service(Actor): - """ - Represents a Service actor in ActivityPub. - """ - type: str = "Service" diff --git a/models/collections1.py b/models/collections1.py deleted file mode 100644 index 58ddbc37332fd021c842b949ebd9494e079cab3b..0000000000000000000000000000000000000000 --- a/models/collections1.py +++ /dev/null @@ -1,30 +0,0 @@ -from __future__ import annotations -from pydantic import HttpUrl, Field, AnyUrl, PositiveInt -from typing import Optional, List, Union -from .objects1 import Object, Link - -class Collection(Object): - """ - Collection object, inheriting from Object - - """ - items: List[Union[Object, Link]] - total_items: Optional[PositiveInt] = None - first: Optional[Union["CollectionPage", Link]] = None - last: Optional[Union["CollectionPage", Link]] = None - current: Optional[Union["CollectionPage", Link]] = None - -class CollectionPage(Collection): - part_of: Optional[Union[Link, Collection]] = None - next: Optional[Union[Link, "CollectionPage"]] = None - prev: Optional[Union[Link, "CollectionPage"]] = None - -class OrderedCollection(Object): - ordered_items: List[Union[Object, Link]] - total_items: PositiveInt - first: Optional[Union["OrderedCollectionPage", Link]] = None - last: Optional[Union["OrderedCollectionPage", Link]] = None - current: Optional[Union["OrderedCollectionPage", Link]] = None - -class OrderedCollectionPage(CollectionPage): - start_index: Optional[PositiveInt] = None \ No newline at end of file diff --git a/models/links1.py b/models/links1.py deleted file mode 100644 index 688ae9daf801499bd3e8007db722fe806206c45d..0000000000000000000000000000000000000000 --- a/models/links1.py +++ /dev/null @@ -1,22 +0,0 @@ -from __future__ import annotations -from pydantic import HttpUrl -from typing import Optional, List -from serializers.json_serializer import ActivityPubModel -from .objects1 import _MediaMixin - -class Link(ActivityPubModel, _MediaMixin): - """ - Base class for links - - """ - href: Optional[HttpUrl] - hreflang: Optional[str] - rel: Optional[List[str]] - height: Optional[int] - width: Optional[int] - media_types: Optional[str] - -class Mention(Link): - """ - """ - type: str = "Mention" \ No newline at end of file diff --git a/models/objects1.py b/models/objects1.py deleted file mode 100644 index 6c980537eb9bdf15b5f3efb63944aaf745737b77..0000000000000000000000000000000000000000 --- a/models/objects1.py +++ /dev/null @@ -1,115 +0,0 @@ -from __future__ import annotations -from pydantic import HttpUrl, Field, AnyUrl, PositiveInt, validator -from typing import Optional, List, Union -from datetime import datetime, timedelta -from serializers.json_serializer import ActivityPubModel -from .collections1 import Collection -from .links import Link - -class _ObjectBaseModel(ActivityPubModel): - """ - Base class for all objects in the ActivityStreams vocabulary - - """ - id: Optional[HttpUrl] = None # Id is optional for transient objects - type: str - context: Optional[Union[HttpUrl, List[HttpUrl]]] = Field(alias="@context") - name: Optional[str] = None - -class _MediaMixin: - """ - Validation helper for MIME types. - This validates the type of media file in use - it recognizes "image/jpeg", "image/png", "application/json", "text/html" - - """ - @validator("media_type") - def validate_media_type(cls, value): - allowed_mimes = ["image/jpeg", "image/png", "application/json", "text/html"] - if value and value not in allowed_mimes: - raise ValueError(f"Invalid MIME type: {value}") - return value - -class _MediaObject(_ObjectBaseModel, _MediaMixin): - """ - Base class for objects with media support - - """ - media_type: Optional[str] # MIME type validation - -class Image(_MediaObject): - pass - -class Object(_MediaObject): - """ - The Object class represents any object in the vocabulary. - https://www.w3.org/TR/activitystreams-core/#object - https://www.w3.org/TR/activitystreams-vocabulary/#object-types - - """ - attachment: Optional[List[Union[Object, Link]]] = None - audience: Optional[List[Union[Object, Link]]] = None - bcc: Optional[List[Union[Object, Link]]] = None - bto: Optional[List[Union[Object, Link]]] = None - cc: Optional[List[Union[Object, Link]]] = None - content: Optional[str] = None - content_map: Optional[dict] = None #TODO structure according to JSON-LD - generator: Optional[Union[Object, Link]] = None - icon: Optional[Union[Image, Link]] = None - image: Optional[Union[Image, Link]] = None - in_reply_to: Optional[Union[Object, Link]] = None - location: Optional[Union[Object, Link]] = None - end_time: Optional[datetime] = None - preview: Optional[Union[Object, Link]] = None - published: Optional[datetime] = None - replies: Optional[Collection] = None - start_time: Optional[datetime] = None - summary: Optional[str] = None - summary_map: Optional[dict] = None - tag: Optional[List[Union[Object, Link]]] = None - updated: Optional[datetime] = None - url: Optional[List[Union[AnyUrl, Link]]] = None - to: Optional[List[Union[Object, Link]]] = None - duration: Optional[timedelta] = None - - @validator("end_time", "start_time") - def validate_time_constraints(cls, v, values, field): - if field.name == "end_time" and v and values.get("start_time") and v < values["start_time"]: - raise ValueError("end_time cannot be before start_time") - return v - -class Event(Object): - """ - Represents any kind of event. - - """ - type: str = "Event" - -class Place(Object): - """ - Represents a logical or physical location. - https://www.w3.org/TR/activitystreams-vocabulary/#dfn-place - https://www.w3.org/TR/activitystreams-vocabulary/#places - - """ - type: str = "Place" - accuracy: float - altitude: float - latitude: float - logitude: float - raduis: float - units: str - - @validator("units") - def validate_unit(cls, value): - allowed_units = ["cm", " feet", " inches", " km", " m", " miles" ] - if value and value not in allowed_units: - raise ValueError(f"Invalid units type: {value}") - return value - -class Profile(Object): - """ - - """ - type: str = "Profile" - describes: str \ No newline at end of file