mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 09:38:02 +01:00
Add routing for stories.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package org.whispersystems.websocket;
|
||||
|
||||
/**
|
||||
* Class containing constants and shared logic for handling stories.
|
||||
* <p>
|
||||
* In particular, it defines the way we interpret the X-Signal-Receive-Stories header
|
||||
* which is used by both WebSockets and by the REST API.
|
||||
*/
|
||||
public class Stories {
|
||||
public final static String X_SIGNAL_RECEIVE_STORIES = "X-Signal-Receive-Stories";
|
||||
|
||||
public static boolean parseReceiveStoriesHeader(String s) {
|
||||
return "true".equals(s);
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,12 @@ public class WebSocketClient {
|
||||
|
||||
public WebSocketClient(Session session, RemoteEndpoint remoteEndpoint,
|
||||
WebSocketMessageFactory messageFactory,
|
||||
Map<Long, CompletableFuture<WebSocketResponseMessage>> pendingRequestMapper)
|
||||
{
|
||||
this.session = session;
|
||||
this.remoteEndpoint = remoteEndpoint;
|
||||
this.messageFactory = messageFactory;
|
||||
Map<Long, CompletableFuture<WebSocketResponseMessage>> pendingRequestMapper) {
|
||||
this.session = session;
|
||||
this.remoteEndpoint = remoteEndpoint;
|
||||
this.messageFactory = messageFactory;
|
||||
this.pendingRequestMapper = pendingRequestMapper;
|
||||
this.created = System.currentTimeMillis();
|
||||
this.created = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public CompletableFuture<WebSocketResponseMessage> sendRequest(String verb, String path,
|
||||
@@ -92,6 +91,11 @@ public class WebSocketClient {
|
||||
session.close(code, message);
|
||||
}
|
||||
|
||||
public boolean shouldDeliverStories() {
|
||||
String value = session.getUpgradeRequest().getHeader(Stories.X_SIGNAL_RECEIVE_STORIES);
|
||||
return Stories.parseReceiveStoriesHeader(value);
|
||||
}
|
||||
|
||||
public void hardDisconnectQuietly() {
|
||||
try {
|
||||
session.disconnect();
|
||||
|
||||
Reference in New Issue
Block a user