move contacts related methods to its own file
This commit is contained in:
parent
88bf4fca66
commit
9a03038126
|
@ -5,6 +5,7 @@ import chronicles
|
|||
|
||||
import ../../status/status
|
||||
import ../../status/chat as status_chat
|
||||
import ../../status/contacts as status_contacts
|
||||
import ../../status/chat/[chat, message]
|
||||
|
||||
import views/channels_list
|
||||
|
@ -133,4 +134,4 @@ QtObject:
|
|||
self.status.chat.renameGroup(self.activeChannel.id, newName)
|
||||
|
||||
proc blockContact*(self: ChatsView, id: string): string {.slot.} =
|
||||
return self.status.chat.blockContact(id)
|
||||
return self.status.contacts.blockContact(id)
|
||||
|
|
|
@ -6,6 +6,7 @@ import ../../status/libstatus/settings as status_settings
|
|||
import json
|
||||
|
||||
import ../../status/profile
|
||||
import ../../status/contacts
|
||||
import ../../status/status
|
||||
import view
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import views/contact_list
|
|||
import views/profile_info
|
||||
import ../../status/profile
|
||||
import ../../status/accounts as status_accounts
|
||||
import ../../status/contacts as status_contacts
|
||||
import ../../status/status
|
||||
|
||||
QtObject:
|
||||
|
|
|
@ -2,6 +2,7 @@ import NimQml
|
|||
import Tables
|
||||
import strformat
|
||||
import ../../../status/profile
|
||||
import ../../../status/contacts
|
||||
|
||||
type
|
||||
ContactRoles {.pure.} = enum
|
||||
|
|
|
@ -162,6 +162,7 @@ proc confirmJoiningGroup*(self: ChatModel, chatId: string) =
|
|||
var response = parseJson(status_chat.confirmJoiningGroup(chatId))
|
||||
var (chats, messages) = formatChatUpdate(response)
|
||||
self.events.emit("chatUpdate", ChatUpdateArgs(messages: messages, chats: chats))
|
||||
# self.events.emit("pushMessage", PushMessageArgs(messages: messages, chats: chats))
|
||||
|
||||
proc blockContact*(self: ChatModel, id: string): string =
|
||||
var contact = status_profile.getContactByID(id)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import eventemitter
|
||||
import json
|
||||
import libstatus/contacts as status_contacts
|
||||
import profile
|
||||
|
||||
type
|
||||
Contact* = ref object
|
||||
name*, address*: string
|
||||
|
||||
type
|
||||
ContactModel* = ref object
|
||||
events*: EventEmitter
|
||||
|
||||
proc newContactModel*(events: EventEmitter): ContactModel =
|
||||
result = ContactModel()
|
||||
result.events = events
|
||||
|
||||
proc getContactByID*(self: ContactModel, id: string): Profile =
|
||||
let response = status_contacts.getContactByID(id)
|
||||
toProfileModel(parseJSON($response)["result"])
|
||||
|
||||
proc blockContact*(self: ContactModel, id: string): string =
|
||||
var contact = self.getContactByID(id)
|
||||
contact.systemTags.add(":contact/blocked")
|
||||
status_contacts.blockContact(contact)
|
|
@ -7,7 +7,6 @@ import sequtils
|
|||
import chronicles
|
||||
import ../chat/[chat, message]
|
||||
import ../../signals/messages
|
||||
import ../profile
|
||||
|
||||
proc buildFilter*(chat: Chat):JsonNode =
|
||||
if chat.chatType == ChatType.PrivateGroupChat:
|
||||
|
@ -103,19 +102,6 @@ proc sendChatMessage*(chatId: string, msg: string): string =
|
|||
}
|
||||
])
|
||||
|
||||
proc blockContact*(contact: Profile): string =
|
||||
callPrivateRPC("blockContact".prefix, %* [
|
||||
{
|
||||
"id": contact.id,
|
||||
"ensVerified": contact.ensVerified,
|
||||
"ensVerifiedAt": contact.ensVerifiedAt,
|
||||
"ensVerificationRetries": contact.ensVerificationRetries,
|
||||
"alias": contact.alias,
|
||||
"identicon": contact.identicon,
|
||||
"systemTags": contact.systemTags
|
||||
}
|
||||
])
|
||||
|
||||
proc markAllRead*(chatId: string): string =
|
||||
callPrivateRPC("markAllRead".prefix, %* [chatId])
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import core
|
||||
import json
|
||||
import utils
|
||||
import ../profile
|
||||
|
||||
# TODO: remove Profile from here
|
||||
proc blockContact*(contact: Profile): string =
|
||||
callPrivateRPC("blockContact".prefix, %* [
|
||||
{
|
||||
"id": contact.id,
|
||||
"ensVerified": contact.ensVerified,
|
||||
"ensVerifiedAt": contact.ensVerifiedAt,
|
||||
"ensVerificationRetries": contact.ensVerificationRetries,
|
||||
"alias": contact.alias,
|
||||
"identicon": contact.identicon,
|
||||
"systemTags": contact.systemTags
|
||||
}
|
||||
])
|
||||
|
||||
proc getContactByID*(id: string): string =
|
||||
callPrivateRPC("getContactByID".prefix, %* [id])
|
|
@ -43,6 +43,3 @@ proc removePeer*(peer: string) =
|
|||
|
||||
proc markTrustedPeer*(peer: string) =
|
||||
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
||||
|
||||
proc getContactByID*(id: string): string =
|
||||
result = callPrivateRPC("getContactByID".prefix, %* [id])
|
||||
|
|
|
@ -8,10 +8,6 @@ type
|
|||
MailServer* = ref object
|
||||
name*, endpoint*: string
|
||||
|
||||
type
|
||||
Contact* = ref object
|
||||
name*, address*: string
|
||||
|
||||
type Profile* = ref object
|
||||
id*, alias*, username*, identicon*: string
|
||||
ensVerified*: bool
|
||||
|
@ -47,10 +43,6 @@ proc toProfileModel*(profile: JsonNode): Profile =
|
|||
systemTags: systemTags
|
||||
)
|
||||
|
||||
proc getContactByID*(id: string): Profile =
|
||||
let response = libstatus_core.getContactByID(id)
|
||||
result = toProfileModel(parseJSON($response)["result"])
|
||||
|
||||
type
|
||||
ProfileModel* = ref object
|
||||
|
||||
|
@ -59,5 +51,3 @@ proc newProfileModel*(): ProfileModel =
|
|||
|
||||
proc logout*(self: ProfileModel) =
|
||||
discard status_accounts.logout()
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import accounts as accounts
|
|||
import wallet as wallet
|
||||
import node as node
|
||||
import mailservers as mailservers
|
||||
import contacts as contacts
|
||||
import profile
|
||||
|
||||
type Status* = ref object
|
||||
|
@ -18,6 +19,7 @@ type Status* = ref object
|
|||
wallet*: WalletModel
|
||||
node*: NodeModel
|
||||
profile*: ProfileModel
|
||||
contacts*: ContactModel
|
||||
|
||||
proc newStatusInstance*(): Status =
|
||||
result = Status()
|
||||
|
@ -29,6 +31,7 @@ proc newStatusInstance*(): Status =
|
|||
result.node = node.newNodeModel()
|
||||
result.mailservers = mailservers.newMailserverModel(result.events)
|
||||
result.profile = profile.newProfileModel()
|
||||
result.contacts = contacts.newContactModel(result.events)
|
||||
|
||||
proc initNode*(self: Status) =
|
||||
libstatus_accounts.initNode()
|
||||
|
|
Loading…
Reference in New Issue