Skip to content

Commit

Permalink
Better handle of synapse SQL connection
Browse files Browse the repository at this point in the history
- Do not fail if it is not configured
- Add missing configuration step
  • Loading branch information
Max Dor committed Oct 18, 2018
1 parent 544cab8 commit bd9161e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/features/experimental/application-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ matrix:
localpart: 'appservice-mxisd'
token:
hs: 'HS_TOKEN_CHANGE_ME'

synapseSql:
enabled: false ## Do not use this line if Synapse is used as an Identity Store
type: '<DB TYPE>'
connection: '<DB CONNECTION URL>'
```
The `synapseSql` section is used to retrieve display names which are not directly accessible in this mode.
For details about `type` and `connection`, see the [relevant documentation](../../stores/synapse.md).
If you do not configure it, some placeholders will not be available in the notification, like the Room name.

You can also change the default template of the notification using the `generic.matrixId` template option.
See [the Template generator documentation](../../threepids/notification/template-generator.md) for more info.

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/io/kamax/mxisd/as/AppServiceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ public void processTransaction(List<JsonObject> eventsJson) {
log.info("Found an email address to notify about room invitation: {}", tpid.getAddress());
Map<String, String> properties = new HashMap<>();
profiler.getDisplayName(sender).ifPresent(name -> properties.put("sender_display_name", name));
synapse.getRoomName(roomId).ifPresent(name -> properties.put("room_name", name));
try {
synapse.getRoomName(roomId).ifPresent(name -> properties.put("room_name", name));
} catch (RuntimeException e) {
log.warn("Unable to fetch room name - Did you provide synapse DB information as documented?");
log.warn("Underlying error:", e);
}

IMatrixIdInvite inv = new MatrixIdInvite(roomId, sender, mxid, tpid.getMedium(), tpid.getAddress(), properties);
notif.sendForInvite(inv);
Expand Down

0 comments on commit bd9161e

Please sign in to comment.