mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-28 00:50:46 +08:00
Add subscription feature
This commit is contained in:
27
src/main/java/com/openisle/model/CommentSubscription.java
Normal file
27
src/main/java/com/openisle/model/CommentSubscription.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/** Subscription to a comment for replies notifications. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "comment_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "comment_id"}))
|
||||
public class CommentSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
}
|
||||
@@ -11,5 +11,9 @@ public enum NotificationType {
|
||||
/** Someone reacted to your post or comment */
|
||||
REACTION,
|
||||
/** Your post under review was approved or rejected */
|
||||
POST_REVIEWED
|
||||
POST_REVIEWED,
|
||||
/** A subscribed post received a new comment */
|
||||
POST_UPDATED,
|
||||
/** A user you subscribe to created a post or comment */
|
||||
USER_ACTIVITY
|
||||
}
|
||||
|
||||
27
src/main/java/com/openisle/model/PostSubscription.java
Normal file
27
src/main/java/com/openisle/model/PostSubscription.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/** Subscription to a post for update notifications. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "post_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "post_id"}))
|
||||
public class PostSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
}
|
||||
27
src/main/java/com/openisle/model/UserSubscription.java
Normal file
27
src/main/java/com/openisle/model/UserSubscription.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/** Following relationship between users. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "user_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"subscriber_id", "target_id"}))
|
||||
public class UserSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "subscriber_id")
|
||||
private User subscriber;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "target_id")
|
||||
private User target;
|
||||
}
|
||||
Reference in New Issue
Block a user