|
205 | 205 | (fn [acc [key contact]]
|
206 | 206 | (let [mentionable-contact (add-searchable-phrases-to-contact contact false)]
|
207 | 207 | (if (nil? mentionable-contact) acc
|
208 |
| - (assoc acc key mentionable-contact)))) {} contacts)) |
| 208 | + (assoc acc key mentionable-contact)))) |
| 209 | + {} |
| 210 | + contacts)) |
209 | 211 |
|
210 | 212 | (defn mentionable-contacts-from-identites [contacts my-public-key identities]
|
211 | 213 | (reduce (fn [acc identity]
|
|
222 | 224 | {}
|
223 | 225 | (remove #(= my-public-key %) identities)))
|
224 | 226 |
|
225 |
| -(defn mentionable-users [chat all-contacts current-multiaccount community-members] |
| 227 | +(defn get-mentionable-users [chat all-contacts current-multiaccount community-members] |
226 | 228 | (let [{:keys [name preferred-name public-key]} current-multiaccount
|
227 | 229 | {:keys [chat-id users contacts chat-type]} chat
|
228 | 230 | mentionable-contacts (mentionable-contacts all-contacts)
|
|
246 | 248 |
|
247 | 249 | :else (merge mentionable-users mentionable-contacts))))
|
248 | 250 |
|
249 |
| -(defn get-mentionable-users |
250 |
| - [{:keys [db]}] |
251 |
| - (let [current-chat-id (:current-chat-id db) |
252 |
| - chat (get-in db [:chats current-chat-id]) |
253 |
| - all-contacts (:contacts/contacts db) |
254 |
| - current-multiaccount (:multiaccount db) |
255 |
| - community-members (get-in db [:communities (:community-id chat) :members])] |
256 |
| - (mentionable-users chat all-contacts current-multiaccount community-members))) |
257 |
| - |
258 | 251 | (def ending-chars "[\\s\\.,;:]")
|
259 | 252 | (def ending-chars-regex (re-pattern ending-chars))
|
260 | 253 | (def word-regex (re-pattern (str "^[\\w\\d]*" ending-chars "|^[\\S]*$")))
|
|
365 | 358 | (recur new-text users (rest idxs)
|
366 | 359 | (+ diff (- (count text) (count new-text)))))))))))))
|
367 | 360 |
|
368 |
| -(defn check-mentions [cofx text] |
369 |
| - (replace-mentions text (get-mentionable-users cofx))) |
| 361 | +(defn check-mentions [{:keys [db]} text] |
| 362 | + (let [current-chat-id (:current-chat-id db) |
| 363 | + chat (get-in db [:chats current-chat-id]) |
| 364 | + all-contacts (:contacts/contacts db) |
| 365 | + current-multiaccount (:multiaccount db) |
| 366 | + community-members (get-in db [:communities (:community-id chat) :members])] |
| 367 | + (replace-mentions |
| 368 | + text |
| 369 | + (get-mentionable-users chat all-contacts current-multiaccount community-members)))) |
370 | 370 |
|
371 | 371 | (defn get-at-sign-idxs
|
372 | 372 | ([text start]
|
|
0 commit comments