aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-27 13:57:34 +0300
committerGravatar Vitaly Takmazov2022-12-27 13:57:34 +0300
commit3629010a96b4aa29ffbbfaab73c09a801d875957 (patch)
treeb175d5659a8c2f377e4a7949f890f5c5085eacea /src/main/java/com/juick/service
parent418cc7f031134e8e5dc72537140d3c82c09c543e (diff)
handle `addFollower` duplicates
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/ActivityPubService.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/ActivityPubService.java b/src/main/java/com/juick/service/ActivityPubService.java
index 1bf1b5d4..c45b0c13 100644
--- a/src/main/java/com/juick/service/ActivityPubService.java
+++ b/src/main/java/com/juick/service/ActivityPubService.java
@@ -20,6 +20,7 @@ package com.juick.service;
import com.juick.model.User;
import com.juick.model.AnonymousUser;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponents;
@@ -58,8 +59,12 @@ public class ActivityPubService extends BaseJdbcService implements SocialService
@Transactional
@Override
public void addFollower(User user, String acct) {
- getJdbcTemplate().update("INSERT INTO followers(user_id, acct) " +
- "VALUES(?, ?)", user.getUid(), acct);
+ try {
+ getJdbcTemplate().update("INSERT INTO followers(user_id, acct) " +
+ "VALUES(?, ?)", user.getUid(), acct);
+ } catch (DuplicateKeyException e) {
+ // ignore
+ }
}
@Transactional