models

package
v0.0.0-...-df0384d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationToken

type ActivationToken struct {
	Id             uuid.UUID `gorm:"column:id;primary_key"`
	Username       string    `gorm:"column:username_fk;type:varchar(20)"`
	User           User      `gorm:"foreignKey:username_fk;references:username"`
	Token          string    `gorm:"column:token;not_null;varchar(6)"`
	ExpirationTime time.Time `gorm:"column:expiration_time;not_null"`
}

type ActivationTokenRequestDTO

type ActivationTokenRequestDTO struct {
	Token string `json:"token" binding:"required"`
}

type AuthorDTO

type AuthorDTO struct {
	Username          string `json:"username"`
	Nickname          string `json:"nickname"`
	ProfilePictureUrl string `json:"profilePictureUrl"`
}

type ChangePasswordDTO

type ChangePasswordDTO struct {
	OldPassword string `json:"oldPassword" binding:"required"`
	NewPassword string `json:"newPassword" binding:"required"`
}

type Chat

type Chat struct {
	Id        uuid.UUID `gorm:"column:id;primary_key"`
	Users     []User    `gorm:"many2many:chat_users;"` // gorm handles the join table
	CreatedAt time.Time `gorm:"column:created_at;not_null"`
}

type ChatCreateRequestDTO

type ChatCreateRequestDTO struct {
	Content  string `json:"content" binding:"required"`
	Username string `json:"username" binding:"required"`
}

type ChatCreateResponseDTO

type ChatCreateResponseDTO struct {
	ChatId  string                   `json:"chatId"`
	Message *FirstMessageResponseDTO `json:"message"`
}

type ChatRecordDTO

type ChatRecordDTO struct {
	ChatId string       `json:"chatId"`
	User   *ChatUserDTO `json:"user"`
}

type ChatUserDTO

type ChatUserDTO struct {
	Username          string `json:"username"`
	Nickname          string `json:"nickname"`
	ProfilePictureUrl string `json:"profilePictureUrl"`
}

type ChatsResponseDTO

type ChatsResponseDTO struct {
	Records []ChatRecordDTO `json:"records"`
}

type Comment

type Comment struct {
	Id        uuid.UUID `gorm:"column:id;primary_key"`
	PostID    uuid.UUID `gorm:"column:post_id"`
	Post      Post      `gorm:"foreignKey:post_id;references:id"`
	Username  string    `gorm:"column:username_fk;type:varchar(20)"`
	User      User      `gorm:"foreignKey:username_fk;references:username"`
	Content   string    `gorm:"column:content;type:varchar(128);not_null"`
	CreatedAt time.Time `gorm:"column:created_at;not_null"`
}

type CommentCreateRequestDTO

type CommentCreateRequestDTO struct {
	Content string `json:"content" binding:"required"`
}

type CommentFeedResponseDTO

type CommentFeedResponseDTO struct {
	Records    []CommentResponseDTO  `json:"records"`
	Pagination *CommentPaginationDTO `json:"pagination"`
}

type CommentPaginationDTO

type CommentPaginationDTO struct {
	Offset  int   `json:"offset"`
	Limit   int   `json:"limit"`
	Records int64 `json:"records"`
}

type CommentResponseDTO

type CommentResponseDTO struct {
	CommentId    uuid.UUID  `json:"commentId"`
	Content      string     `json:"content"`
	Author       *AuthorDTO `json:"author"` // AuthorDTO is defined in post.go
	CreationDate time.Time  `json:"creationDate"`
}

type FirstMessageResponseDTO

type FirstMessageResponseDTO struct {
	Content      string    `json:"content"`
	Username     string    `json:"username"`
	CreationDate time.Time `json:"creationDate"`
}

type GeneralFeedDTO

type GeneralFeedDTO struct {
	Records    []PostResponseDTO         `json:"records"`
	Pagination *GeneralFeedPaginationDTO `json:"pagination"`
}

type GeneralFeedPaginationDTO

type GeneralFeedPaginationDTO struct {
	LastPostId string `json:"lastPostId"`
	Limit      int    `json:"limit"`
	Records    int64  `json:"records"`
}

type Hashtag

type Hashtag struct {
	Id    uuid.UUID `gorm:"primary_key"`
	Name  string    `gorm:"uniqueIndex"`
	Posts []Post    `gorm:"many2many:post_hashtags;"` // gorm handles the join table
}

type InitiatePasswordResetResponseDTO

type InitiatePasswordResetResponseDTO struct {
	Email string `json:"email"` // Response contains censored mail
}

