mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-04-29 16:30:29 +05:30
Add support for overriding subscriptions when importing.
This commit is contained in:
parent
86827d6a2c
commit
3e99d1d806
@ -254,9 +254,8 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||||||
try {
|
try {
|
||||||
String[] subscriptions = Constants.mapper.readValue(request.loadBody().getResult().asArray(),
|
String[] subscriptions = Constants.mapper.readValue(request.loadBody().getResult().asArray(),
|
||||||
String[].class);
|
String[].class);
|
||||||
return getJsonResponse(
|
return getJsonResponse(ResponseHelper.importResponse(request.getHeader(AUTHORIZATION),
|
||||||
ResponseHelper.importResponse(request.getHeader(AUTHORIZATION), subscriptions),
|
subscriptions, Boolean.parseBoolean(request.getQueryParameter("override"))), "private");
|
||||||
"private");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return getErrorResponse(e);
|
return getErrorResponse(e);
|
||||||
}
|
}
|
||||||
|
@ -801,7 +801,7 @@ public class ResponseHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final byte[] importResponse(String session, String[] channelIds)
|
public static final byte[] importResponse(String session, String[] channelIds, boolean override)
|
||||||
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||||
|
|
||||||
Session s = DatabaseSessionFactory.createSession();
|
Session s = DatabaseSessionFactory.createSession();
|
||||||
@ -811,9 +811,12 @@ public class ResponseHelper {
|
|||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
||||||
Multithreading.runAsync(() -> {
|
Multithreading.runAsync(() -> {
|
||||||
for (String channelId : channelIds)
|
if (override)
|
||||||
if (!user.getSubscribed().contains(channelId))
|
user.setSubscribed(Arrays.asList(channelIds));
|
||||||
user.getSubscribed().add(channelId);
|
else
|
||||||
|
for (String channelId : channelIds)
|
||||||
|
if (!user.getSubscribed().contains(channelId))
|
||||||
|
user.getSubscribed().add(channelId);
|
||||||
|
|
||||||
if (channelIds.length > 0) {
|
if (channelIds.length > 0) {
|
||||||
s.update(user);
|
s.update(user);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user