REQ-3284: 推送

This commit is contained in:
yanglin 2024-11-27 20:44:57 +08:00
parent 7f8c8c2917
commit 5705c67c07
2 changed files with 13 additions and 6 deletions

View File

@ -97,13 +97,13 @@ public class NimPushService {
@SuppressWarnings({"rawtypes", "unchecked"})
private JSONObject buildPayload(PushContent content, PushPeer peer) {
Consumer<Intent<?>> intentPopulator = intent -> {
intent.setValue("type", IntentValue.CONSTANT_TYPE);
intent.setValue("sessionType", IntentValue.CONSTANT_SESSION_TYPE);
intent.setValue("sessionId", IntentValue.create(peer.getSenderImAccount()));
intent.setValue(Intent.INTENT_TYPE, IntentValue.CONSTANT_TYPE);
intent.setValue(Intent.INTENT_SESSION_TYPE, IntentValue.CONSTANT_SESSION_TYPE);
intent.setValue(Intent.INTENT_SESSION_ID, IntentValue.create(peer.getSenderImAccount()));
if (peer.getOuId() != null && peer.getOuId() != 0L)
intent.setValue("ouId", IntentValue.create(peer.getOuId()));
intent.setValue(Intent.INTENT_OU_ID, IntentValue.create(peer.getOuId()));
if (peer.getWorkspaceId() != null && peer.getWorkspaceId() != 0L)
intent.setValue("workspaceId", IntentValue.create(peer.getWorkspaceId()));
intent.setValue(Intent.INTENT_WORKSPACE_ID, IntentValue.create(peer.getWorkspaceId()));
};
JSONObject payload = new JSONObject();
payload.put("pushTitle", content.getTitle());

View File

@ -5,6 +5,13 @@ package cn.axzo.msg.center.nimpush.payload.intent;
*/
public interface Intent<T> {
String INTENT_ROUTER = "router";
String INTENT_TYPE = "type";
String INTENT_SESSION_TYPE = "sessionType";
String INTENT_SESSION_ID = "sessionId";
String INTENT_WORKSPACE_ID = "workspaceId";
String INTENT_OU_ID = "ouId";
void setValue(String key, IntentValue value);
T build();
@ -12,7 +19,7 @@ public interface Intent<T> {
// !! helper
static void setRouter(Intent<?> intent, IntentValue value) {
intent.setValue("router", value);
intent.setValue(INTENT_ROUTER, value);
}
}