Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix typos in multiple files #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions server/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ func GetPublicKey(c *fiber.Ctx) error {
return c.JSON(res.SendPublicKey)
}

func ReplayMessage(c *fiber.Ctx) error {
func ReplyMessage(c *fiber.Ctx) error {
userid := c.Locals("userid")

var body request.ReplayMessage
var body request.ReplyMessage

if err := c.BodyParser(&body); err != nil {
return err
Expand Down Expand Up @@ -266,7 +266,7 @@ func GetMessages(c *fiber.Ctx) error {
Content: result[i].Content,
Time: result[i].Time,
Owner: owner, // true
CanReplay: true,
CanReply: true,
SenderPublicKey: sourceUser.SendPublicKey,
Quote: &response.Quote{
ID: res.ID,
Expand All @@ -279,7 +279,7 @@ func GetMessages(c *fiber.Ctx) error {
Content: result[i].Content,
Time: result[i].Time,
Owner: owner, // false
CanReplay: true,
CanReply: true,
SenderPublicKey: sourceUser.ReceivePublicKey,
Quote: &response.Quote{
ID: res.ID,
Expand All @@ -294,7 +294,7 @@ func GetMessages(c *fiber.Ctx) error {
Owner: owner,
Quote: nil,
Content: result[i].Content,
CanReplay: true,
CanReply: true,
SenderPublicKey: sourceUser.SendPublicKey,
})
}
Expand Down
2 changes: 1 addition & 1 deletion server/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SendMessage struct {
Message string `json:"message"`
}

type ReplayMessage struct {
type ReplyMessage struct {
MessageId uint64 `json:"message_id"`
Message string `json:"message"`
}
2 changes: 1 addition & 1 deletion server/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ type GetMessages struct {
Time time.Time `json:"time"`
Owner bool `json:"owner"`
Quote *Quote `json:"quote,omitempty"`
CanReplay bool `json:"can_replay"`
CanReply bool `json:"can_reply"`
SenderPublicKey string `json:"sender_public_key"`
}
4 changes: 2 additions & 2 deletions server/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (

func DefineRoutes(app *fiber.App) {
app.Get("/", middlewares.AuthMiddleware, handlers.HelloWorld)

app.Get("/me", middlewares.AuthMiddleware, handlers.GetMe)
app.Get("/get-messages", middlewares.AuthMiddleware, handlers.GetMessages)
app.Get("/profile/:username", handlers.GetProfile)
app.Get("/get-key/:id", middlewares.AuthMiddleware, handlers.GetPublicKey)
app.Post("/set-username", middlewares.AuthMiddleware, handlers.SetUsername)
app.Post("/send-message", middlewares.AuthMiddleware, handlers.SendMessage)
app.Post("/set-key", middlewares.AuthMiddleware, handlers.SetPublicKey)
app.Post("/replay-message", middlewares.AuthMiddleware, handlers.ReplayMessage)
app.Post("/reply-message", middlewares.AuthMiddleware, handlers.ReplyMessage)
}
34 changes: 17 additions & 17 deletions src/components/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const props = defineProps<{
time: string
owner: boolean
mark: boolean
canReplay: boolean
canReply: boolean
sender_public_key: string
quote?: {
id: number
content: string
}
}>()

const replaying = ref(false)
const replayMessage = ref('')
const replaySent = ref(false)
const replying = ref(false)
const replyMessage = ref('')
const replySent = ref(false)

const vDecrypt = {
mounted: async (el: HTMLParagraphElement) => {
Expand Down Expand Up @@ -69,7 +69,7 @@ const vFocus = {
}

function Submit() {
if (!replayMessage.value) return
if (!replyMessage.value) return

axios.get(`/get-key/${props.id}`).then(async ({ data: key }) => {
window.Telegram.WebApp.CloudStorage.getItem(
Expand All @@ -78,19 +78,19 @@ function Submit() {
const encryptedMsg = await createE2EPacket(
key,
privateKey!,
replayMessage.value,
replyMessage.value,
)
axios
.post('/replay-message', {
.post('/reply-message', {
message_id: props.id,
message: encryptedMsg,
})
.then(() => {
replaying.value = false
replayMessage.value = ''
replaySent.value = true
replying.value = false
replyMessage.value = ''
replySent.value = true

setTimeout(() => (replaySent.value = false), 1500)
setTimeout(() => (replySent.value = false), 1500)
})
},
)
Expand All @@ -115,29 +115,29 @@ function Submit() {

<p class="break-words py-2" dir="auto" v-decrypt>{{ text }}</p>

<template v-if="canReplay">
<div v-if="!replaying" class="flex justify-end text-gray-400 text-end">
<div class="flex items-center cursor-pointer" @click="replaying = true">
<template v-if="canReply">
<div v-if="!replying" class="flex justify-end text-gray-400 text-end">
<div class="flex items-center cursor-pointer" @click="replying = true">
<span class="ml-1 text-sm">پاسخ</span>
<ReplyIcon size="20" color="#9CA38F" />
</div>
</div>

<div v-else class="flex flex-col mt-4">
<Textarea
v-model="replayMessage"
v-model="replyMessage"
placeholder="پاسخ شما..."
v-focus
></Textarea>
<Button :block="true" class="mt-4" @click="Submit">ارسال</Button>
<p
class="text-center pt-4 text-[#119af5] font-bold cursor-pointer"
@click="replaying = false"
@click="replying = false"
>
بیخیال
</p>
</div>
<p v-if="replaySent" class="text-center text-[#119af5]">
<p v-if="replySent" class="text-center text-[#119af5]">
پاسخ شما ارسال شد.
</p>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/views/Inbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ axios
<div class="grid grid-cols-1 gap-y-3 my-4">
<template v-if="messages?.length">
<Message v-for="(message, i) in messages" :key="i" :id="message.id" :time="message.time" :owner="message.owner"
:quote="message.quote" :text="message.content" :canReplay="message.can_replay" :mark="false"
:quote="message.quote" :text="message.content" :canReply="message.can_reply" :mark="false"
:sender_public_key="message.sender_public_key" />
</template>
<p class="text-center text-gray-400" v-else>
Expand Down