fix missing deck card links / always show links if available in message

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-02-25 12:47:27 +01:00
parent c4ce5729e1
commit 42fea1a588
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 54 additions and 45 deletions

View File

@ -6,7 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Types of changes can be: Added/Changed/Deprecated/Removed/Fixed/Security
## [Unreleased]
### Added
### Fixed
- show links for deck-cards
## [11.0.0] - 2021-02-23
### Added

View File

@ -210,7 +210,7 @@ public class NotificationWorker extends Worker {
if (notification.getMessageRichParameters() != null &&
notification.getMessageRichParameters().size() > 0) {
decryptedPushMessage.setText(ChatUtils.getParsedMessage(notification.getMessageRich(),
decryptedPushMessage.setText(ChatUtils.Companion.getParsedMessage(notification.getMessageRich(),
notification.getMessageRichParameters()));
} else {
decryptedPushMessage.setText(notification.getMessage());

View File

@ -155,7 +155,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
@Override
public String getText() {
return ChatUtils.getParsedMessage(getMessage(), getMessageParameters());
return ChatUtils.Companion.getParsedMessage(getMessage(), getMessageParameters());
}
public String getLastMessageDisplayText() {

View File

@ -1,43 +0,0 @@
/*
* Nextcloud Talk application
*
* @author Mario Danic
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.models.json.chat;
import java.util.HashMap;
public class ChatUtils {
public static String getParsedMessage(String message, HashMap<String, HashMap<String, String>> messageParameters) {
if (messageParameters != null && messageParameters.size() > 0) {
for (String key : messageParameters.keySet()) {
HashMap<String, String> individualHashMap = messageParameters.get(key);
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
message = message.replaceAll("\\{" + key + "\\}", "@" +
messageParameters.get(key).get("name"));
} else if (individualHashMap.get("type").equals("file")) {
message = message.replaceAll("\\{" + key + "\\}", messageParameters.get(key).get("name"));
}
}
}
return message;
}
}

View File

@ -0,0 +1,49 @@
/*
* Nextcloud Talk application
*
* @author Mario Danic
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
* @author Marcel Hibbe
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.models.json.chat
class ChatUtils {
companion object {
fun getParsedMessage(message: String?, messageParameters: HashMap<String?, HashMap<String?, String?>>?):
String? {
var resultMessage = message
if (messageParameters != null && messageParameters.size > 0) {
for (key in messageParameters.keys) {
val individualHashMap = messageParameters[key]
val type = individualHashMap?.get("type")
if (type == "user" || type == "guest" || type == "call") {
resultMessage = resultMessage?.replace("{$key}", "@" + individualHashMap["name"])
} else if (individualHashMap?.containsKey("link") == true) {
resultMessage = if (type == "file") {
resultMessage?.replace("{$key}", individualHashMap["name"].toString())
} else {
individualHashMap["link"].toString()
}
}
}
}
return resultMessage
}
}
}