type Like

type Like struct {
	Id       uuid.UUID `gorm:"column:id;primary_key"`
	PostId   uuid.UUID `gorm:"column:post_id"`
	Post     Post      `gorm:"foreignKey:post_id;references:id"`
	Username string    `gorm:"column:username_fk"`
	User     User      `gorm:"foreignKey:username_fk;references:username"`
}

type Location

type Location struct {
	Id        uuid.UUID `gorm:"column:id;primary_key"`
	Longitude float64   `gorm:"type:float"`
	Latitude  float64   `gorm:"type:float"`
	Accuracy  uint      `gorm:"type:integer"`
}

type LocationDTO

type LocationDTO struct {
	Longitude *float64 `json:"longitude" binding:"required"` // using pointer to allow values to be zero
	Latitude  *float64 `json:"latitude" binding:"required"`
	Accuracy  *uint    `json:"accuracy" binding:"required"`
}

type Message

type Message struct {
	Id        uuid.UUID `gorm:"column:id;primary_key"`
	ChatId    uuid.UUID `gorm:"column:chat_id"`
	Chat      Chat      `gorm:"foreignKey:chat_id;references:id"`
	Username  string    `gorm:"column:username_fk;type:varchar(20)"`
	User      User      `gorm:"foreignKey:username_fk;references:username"`
	Content   string    `gorm:"column:content;type:varchar(256);null"`
	CreatedAt time.Time `gorm:"column:created_at;not_null"`
}

type MessageCreateRequestDTO

type MessageCreateRequestDTO struct {
	Content string `json:"content" binding:"required"`
}

type MessagePaginationDTO

type MessagePaginationDTO struct {
	Offset  int   `json:"offset"`
	Limit   int   `json:"limit"`
	Records int64 `json:"records"`
}

type MessageRecordDTO

type MessageRecordDTO struct {
	Content      string    `json:"content"`
	Username     string    `json:"username"`
	CreationDate time.Time `json:"creationDate"`
}

type MessagesResponseDTO

type MessagesResponseDTO struct {
	Records    []MessageRecordDTO    `json:"records"`
	Pagination *MessagePaginationDTO `json:"pagination"`
}

type Notification

type Notification struct {
	Id               uuid.UUID `gorm:"column:id;primaryKey"`
	Timestamp        time.Time `gorm:"column:timestamp"`
	NotificationType string    `gorm:"column:notification_type"`
	ForUsername      string    `gorm:"column:for_username"` // the user that the notification is for
	ForUser          User      `gorm:"foreignKey:for_username;references:username"`
	FromUsername     string    `gorm:"column:from_username"` // the user that created the notification by following or reposting
	FromUser         User      `gorm:"foreignKey:from_username;references:username"`
}

type NotificationRecordDTO

type NotificationRecordDTO struct {
	NotificationId   string               `json:"notificationId"`
	Timestamp        time.Time            `json:"timestamp"`
	NotificationType string               `json:"notificationType"`
	User             *NotificationUserDTO `json:"user"`
}

type NotificationUserDTO

type NotificationUserDTO struct {
	Username          string `json:"username"`
	Nickname          string `json:"nickname"`
	ProfilePictureUrl string `json:"profilePictureUrl"`
}

type NotificationsResponseDTO

type NotificationsResponseDTO struct {
	Records []NotificationRecordDTO `json:"records"`
}

type PasswordResetToken

type PasswordResetToken struct {
	Id             uuid.UUID `gorm:"type:uuid;primary_key;"`
	Username       string    `gorm:"column:username_fk;type:varchar(20);not_null"`
	User           User      `gorm:"foreignKey:username_fk;references:username"`
	Token          string    `gorm:"column:token;type:varchar(6);not_null"`
	ExpirationTime time.Time `gorm:"column:expiration_time;not_null"`
}

type Post

type Post struct {
	Id         uuid.UUID  `gorm:"column:id;primary_key"`
	Username   string     `gorm:"column:username_fk;type:varchar(20)"`
	User       User       `gorm:"foreignKey:username_fk;references:username"`
	Content    string     `gorm:"column:content;type:varchar(256);null"`
	ImageUrl   string     `gorm:"column:image_url;type:varchar(128);null"`
	Hashtags   []Hashtag  `gorm:"many2many:post_hashtags;onDelete:CASCADE"` // gorm handles the join table, onDelete:CASCADE deletes the hashtags if the post is deleted
	CreatedAt  time.Time  `gorm:"column:created_at;not_null"`
	LocationId *uuid.UUID `gorm:"column:location_id;null"`
	Location   Location   `gorm:"foreignKey:location_id;references:id"`
	RepostId   *uuid.UUID `gorm:"column:repost_id;null"` // no foreign key constraint, original post may be deleted without affecting repost
}

