public static void onMsgReaction(StreamMessage reaction_msg, byte[] msg_reaction_data, int channel, RemoteEndpoint endpoint)
        {
            SpixiMessageReaction smr = new SpixiMessageReaction(msg_reaction_data);
            StreamMessage        msg = Messages.getMessage(smr.msgId, channel);

            if (msg == null)
            {
                return;
            }

            Messages.addMessage(reaction_msg, channel, false);
            NetworkServer.forwardMessage(ProtocolMessageCode.s2data, reaction_msg.getBytes());
        }
Beispiel #2
0
 public bool addReaction(byte[] sender_address, SpixiMessageReaction reaction_data, int channel)
 {
     if (!reaction_data.reaction.StartsWith("tip:") && !reaction_data.reaction.StartsWith("like:"))
     {
         Logging.warn("Invalid reaction data: " + reaction_data.reaction);
         return(false);
     }
     if (reaction_data.reaction.Length > 128)
     {
         Logging.warn("Invalid reaction data length: " + reaction_data.reaction);
         return(false);
     }
     lock (messages)
     {
         var tmp_messages = getMessages(channel);
         if (tmp_messages == null)
         {
             return(false);
         }
         FriendMessage fm = tmp_messages.Find(x => x.id.SequenceEqual(reaction_data.msgId));
         if (fm != null)
         {
             if (fm.reactions.Count >= 10)
             {
                 Logging.warn("Too many reactions on message " + Crypto.hashToString(reaction_data.msgId));
                 return(false);
             }
             if (fm.addReaction(sender_address, reaction_data.reaction))
             {
                 Node.localStorage.requestWriteMessages(walletAddress, channel);
                 if (chat_page != null)
                 {
                     chat_page.updateReactions(fm.id, channel);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }