1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
package com.juick.service.rest;
import com.juick.ExternalToken;
import com.juick.User;
import com.juick.server.helpers.ApplicationStatus;
import com.juick.service.CrosspostService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.inject.Inject;
import java.util.Optional;
@Component
public class CrosspostRestService implements CrosspostService {
@Inject
private RestTemplate rest;
@Override
public Optional<ExternalToken> getTwitterToken(int uid) {
User user = rest.getForObject("https://api.juick.com/tokens?uid={uid}", User.class, uid);
if (user != null) {
return user.getTokens().stream()
.filter(t -> t.getType().equals("twitter")).findFirst();
}
return Optional.empty();
}
@Override
public boolean deleteTwitterToken(Integer uid) {
return false;
}
@Override
public Optional<String> getFacebookToken(int uid) {
return null;
}
@Override
public ApplicationStatus getFbCrossPostStatus(int uid) {
return null;
}
@Override
public boolean enableFBCrosspost(Integer uid) {
return false;
}
@Override
public void disableFBCrosspost(Integer uid) {
}
@Override
public String getTwitterName(int uid) {
ExternalToken token = getTwitterToken(uid).orElse(null);
if (token != null) {
return token.getName();
}
return StringUtils.EMPTY;
}
@Override
public String getTelegramName(int uid) {
return null;
}
@Override
public Optional<Pair<String, String>> getVkTokens(int uid) {
return null;
}
@Override
public void deleteVKUser(Integer uid) {
}
@Override
public int getUIDbyFBID(long fbID) {
return 0;
}
@Override
public boolean createFacebookUser(long fbID, String loginhash, String token, String fbName, String fbLink) {
return false;
}
@Override
public boolean updateFacebookUser(long fbID, String token, String fbName, String fbLink) {
return false;
}
@Override
public int getUIDbyVKID(long vkID) {
return 0;
}
@Override
public boolean createVKUser(long vkID, String loginhash, String token, String vkName, String vkLink) {
return false;
}
@Override
public String getFacebookNameByHash(String hash) {
return null;
}
@Override
public String getTelegramNameByHash(String hash) {
return null;
}
@Override
public boolean setFacebookUser(String hash, int uid) {
return false;
}
@Override
public String getVKNameByHash(String hash) {
return null;
}
@Override
public boolean setVKUser(String hash, int uid) {
return false;
}
@Override
public boolean setTelegramUser(String hash, int uid) {
return false;
}
@Override
public String getJIDByHash(String hash) {
return null;
}
@Override
public boolean setJIDUser(String hash, int uid) {
return false;
}
}
|