type PostCreateRequestDTO

type PostCreateRequestDTO struct {
	Content  string       `json:"content"`
	Location *LocationDTO `json:"location"`
	RepostId *string      `json:"repostedPostId"`
}

type PostResponseDTO

type PostResponseDTO struct {
	PostId       uuid.UUID        `json:"postId"`
	Author       *AuthorDTO       `json:"author"`
	CreationDate time.Time        `json:"creationDate"`
	Content      string           `json:"content"`
	Comments     int64            `json:"comments"`
	Likes        int64            `json:"likes"`
	Liked        bool             `json:"liked"`
	Location     *LocationDTO     `json:"location"`
	Repost       *PostResponseDTO `json:"repost"`
}

type PushSubscription

type PushSubscription struct {
	Id        uuid.UUID `gorm:"column:id;primary_key"`
	Username  string    `gorm:"column:username_fk;type:varchar(20)"`
	User      User      `gorm:"foreignKey:username_fk;references:username"`
	Type      string    `gorm:"column:type;type:varchar(4)"` // either "web" or "expo"
	Endpoint  string    `gorm:"column:endpoint;type:text"`   // for web only
	P256dh    string    `gorm:"column:p256dh;type:text"`     // for web only
	Auth      string    `gorm:"column:auth;type:text"`       // for web only
	ExpoToken string    `gorm:"column:expo_token;type:text"` // for expo only
}

type PushSubscriptionRequestDTO

type PushSubscriptionRequestDTO struct {
	Type             string            `json:"type" binding:"required"`
	SubscriptionInfo *SubscriptionInfo `json:"subscription"` // subscription info for web push notifications
	Token            string            `json:"token"`        // token for expo push notifications
}

type PushSubscriptionResponseDTO

type PushSubscriptionResponseDTO struct {
	SubscriptionId string `json:"subscriptionId"`
}

type ResetPasswordRequestDTO

type ResetPasswordRequestDTO struct {
	Token       string `json:"token" binding:"required"`
	NewPassword string `json:"newPassword" binding:"required"`
}

type Subscription

type Subscription struct {
	Id                uuid.UUID `gorm:"column:id;primary_key"`
	SubscriptionDate  time.Time `gorm:"column:subscription_date;not null"`
	FollowerUsername  string    `gorm:"column:follower;type:varchar(20)"`
	Follower          User      `gorm:"foreignKey:follower;references:username"` // Person who follows
	FollowingUsername string    `gorm:"column:following;type:varchar(20)"`       // Person who is being followed
	Following         User      `gorm:"foreignKey:following;references:username"`
}

type SubscriptionInfo

type SubscriptionInfo struct {
	Endpoint         string           `json:"endpoint" binding:"required"`
	SubscriptionKeys SubscriptionKeys `json:"keys" binding:"required"`
}

type SubscriptionKeys

type SubscriptionKeys struct {
	P256dh string `json:"p256dh" binding:"required"`
	Auth   string `json:"auth" binding:"required"`
}

type SubscriptionPaginationDTO

type SubscriptionPaginationDTO struct {
	Offset  int   `json:"offset"`
	Limit   int   `json:"limit"`
	Records int64 `json:"records"`
}

type SubscriptionPostRequestDTO

type SubscriptionPostRequestDTO struct {
	Following string `json:"following" binding:"required"`
}

type SubscriptionPostResponseDTO

type SubscriptionPostResponseDTO struct {
	SubscriptionId   uuid.UUID `json:"subscriptionId"`
	SubscriptionDate time.Time `json:"subscriptionDate"`
	Follower         string    `json:"username"`
	Following        string    `json:"following"`
}

type SubscriptionResponseDTO

type SubscriptionResponseDTO struct {
	Records    []UserSubscriptionRecordDTO `json:"records"`
	Pagination *SubscriptionPaginationDTO  `json:"pagination"`
}

type User

type User struct {
	Username          string    `gorm:"column:username;primary_key;type:varchar(20)"`
	Nickname          string    `gorm:"column:nickname;type:varchar(25)"`
	Email             string    `gorm:"column:email;type:varchar(128);not_null;unique"`
	PasswordHash      string    `gorm:"column:password_hash;type:varchar(80);not_null"`
	CreatedAt         time.Time `gorm:"column:created_at;not_null"`
	Activated         bool      `gorm:"column:activated;not_null"`
	ProfilePictureUrl string    `gorm:"column:profile_picture_url;type:varchar(128);null"`
	Status            string    `gorm:"column:status;type:varchar(128)"`
	Chats             []Chat    `gorm:"many2many:chat_users;"` // gorm handles the join table
}

type UserActivationRequestDTO

type UserActivationRequestDTO struct {
	Token string `json:"token" binding:"required"`
}

type UserCreateRequestDTO

type UserCreateRequestDTO struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
	Nickname string `json:"nickname"`
	Email    string `json:"email" binding:"required"`
}

type UserFeedDTO

type UserFeedDTO struct {
	Records    []UserFeedRecordDTO    `json:"records"`
	Pagination *UserFeedPaginationDTO `json:"pagination"`
}

type UserFeedPaginationDTO

type UserFeedPaginationDTO struct {
	Offset  int   `json:"offset"`
	Limit   int   `json:"limit"`
	Records int64 `json:"records"`
}

type UserFeedRecordDTO

type UserFeedRecordDTO struct {
	PostId       string           `json:"postId"`
	CreationDate time.Time        `json:"creationDate"`
	Content      string           `json:"content"`
	Comments     int64            `json:"comments"`
	Likes        int64            `json:"likes"`
	Liked        bool             `json:"liked"`
	Location     *LocationDTO     `json:"location"`
	Repost       *PostResponseDTO `json:"repost"`
}

type UserInformationUpdateDTO

type UserInformationUpdateDTO struct {
	Nickname string `json:"nickname"`
	Status   string `json:"status"`
}

type UserLoginRequestDTO

type UserLoginRequestDTO struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type UserLoginResponseDTO

type UserLoginResponseDTO struct {
	Token        string `json:"token"`
	RefreshToken string `json:"refreshToken"`
}

type UserProfileResponseDTO

type UserProfileResponseDTO struct {
	Username          string  `json:"username"`
	Nickname          string  `json:"nickname"`
	Status            string  `json:"status"`
	ProfilePictureUrl string  `json:"profilePictureUrl"`
	Follower          int64   `json:"follower"`
	Following         int64   `json:"following"`
	Posts             int64   `json:"posts"`
	SubscriptionId    *string `json:"subscriptionId"`
}

type UserRefreshTokenRequestDTO

type UserRefreshTokenRequestDTO struct {
	RefreshToken string `json:"refreshToken" binding:"required"`
}

type UserResponseDTO

type UserResponseDTO struct {
	Username string `json:"username"`
	Nickname string `json:"nickname"`
	Email    string `json:"email"`
}

type UserSearchPaginationDTO

type UserSearchPaginationDTO struct {
	Offset  int   `json:"offset"`
	Limit   int   `json:"limit"`
	Records int64 `json:"records"`
}

type UserSearchRecordDTO

type UserSearchRecordDTO struct {
	Username          string `json:"username"`
	Nickname          string `json:"nickname"`
	ProfilePictureUrl string `json:"profilePictureUrl"`
}

type UserSearchResponseDTO

type UserSearchResponseDTO struct {
	Records    []UserSearchRecordDTO    `json:"records"`
	Pagination *UserSearchPaginationDTO `json:"pagination"`
}

type UserSubscriptionRecordDTO

type UserSubscriptionRecordDTO struct {
	FollowerId        *uuid.UUID `gorm:"column:follower_id" json:"followerId"`                // SubscriptionID, wenn Nutzer mir folgt - ggf. null
	FollowingId       *uuid.UUID `gorm:"column:following_id" json:"followingId"`              // SubscriptionID, wenn ich Nutzer folge - ggf. null
	Username          string     `gorm:"column:username" json:"username"`                     // Der Benutzername des Followers/Following
	Nickname          string     `gorm:"column:nickname" json:"nickname"`                     // Der Spitzname des Followers/Following
	ProfilePictureUrl string     `gorm:"column:profile_picture_url" json:"profilePictureUrl"` // Die URL des Profilbildes des Followers/Following
}

type UserSubscriptionSearchRecordDTO

type UserSubscriptionSearchRecordDTO struct {
	Username          string `json:"username"`
	Nickname          string `json:"nickname"`
	ProfilePictureUrl string `json:"profilePictureUrl"`
}

type VapidKeyResponseDTO

type VapidKeyResponseDTO struct {
	Key string `json:"key"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL