-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.lua
More file actions
73 lines (63 loc) · 2.05 KB
/
process.lua
File metadata and controls
73 lines (63 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- AO Scientific Paper Verification System (v1.0.0)
-- Backend for submitting and tracking scientific papers.
local json = require("json")
-- State initialization
State = State or {
papers = {}, -- Stores all submitted papers, indexed by a unique ID
paperCount = 0
}
---
-- Submit a new scientific paper to the registry.
-- @param msg.Tags.Title - The title of the paper.
-- @param msg.Tags.Authors - A comma-separated string of author names.
-- @param msg.Tags.ManuscriptHash - The SHA-256 hash of the full paper document.
-- @param msg.Data - The abstract of the paper.
--
Handlers.add(
"SubmitPaper",
Handlers.utils.hasMatchingTag("Action", "SubmitPaper"),
function (msg)
local title = msg.Tags.Title
local authorsStr = msg.Tags.Authors
local manuscriptHash = msg.Tags.ManuscriptHash
local abstract = msg.Data
if not title or not authorsStr or not manuscriptHash or not abstract then
return msg.reply("Erro: Título, Autores, Hash do Manuscrito e Resumo são obrigatórios.")
end
-- Increment paper count to get a new ID
State.paperCount = State.paperCount + 1
local paperId = "paper-" .. State.paperCount
-- Split authors string into a table
local authors = {}
for author in string.gmatch(authorsStr, "[^,]+") do
table.insert(authors, author)
end
-- Create the new paper object
local newPaper = {
id = paperId,
title = title,
authors = authors,
abstract = abstract,
manuscriptHash = manuscriptHash,
submissionDate = msg.Timestamp,
submitter = msg.From,
reviewStatus = "pending_review",
reviews = {},
finalVerdict = nil,
credibilityScore = 0
}
-- Add the new paper to the state
State.papers[paperId] = newPaper
msg.reply(json.encode({ success = true, paperId = paperId, message = "Artigo submetido com sucesso." }))
end
)
---
-- Retrieve the list of all submitted papers.
--
Handlers.add(
"GetPapers",
Handlers.utils.hasMatchingTag("Action", "GetPapers"),
function (msg)
msg.reply(json.encode(State.papers))
end
)