diff options
author | 2018-10-05 01:38:04 +0300 | |
---|---|---|
committer | 2018-10-05 01:38:04 +0300 | |
commit | fe761771ce3cb65b00dc3a826c51b9f20ff6c72d (patch) | |
tree | 7671e1bd31dfc10f10d1110048efc313762c6dfe /juick-server/src/main/java/com/juick/server/TwitterManager.java | |
parent | a6824b011325df07caf284352f09c2b9f76155c7 (diff) |
TopEvent: Announce in Fediverse, like in XMPP/Telegram
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/TwitterManager.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/TwitterManager.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/TwitterManager.java b/juick-server/src/main/java/com/juick/server/TwitterManager.java index eeef2b91..613594e6 100644 --- a/juick-server/src/main/java/com/juick/server/TwitterManager.java +++ b/juick-server/src/main/java/com/juick/server/TwitterManager.java @@ -17,6 +17,8 @@ package com.juick.server; import com.juick.Message; +import com.juick.User; +import com.juick.service.UserService; import com.juick.service.component.*; import com.juick.service.CrosspostService; import com.juick.util.MessageUtils; @@ -28,6 +30,7 @@ import org.springframework.stereotype.Component; import twitter4j.TwitterFactory; import twitter4j.conf.ConfigurationBuilder; +import javax.annotation.PostConstruct; import javax.inject.Inject; /** @@ -45,6 +48,18 @@ public class TwitterManager implements NotificationListener { private String twitter_consumer_key; @Value("${twitter_consumer_secret:secret}") private String twitter_consumer_secret; + @Inject + private UserService userService; + + @Value("${service_user:juick}") + private String serviceUsername; + + private User serviceUser; + + @PostConstruct + public void init() { + serviceUser = userService.getUserByName(serviceUsername); + } void twitterPost(final com.juick.Message jmsg) { crosspostService.getTwitterToken(jmsg.getUser().getUid()).ifPresent(t -> { @@ -100,4 +115,11 @@ public class TwitterManager implements NotificationListener { public void processMessageReadEvent(MessageReadEvent messageReadEvent) { } + + @Override + public void processTopEvent(TopEvent topEvent) { + Message jmsg = topEvent.getMessage(); + jmsg.setUser(serviceUser); + twitterPost(jmsg); + } } |